This is a creation in Article, where the information may have evolved or changed.
Go language: Introduction (i)
Before we get to the go language, let's start by filling in some basic concepts
Basic concepts
Program Errors
Trapped errors. Causes the program to terminate execution, such as an array of out-of-bounds access in addition to 0,java
untrapped errors. Continue execution after an error, but any behavior may occur. such as a buffer overflow in C, jump to the wrong address
Forbidden Behaviours
When designing a language, you can define a set of forbidden behaviors. It must include all untrapped errors, but may contain trapped errors.
Well behaved, ill behaved
Well behaved: If forbidden behaviors is not possible for program execution, it is the well behaved.
Ill behaved: otherwise ill behaved ...
Strongly typed and weakly typed
Strongly typed (strongly typed): All Programs in one language are well behaved--and forbidden behaviors is not possible.
Weak type (weakly typed): Otherwise weakly typed. (There is a possibility that some programs may appear forbidden behaviors)
Dynamic and static types (dynamically/statically Typed Language)
Static type (statically): rejects the ill behaved program at compile time.
Dynamic type (dynamiclly): rejects the ill behaved program at run time.
Note: You cannot determine whether a static type language is defined by whether the variable type is explicitly declared.
Static type languages include: explicitly typed explicit type and implicity typed implicit type.
People think C language to write int a, int b and so on, Python do not write (can directly write a, b), so C
Is static, Python is dynamic. This understanding is not accurate enough. For example, OCaml is a static type, but can also be
Not to be explicitly written out.
The OCaml here is a static implicit type.
Dynamic language (programming Language)
Also called dynamic programming language, refers to the program at run time can change its structure: The new function can be introduced, the existing letter
The number can be deleted and so on structural changes. For example, the well-known ECMAScript (JavaScript) is a
Dynamic language. In addition, such as Ruby, Python and so on are also dynamic languages, and C, C + + and other languages do not belong to
Dynamic language.
Example
No type: assembly
Weakly-typed, Static-type: C + +
Weak type, dynamic type check: perl/php
Strongly typed, static type checking: java/c#
Strongly typed, dynamic type checking: Python, Scheme
Static explicit type: JAVA/C
Static implicit type: Ocaml, Haskell
Add several concepts to understand
Dynamic type language: means that the check of type is done at run time.
Static type language: type judgments are judged before they are run.
Strongly typed: Once a variable is assigned a data type, it is always the data type if it is not cast.
Weak type: A variable can be assigned a value of a different data type ...
Note: Whether the dynamic type language is completely irrelevant to the language is not type-safe, do not associate them together!
The previous sections describe a relatively "strict" argument in academia, which is a more popular explanation in the concept of complementarity.
(Personal understanding: "type judgment" to deny (try) "Ill behaved", by "Specify the data type" to
Ensure "well behaved").
Finally help understand
So tired, a little relaxed ~
Go origin and development
This is a gold team of "the Father of inventions" in the field of computer science, and they have very deep insights into system programming languages, operating systems and parallelism.
The Go language originated in 2007 and was formally released in 2009.
The Go language was announced as the "2009 Language of the Year" by Tiobe (known for its popularity ranking in programming languages) on January 8, 2010
Compared with the improvement of computer performance, the field of software development is not considered fast enough or more successful than hardware development (many projects fail), while the volume of the application is constantly expanding, it is urgent to need a higher level concept of low-level language to break the status quo.
Before the advent of the Go language, developers were faced with a very difficult choice whether to use a language that was fast but not very fast to compile (for example, C + +), or to use a language that was faster and less efficient to perform (e.g.. NET, Java), Or do you develop dynamic languages that are less difficult to implement and perform at a faster pace? Obviously, the Go language has the best balance between these 3 conditions: Fast compilation, efficient execution, and ease of development.
The main goal of the Go language is to combine the security and efficiency of static language with the easy development of dynamic language to achieve perfect balance. (The Go language is a type-safe (strongly typed) and memory-safe programming language.) )
1. Build speed
动态语言将快速编译作为自身的一大亮点,像 C++ 那样的静态语言一般都有非常漫长的编译和链接工作。而同样作为静态语言的 Go 语言,通过自身优良的构建机制,成功地去除了这个弊端,使得程序的构建过程变得微不足道,拥有了像脚本语言和动态语言那样的高效开发的能力。Go 语言中另一个非常重要的特性就是它的构建速度(编译和链接到机器代码的速度),一般情况下构建一个程序的时间只需要数百毫秒到几秒。C 语言中“头文件”的概念却导致越来越多因为依赖关系而使得构建一个大型的项目需要长达几个小时的时间,而Go 语言采用包模型这个模型通过严格的依赖关系检查机制来加快程序构建的速度,提供了非常好的可量测性。
2. Garbage collection
由于内存问题(通常称为内存泄漏)长期以来一直伴随着 C++ 的开发者们,Go 语言的设计者们认为内存管理不应该是开发人员所需要考虑的问题。因此尽管 Go 语言像其它静态语言一样执行本地代码,但它依旧运行在某种意义上的虚拟机,以此来实现高效快速的垃圾回收.
3. Process and Channel
Another goal of the Go language is the excellent support for network communication, concurrency, and parallel programming to make better use of a large number of distributed and multicore computers, which is important for Google's internal use. The designer achieves this by goroutine the concept of this lightweight thread, and then communicates between the various goroutine through the channel. They have achieved the automation of the multipart stack growth and goroutine * * multiplexing technology on a thread-based basis.