第一部分 Go 语言基础

maniacbin · · 1942 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

<!-- /* Font Definitions */ @font-face {font-family:Wingdings; panose-1:5 0 0 0 0 0 0 0 0 0; mso-font-charset:2; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:0 268435456 0 0 -2147483648 0;} @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:黑体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimHei; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:1627421319 -2147483648 8 0 66047 0;} @font-face {font-family:"/@黑体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:1 135135232 16 0 262144 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} h1 {mso-style-next:正文; margin-top:17.0pt; margin-right:0cm; margin-bottom:16.5pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:240%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:1; font-size:22.0pt; font-family:"Times New Roman"; mso-font-kerning:22.0pt;} h2 {mso-style-next:正文; margin-top:13.0pt; margin-right:0cm; margin-bottom:13.0pt; margin-left:0cm; text-align:justify; text-justify:inter-ideograph; line-height:173%; mso-pagination:lines-together; page-break-after:avoid; mso-outline-level:2; font-size:16.0pt; font-family:Arial; mso-fareast-font-family:黑体; mso-bidi-font-family:"Times New Roman"; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:1333803225; mso-list-type:hybrid; mso-list-template-ids:1732035604 -564631190 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-number-format:japanese-counting; mso-level-text:第%1章; mso-level-tab-stop:53.25pt; mso-level-number-position:left; margin-left:53.25pt; text-indent:-53.25pt;} @list l1 {mso-list-id:2015305095; mso-list-type:hybrid; mso-list-template-ids:-369974582 67698689 67698691 67698693 67698689 67698691 67698693 67698689 67698691 67698693;} @list l1:level1 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:21.0pt; mso-level-number-position:left; margin-left:21.0pt; text-indent:-21.0pt; font-family:Wingdings;} @list l1:level2 {mso-level-number-format:bullet; mso-level-text:; mso-level-tab-stop:42.0pt; mso-level-number-position:left; margin-left:42.0pt; text-indent:-21.0pt; font-family:Wingdings;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->

Go 语言学习札记
                                                    魏仁言 2010年5月


  第一部分   Go 语言基础

第一章    Go 语言概述
1.1 Go 语言简介
  Go 语言是谷歌推 出的一种全新的编程语 言,可以在不损失应用程序性能的情况下降低代码的复杂性。谷歌首席软件工程师罗布派克(Rob Pike) 说:我们之所以开发Go ,是因为过去10 多年间软件开发的难度令人沮丧。Go 是谷歌2009 发布的第二款编程语言.2009 年7 月份, 谷歌曾发 布了Simple 语言, 它是用来开发Android 应用的一种BASIC 语言.

  北京时间2010 年1 月10 日,Go 语言摘得了TIOBE 公布的2009 年年度大奖。该奖项授予在2009 年市场份额增长最多的编程语言。

  谷歌资深软件工 程师罗布· 派克(Rob Pike) 表示,“Go 让我体验到了从未有过的开发效率.” 派克表示, 和今天的C++ 或C 一样,Go 是一种系统语言. 他解释道,“ 使用它可以进行快速开 发, 同时它还是一个真正的编译语言, 我们之所以现在将其开源, 原因是我们认为它已经非常有用和强大.”

  2007 年, 谷歌把Go 作为一个20% 项目开始研发, 即让员工抽出本职工作之外时间的20%, 投入在该项目上. 除了派克外, 该项目的成员还其它一些谷歌工程师.

  派克表示, 编译后Go 代码的运行速度与C 语言非常接近, 而且编译速度非常快, 就像在使用一个交 互式语言.

  现有编程语言均未专门对多核处理器进行优化. 派克表示,Go 就是谷歌工程师为这类程序编写的一 种语言. 它不是针对编程初学者设计的, 但学习使用它也不是非常困难.Go 支持面向对象, 而且具有真正的封装(closures) 和反射 (reflection) 等功能.

  在学习曲线方面, 派克认为Go 与Java 类似, 对于Java 开发者来说, 应该能够轻松学会 Go.

  之所以将Go 作为一个开源项目发布, 目的是让开源社区有机会创建更好的工具来使用该语言, 例如 Eclipse IDE 中的插件. 目前还没有支持Go 的IDE.

  在目前谷歌公开发布的所有网络应用中, 均没有使用Go. 但是谷歌已经使用该语言开发了几个内部 项目.

  派克表示,Go 是否会对谷歌即将推出的Chrome OS 产生影响, 现在还言之尚早, 不过Go 的确可以和Native Client 配合使用. 他表示,“Go 可以让应用完美的运行在浏览器内.” 例如, 使用Go 可以更高效的实现Wave, 无论是在前端还是后台.

  Go 同时具有两种编译器, 一种是建立在GCC 基础上的Gccgo, 另外一种是分别针对64 位x86 和32 位x86 计算机的一套编译器(6g 和8g ). 谷歌目前 正在研发其对ARM 芯片和Android 设备的支持. 派克表示,“Android 手机存在的问题是, 我们一直没有一个数字协处理器.”

1.2 Go 语言特点
Go 是一种功能强大的系统编程语言,使用它可以方便快捷并快乐地进行编程。与 C 语言一样,可以快速并安全地运行,尤其在并行编程方面表现很出色,它还有一个垃圾收集器,用以保证内存安全。

归纳起来, Go 有以下优点:

 

l         简洁

Go 编写的代码简洁

l         快速

Go 编译器可以快速地编译代码。其运行速度可以与 C 或 C++ 相媲美。

l         安全

Go 是一种类型安全和内存安全的语言。 具有垃圾回收( Garbage Collect , GC )功能,能自动回收不再使用的对象。不需要用户对内存进行管理。 Go 有指针,但是没有指针运算。

l         并行

Go 使用一种轻量级通信的进程,对于促进系统和服务器方面编程,从语言方面进行有力的支持,叫做 Goroutines 。如果你想同时运行几千个 Goroutines, 不需要为内存溢出而烦恼,使用它可以对 堆栈溢出说再见了。

l         有趣

Go 可以快速构建,拥有清晰的语法、垃圾收集器、运行时反射、很多类型方法。它可以像动态语言一样去书写,但是又具有静态语言的速度和安全。使用它是一种乐趣。

l         开源

Go 是开源的,免费的,可以很方便地从网络上获取其源代码。

 

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/savechina/archive/2010/05/20/5612316.aspx


有疑问加站长微信联系(非本文作者)

本文来自:CSDN博客

感谢作者:maniacbin

查看原文:第一部分 Go 语言基础

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

1942 次点击  
加入收藏 微博
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传