Hello, Go Language

This article is one "vangoleo the Go language learning notes" series of articles.
Official website: http://www.vangoleo.com/go/hello-golang/

I first contacted in 2015, the Go language, completed the Hello World, then've been watching this new language. So far, Go language development has over the past decade and more, more and more attention of developers, but with the popularity of cloud native, IoT, block chains, Go seems to be the first language of the 21st century. Docker, Kubernetes, Ethernet Fong heavyweight projects are developed based on Go.

Go languages ​​is Google's open source in 2009, a high-level programming language, it is to solve practical problems of large systems development process designed to support concurrent, standardized and unified, simple, elegant, powerful performance, it was hailed as a lot of the Go language preacher "cloud computing C language of the times."

Recently, I was in the systematic study of the Go language, and compiled some study notes. Follow-up will be shared with everyone. Today we talk about the characteristics of the first and the history of language and Go Go language.

Go naming

Go language naming
This is an email sent by Rob Pike, 2007 September 25, 3:12 pm to Robert Griesemer and Ken Thompson of discussion topics related to programming language, the body of the message to the effect that:

I got some inspiration in the car on the way home:

  • To this programming language named "go", it is very short, easy to write.
  • Tools can be named: goc, gol, goa.
  • Interactive debugging tools can be named directly as "go".
  • Language file name suffix .go and so on.

And a lot of great companies born in the same garage, also named Go language and vehicle-related. These are the sources of the Go language name. I personally really like this name Go, it seems the idea of ​​a very casual, very precise. Google has a pedigree, but also reflects the language simple and elegant. Go inside and open a keyword coroutine is go.

Google engineers 20% of the time

Since then Robert, Rob and Ken three people started the research and development within Google, until 2009, Go officially open source, Go project team will be November 10, 2009, that is, the language officially open daily word as its official birthday. Source code was originally hosted http://code.google.comon, it gradually migrated to GitHub after a few years.
Google's "20% time" mode, allowing engineers to come up with 20 percent of the time to research their favorite projects. Voice service Google Now, Google News Google News, traffic information on Google Maps Google Map, is the product of 20% of all time.
Go language is a product of 20% of the beginning of time.

Go three founders language

E-mail mentioned in the Go language is the most important of the three founder:
Founder of the Go language
Let us know what these three heavyweights:

  • Rob Pike: former Bell Labs Unix development team members, key leaders Plan9 operating system development, the main leaders of the Inferno operating system development.
  • ken tomption: Turing Award winner, the predecessor of the C language B language, one of the inventors of the Unix operating system Plan 9's lead author. Jointly developed the UTF-8.
  • Robert: who Google's V8 JavaScript engine, and Chubby development code.

Go language origin

The development of programming languages, and similar species evolution. Each programming language will absorb the essence from the previous language, then innovation and improvement. The following figure shows Go inherited What are the advantages from its predecessors, it is Go stand on the shoulders of these giants in the cloud era, play an increasing role.
Go stand on the shoulders of giants language
Go language inherited from predecessors Features:

  • C Language: Go language is sometimes described as "similar to the C language," or "C language of the 21st century." Go inherited from the C language similar expression syntax, flow control structures, basic data types, call parameters by value, pointer, and many other ideas , as well as C language has been the fancy of the operating efficiency of the machine code as well as compiled and existing OS seamless fit .
  • Pascal: But in the language of the family tree Go There are other ancestors. Which branch from an influential Niklaus Wirth designed Pascal) language. Then Modula-2 language inspired the concept of packages . Then Oberon) abandoned the language module interface files and modules to realize the difference between the files. The second generation of Oberon-2) and introduced directly affect language statements packet syntax, grammar or the like as well as a statement of object-oriented features Oberon) language provided.
  • CSP: Another branch of the ancestral language Go, Go language has brought distinction in other languages important features, inspired by Tony Hoare Bell Labs, published in 1978, based on the literature on concurrent study of the little known to outsiders, the order communication process (communicating sequential processes, abbreviated as CSP). In the CSP, the processing program is run in parallel a set of intermediate no shared state between them using pipe communicate synchronization and control. But Tony Hoare's CSP is just a basic concept used to describe concurrency description language, not a general purpose programming language can be written in an executable program. Go coroutine language duct into communication .

Heavyweight applications

Here are some heavyweight applications listed in Go:
Go language heavyweight applications

Go advantages

If you need me to the real world for a production system to prototype within a few days, testing and deployment, but also can handle per second, five times more than the original request, CPU and memory overhead is also very small. I think only about the Go language may be sufficient.

Go language has the following advantages:

  • Separate binary distribution: Go compile the project will generate a static executable. The file can be run independently without having to rely on others. This embodiment is particularly suitable for containers cloud native environment.
  • Cross compiler:? On any operating system can be compiled binaries on other platforms can run. For example, on a Mac system can compile binaries on Linux and Windows can run.
  • Garbage collection: Go Language support garbage collection. Compared, C ++, Rust and other needs of the developer's own control.
  • Execution performance: Go very fast. Performance is close to C ++. Much higher than Java, Python, Node.
  • Development efficiency: Go along with language development efficiency and operating performance of static and dynamic language of languages.
  • Simple and efficient: Go language's design philosophy including simple and efficient. A typical counter-example is complicated, bloated Java language.
  • Concurrency: concurrent language support level, simplifying parallel development by co-channel process and improve concurrency.
  • Rich standard library: Go standard library covers the text, IO, network, encryption, Web services, remote RPC, template engine and other functions.
  • You can call C language: You can call C language function, and further optimize performance, reusable C vast ecosystem language.
  • Quick compile time: Compile Go particularly fast. You can refer to two static blog generation system, Hexo (Node Development) and Hugo (Go Development).
  • Engineering: The purpose of Go is designed to become an engineering language, solve practical engineering problems. Go language defines the development of norms, and provides a rich set of tools. Using the Go language can write easy to read and understand, easy to test, maintain and expand the program.

Go shortcomings

  • Lack of heavyweight framework. As for Ruby Rails, Python's Django, Java's Spring.
  • Error handling: no abnormal system. Go officials are to solve the problem.
  • Package Management: For a long time, Go official did not have a package management systems. Until recently, the 1.13 version of Go Go Module formally introduced as the official dependency management tool.
  • Instead of the standard object-oriented programming model: This is an innovative Go language. If you are a solid OOP advocates, some may not meet.

culture

People say that whenever you learn a new conversation, you'll immersed in the culture of people say that some of this language. Thus, the more you learn the language, you may have more changes.
Programming languages as well. No matter how your future application of the new programming language, it always give you a new perspective of programming or some special techniques.
Whether it is functional programming, pattern matching or prototype inheritance, once you learn them, you can carry these programming ideas, which extends the toolset as you solve the problem of software developers have. They also changed the way you read high-quality code.
Go and have a great wealth in this regard. Go main pillars of culture is to keep it simple, down to earth code, but does not produce a lot of redundant abstraction and maintainability in the first place. Most of the time spent at work writing code, rather than on the repair tools and environments, or choose a different way to achieve this is part of Go culture.
Go culture can be summed up as: "should only do one thing one way, and keep it simple and efficient" .

A little note. When you need to build relatively complex abstract codes, Go will usually prevent you. Well, I would say this is a simple trade-off.

This article from the www.vangoleo.com release

Guess you like

Origin www.cnblogs.com/leiwei/p/11780026.html