Go is a general-purpose, compiled language that is strongly typed, garbage-collected, and has explicit support for concurrent programming through goroutines and channels. Programs in Go are constructed using packages and the language provides standard types while also allowing functions to return multiple values.
The document discusses the Go programming language and why it was created. It provides several key points:
- Go was created over a decade since a new major systems language emerged, and the computing landscape has changed significantly in areas like software development speed, dependency management, type systems, garbage collection, and parallelism.
- Go aims to address these changes with a compiled, garbage-collected language that provides fast compilation, easy dependency analysis, lightweight static types, built-in support for concurrency and communication on multicore systems.
- Some of Go's guiding principles in design were to reduce typing, clutter, and complexity while avoiding forward declarations and header files everything is declared once without type hierarchies.
Go is a general-purpose, compiled language that is strongly typed, garbage-collected, and has explicit support for concurrent programming through goroutines and channels. Programs in Go are constructed using packages and the language provides standard types while also allowing functions to return multiple values.
The document discusses the Go programming language and why it was created. It provides several key points:
- Go was created over a decade since a new major systems language emerged, and the computing landscape has changed significantly in areas like software development speed, dependency management, type systems, garbage collection, and parallelism.
- Go aims to address these changes with a compiled, garbage-collected language that provides fast compilation, easy dependency analysis, lightweight static types, built-in support for concurrency and communication on multicore systems.
- Some of Go's guiding principles in design were to reduce typing, clutter, and complexity while avoiding forward declarations and header files everything is declared once without type hierarchies.
Go is an open source programming language designed by Google to be concurrent, garbage collected, and efficient. It has a simple syntax and is used by Google and others to build large distributed systems. Key features include garbage collection, concurrency with goroutines and channels, interfaces without inheritance, and a large standard library.
This document discusses concurrency and parallelism. It defines concurrency as dealing with multiple things at once through structuring solutions, while defining parallelism as doing multiple things at once through execution. It provides examples of concurrency concepts in Go including goroutines, channels, and the Go scheduler. It also gives best practices for concurrency in Go such as using wait groups, channels, contexts, and message queues.
This document compares the Go and Ruby programming languages. It discusses the rising popularity of Go from 2012-2017 according to the TIOBE index. It also compares the number of reserved keywords between several languages, with Ruby having the most. The document then contrasts static and dynamic typing between Go and Ruby. It provides an example of duck typing in Go. It also discusses various aspects of design patterns, concurrency, error handling, and formatting between the two languages.
4. 主要目标
Bruce Eckel 表示:
C++的复杂性(新C++更复杂),对于生产效率的影响,已经不
再合理了。程序员为了使用好C++, 需要跳过很多坑,是完全说不
通的,只是浪费你的时间和精力。现在,go对C++想要解决的那类
问题,做的更合理。
( Bruce Eckel: The complexity of C++ (even more complexity has been added
in the new C++), and the resulting impact on productivity, is no longer justified. All
the hoops that the C++ programmer had to jump through in order to use a C-
compatible language make no sense anymore -- they?re just a waste of time and
effort. Now, Go makes much more sense for the class of problems that C++ was
originally intended to solve.)
11. 关键字
共25个关键词(ANSI C语言32 个,C++ 63个,Lua 20个,Java50个)
GO语言在关键词使用上是非常吝啬的。
Keep it simple, make it general, and make it intelligible.
--- Douglas McIlroy
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
24. 名字空间和类 VS. 目录
1. 一个目录中的所有文件同属一个namespace (朴素思想来源?)
2. 同一目录、不同文件的变量,函数,互相可见,因此也类似于
Class
3. 小写字母开头的为private函数/变量
func test() var a ? 对其他目录不可见
4. 大写字母开头的为public函数/变量
func Test() var A ? 对其他目录可见
50. 通信顺序进程(CSP)
CSP := Communication Sequential Processing
is a formal language for describing patterns of interaction in concurrent systems.
一种用于定义并行交互的形式语言.
eg: COPY = *[c:character; west?c → east!c]
CSP was first described in a 1978 paper by C. A. R. Hoare(東尼·霍爾)
? 1980年,获颁图灵奖。
? 1982年,成为英国皇家学会院士。
? 2000年,因为他在计算机科学与教育方面的杰出贡献,获得英国王室颁赠爵士头衔。
(思考:霍爾还做过什么算法?)