Do you know the key features of GO language do?

Xiao Bian gave you today talk about the language of the key features go, GO reason why the powerful language, because it is in the development of server-side, the programmer can always grasp the point of pain, in the most direct, simple, efficient and stable way Solve the problem. Here we will not discuss in depth the specific language grammar GO, will only introduce aspects of critical importance to simplify programming language for everyone to follow the footsteps of masters, GO experience design philosophy. Want to learn the language go and entry-go language of a small partner would take a good look.

GO key features of the language include the following aspects:

  • Concurrent with the coroutine
  • Based message passing communication
  • Rich and useful built-in data types
  • Multi-function return values
  • defer mechanism
  • Reflection (the reflect)
  • High-performance HTTP Server
  • Engineering Management
  • Programming Specification

img

In today's multi-core era, the significance of concurrent programming is self-evident. Of course, many languages ​​support multi-threaded, multi-process programming, but unfortunately, implement and control them is not that people feel relaxed and pleasant. Different Golang is language-level support coroutines (goroutine) Concurrent (coroutines, also known as micro-threading, the overhead is smaller than the thread lighter, higher performance), is very simple to operate, provide keyword-level language (go) for starting coroutine, and may start thousands coroutine on the same machine.

Comparative JAVA multithreading and GO coroutine achieve significantly more direct and simple. This is the GO charm, in a simple, efficient way to solve the problem, keywords, go, GO is perhaps the most important sign language.

Based message passing communication

img

In asynchronous concurrent programming process, can only convenient, quick start coroutine is not enough. Message communication between coroutines, also a very important part. Otherwise, each coroutine will become a runaway Mustang can not control. In GO language used for communication between the coroutine based communication messaging (as opposed to most of the shared memory based communication language used), and the message pipe (channel) as the basic data types, the type of key used word (chan) are defined, thread-safe concurrent operation. This point in the realization of the language, but also revolutionary. Visible, GO language itself is not so simple that there is no bottom line, they will be just the most practical and most conducive to problem-solving abilities, available to users in the most simple and direct form.

Channel is not just used for simple messaging, it can also come out of a lot of very practical, and to implement and very handy feature. For example, to achieve TCP connection pooling, current limiting, etc., and to implement these in other languages ​​is not easy, but GO languages ​​can easily be done.

img

GO language as a compiled language, on the type of data also support very comprehensive, in addition to the traditional type of integer, floating point, character, arrays, structures, and so on. From the viewpoint of practicality, but also character string type, slice type (variable length arrays), a dictionary, a complex type, error type, pipeline type, or even of any type (Interface {}) were native support, and with very Convenience. Such as string, slice type, ease of operation and almost like Python.

In addition, the type of error (error) as the basic data types, and no longer supports try ... catch at the language level of usage, this should be a very bold and revolutionary initiative, it is no wonder many people Tucao GO language nondescript. But beyond the traditional concept, GO developers believe in the programming process, to ensure the robustness and stability of the program, the precise treatment of abnormalities is very important, and only after the completion of each logic processing, clearly inform the upper layer calls, whether there is abnormal, a clear call by the upper, abnormal timely processing, so that it can guarantee a high degree of robustness and stability of the program. While doing so a lot of judgment on the result of error occurs during programming, but it no doubt enhanced the developer of alert for exception handling. The practice has proved that as long as strict accordance with the GO recommended coding style, do not want to write robust code, very difficult. Of course, the premise is that you do not reject it, recognize it.

img

Multi-language support function return values, is nothing new, Python is one of them. Allowing a plurality of function return values, in some scenarios, can effectively simplify programming. GO recommend language programming style, is the last parameter function returns the type of error (exception may occur as long as the logical body), so that at the language level support for multi-value return, it is very necessary.

These are the small series for everyone to go speak the language of the key, I would like to know and learn the language go small partners can follow Marco education official website.

Guess you like

Origin www.cnblogs.com/woshijiuke/p/12611829.html