Destination Go language for holidays

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. The Go community is now very active, with hundreds of discussions every day in the mailing list, plus strong support from Google, which is considered very promising.

So what can go to solve the problem:
1. Hardware very quickly software development is slow.
2. Dependence is cumbersome.
3. C + + Java is too clumsy.
4. Parallel and GC
5. The advent of multi-core machines is common in 128 core machines in the coming years.

Most of the system languages are not designed to solve these problems, and most of the newly emerging libraries do not improve these problems, but instead intensify.

Go combines the development efficiency of dynamic languages with the security and operational efficiency of statically compiled languages, supporting network and multicore programming, bringing us fast, secure, concurrent, and happy.

Go has a very high efficiency. In fact, golang.org was erected with gDOC. At the same time, the comparison of the Language Performance Evaluation website () go and other languages also fully illustrates that go's efficiency and C language are very close.

design goals for go:
1. System programming language.
2. Quickly compile and execute.
3. Type safety and memory usage security.
4. Very good support for concurrent computing.
5. Efficient, low-latency garbage collection algorithm.

Guiding principles:
1. Reduce bookkeeping.
2. Fewer keywords, less unnecessary input. The unsigned table design makes parsing, debugging, and so on much simpler.
3. Keep the concept orthogonal
4. Keep it simple.
5. Reduce type, no type level, avoid wordy.

Language Features:
Clear, precise syntax: most inherit from C, packet mechanism Pascal/modula/oberon family (declarations, packages), and concurrency from (CSP).
The uppercase symbol exports the symbol.
The function or block start comment is a document that is used for gdoc processing.
An improved if, case compound statement that allows the execution of a statement before the condition. Case does not support automatic fall throught, a description must be displayed. Case supports multiple judgements.

Light-weight type system
No implicit conversions
Strongly typed, explicit type conversions
pointer arithmetic slice instead of providing security
Common type: interface{}
Built-in arrays and dictionaries
Object-oriented programming is supported, but hierarchy inheritance is not supported.
The fusion of multiple language features is familiar to everyone in the community, especially C, LUA, and Python community users are very easy to get started with.

Runtime: C and Assembler implement the infrastructure of memory allocation and collection, stack management, lightweight coprocessor, communication pipeline, slicing, map and reflection, etc.

Gc: Currently using the classic simple mark and sweep algorithm, a more efficient, low latency algorithm will be adopted in the future.

Library implementations:
1. Fully implemented in the go language, independent of other system libraries
2. From the interface library such as XML, Asn1,jonson, IO Library, compression, encryption library and so on, relatively complete, greatly facilitates the user.
Unicode supported. It is worth mentioning the "Hello World" of Go, which shows the support for Unicode very well.

Module:
Package management. A package can be scattered across multiple files, just like a file effect.

Extended:
Cgo supports C and go programming mixes, making go extension very easy, allowing Cgo to do the conversion of parameters and types, directly connected to the user's C function.


The Range:for statement supports common iterations, supports arrays, dictionaries, and communication pipelines. In particular, the communication pipeline combined with Goroutine, the producer is responsible for entering data at one end, range acts as a consumer, from the other end ... Makes the iterative implementation of the inclusion very elegant and easy to understand.

Type: A fairly flexible struct that supports anonymous fields, and reuse looks elegant.

Interface:
Interface type interface implementation is decoupled. interface{} is used to implement representations of the same type for implementing container-preserving and parameter-omitting.

Closures: A function is the first class of objects. With closures, it's easy to combine data and functions to form a separate actuator without worrying about data leaks.

Reflection (Reflection): for implementing multiple parameters and implementations such as XML libraries, it is very straightforward to map the field names and values of the structure, but the efficiency is not high.

Network support. Support TCP,UDP, unified interface, but the network read and write temporarily invalid, the Net module will automatically register the handle to the system's poll, and let go of execution, waiting for the occurrence of read-write events. As soon as the event is notified, the blocked handle in net is notified through the channel to continue execution. From the user's point of view, the network read and write are sequential execution, greatly simplifying the programming.

Goroutine:goroutines is the core that makes concurrent programming easy. The core idea is to dispatch the execution unit of the independent function through the system's threads. When a co-process is blocked, such as a system call, the scheduler automatically arranges the other threads to execute, thus guaranteeing uninterrupted operation of the system. This schedule is transparent to the programmer, and from the user's point of view, the co-process is running. And the overhead of this scheduling is very small, the typical CPU can be dispatched million per second, so that we can create a large number of goroutine, simulation of real-world behavior, greatly simplifying the design and implementation of the program.

The core idea of CHANNEL:CSP is through message sharing, not memory sharing. The message sharing mechanism is to pass the message through the channel, with synchronous and asynchronous points. The channel bridges the communication between producers and consumers.

It is network+ closure +goroutine+channel let go so prominent.

Existing problems:
1. Language implementation time is short, the implementation and the community are not mature, some language features such as select Timeout has not been implemented.
2. The language library and go-based applications are still relatively small, even within Google is a pilot project.

Look at the online evaluation of its very high, to look at the study!! The group of several technical people, has now begun coding, admire their speed and ability!!
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.