go Language Learning Beginners 1 --- go language key features and development

1.1 Effect of early language development programming language Go

As the "C language of the 21st century", that said, Go language is not made out of thin air, but and C ++, Java and C # C belong to the same department. Not only that, the designers have also learned the essence of the other part of the programming language into the language which Go.

In a statement and package design aspects, Go language influenced Pascal, Modula and Oberon system language; in the design of concurrent principle, Go language from the same by theory affect Tony Hoare's CSP (communicating sequential processes Communicating Squential Processes) of Limbo and Newsqueak practice draws some experience, and the use of Erlang and similar mechanisms.

This is a completely open source programming language, because it uses the BSD license, so anyone can develop commercial software without paying any fees.

Although in order to enable mainstream developers can feel for grammar Go language classes in C language is very friendly and easy transition, but it simplifies the syntax to a large extent, makes them more concise than the syntax of C / C ++ is and clean. At the same time, the Go language also has some of the characteristics of dynamic languages, which makes using Python and Ruby developers who feel very easy to use when using the Go language.

The figure below shows the effect of some other programming language Go languages: Impact Figure 1.3 on the Go programming language other languages

Why 1.2 to create a programming language

  • C / C ++ can not keep up with the pace of development of computer development, more than a decade did not appear a mainstream programming language system in line with the times, so people need a new system programming language to make up that gap, especially in computer information age.

  • Enhance the contrast performance of your computer, software development is not considered to be developing fast enough or more successful than hardware development (there are many projects and failed), while the volume of applications always continues to expand, there is an urgent need one low-level language with a higher level concept to break the status quo.

  • Go before language appeared, developers are always faced with very difficult choices, what is the use of fast execution speed, but speed is not ideal compiled languages ​​(eg: C ++), or use a compiler is faster but poor efficiency in the implementation of the language (eg: .NET, Java), or less difficult to develop but the execution speed of dynamic languages ​​in general it? Obviously, Go language between these three conditions to achieve the best balance: fast compilation, efficient execution, ease of development.

1.3 Go language development goals

The main objective of the Go language is the language of the safety and efficiency of static and dynamic language of ease of development organically combine to achieve the perfect balance, so that the program becomes more fun, but not before suffering the tough choices in line.

Therefore, Go language is a type-safe and memory safe programming language. Although the Go language still exists pointer, but does not allow pointer arithmetic.

Another goal Go languages ​​is an excellent support for network communication, concurrency and parallel programming to better take advantage of multi-core and distributed a large number of computers, which is for use inside of Google is very important. Designer to achieve this goal through the concept of goroutine this lightweight threads, and then to realize the communication between the various goroutine through the channel. They automated segmentation stack grows and goroutine multiplexing technology in the thread basis.

This feature is obviously the most powerful part of the Go language, not only to support the growing importance of multi-core and multi-processor computers, also up for the lack of existing programming languages ​​that exist in this area.

Go language Another very important feature is its build speed (the speed of compiled and linked into machine code), the time required to build a program of only a few hundred milliseconds to several seconds under normal circumstances. As the extensive use C ++ to build the infrastructure of Google, no doubt out of C ++ to build on the very unsatisfactory nightmare fundamentally. This not only greatly enhance the productivity of developers, but also makes the code testing phase of the software development process more compact, without having to waste a lot of time waiting in building on the program.

Dependency management is an important part of software development today, but the C language "header files" concept has led to more and more because of dependencies and makes building a large project can take up to several hours. There is a growing need for a strict, concise dependency analysis system can be quickly compiled programming language. This is the root cause of the package using the Go language model, this model to speed up procedures built through strict inspection mechanism dependencies, provides a very good scalability.

Go the whole compile-time language standard library generally less than 20 seconds, the other regular projects need only half a second time to complete the compilation. This compilation lightning speed even than compiled C or Fortran language even faster, making the compilation of this link is no longer a problem for developers in software development. Prior to this, the rapid dynamic language compiler itself as a highlight, as static as C ++ language are generally very lengthy compile and link work. The same as a static language Go language, through its own mechanism to build excellent, successfully removed the disadvantages, making the process of building the program becomes negligible, with the ability to dynamic languages ​​like scripting language and efficient development of like that.

In addition, Go languages ​​can also be compared with the C / C ++ in execution speed.

Due to memory problems (often referred to as memory leaks) it has long been associated with C ++ developers who, Go language designers think memory management should not be a problem developers need to consider. So despite the Go language like other static languages ​​execute native code, but it is still running in the sense of a virtual machine, in order to achieve rapid and efficient garbage collection (using a simple mark - sweep algorithm).

Although garbage collection is not easy to achieve, but it would be considered an important part of the future development of concurrent applications, Go language designers still complete this difficult task.

Go is also possible to reflect the language related operations at runtime.

Use go installcan easily be deployed on third-party packages.

In addition, Go language also supports the call by the massive library files written in C language (Section 3.9), which in the past developed software capable of rapid transition.

1.4 guiding design principle

Go to simplify the language of chaos and complexity of the encoding process by reducing the number of keywords (25). Clean, neat and concise syntax can increase compilation speed program, because these keywords in the compilation process as few do not even need to help resolve the symbol table.

Work in these areas is to reduce the workload of encoding, even can be compared with the degree of simplification of Java.

Go language has a sense of minimalist artist, because it provides only one to two ways to solve a problem, which allows developers to code very easy to read and understand. As we all know, the readability of the code is the most important software engineering part ( Translator's Note: The code is written posters, not addressed to the machine to see ).

The design concept is not established on other concepts, it is not because some of the concepts involved and the complexity of a concept, among them are independent.

Go language a complete set of coding standards, you can view the Go language encoding specification page.

Ruby as it is not defined by the coding standard implementation. As a language with a clear coding standards, which requirements can be as gc and gccgo (Section 2.1) is compiled with different compilers work, which has a better coding standards play a great help to the language itself.

Go LALR grammar standard language, you can also in src/cmd/internal/gc/go.yview, this standard does not require grammar symbol table to help resolve at compile time.

1.5 features language

Go language essentially (procedures and structures) to achieve concurrent programming.

Go because there is no concept of language classes and inheritance, and so it Java or C ++ does not look the same. But it is achieved through the concept of polymorphism of the interface (interface) is. Go have a clear and understandable language lightweight type system, between the level of type did not say. Therefore we can say this is a hybrid language.

In traditional object-oriented language, object-oriented programming techniques is very bloated, they are always to build a huge complex patterns by type hierarchy, contrary to the programming language should aim to enhance productivity.

Go member function is the basic language, methods of their use is very flexible. In Chapter 6, we will see the basic concepts of Go in functional programming.

Go statically typed language, so it is a type-safe language, by adding to the local building codes, program execution speed is very fast.

As a strongly typed language, implicit type conversion is not allowed, keep in mind a principle: that all things are explicit.

Go language fact, there are some features of dynamic languages (keyword var), so that it fled Java and .Net world and use Python, Ruby, PHP and JavaScript developers are also very attractive.

Go language support cross-compiler, for example, you can develop applications that run under Windows run on computers running Linux. This is the first door fully supported programming languages ​​UTF-8, which is not only reflected in the string it can handle using UTF-8 encoding, even its source file formats are used UTF-8 encoding. Go language did truly international!

1.6 The use of language

Go system programming language was designed to be applied to a Web server is mounted, the storage cluster or similar giant central server. For high-performance distributed systems field, Go language than most other languages ​​certainly has a higher development efficiency. It provides support for the massively parallel, which is the best thing for the development of server-side game.

Go language is a very good goal to achieve so-called complex event processing (CEP), the technology required to support massively parallel, high performance and a high degree of abstraction. As we enter the era of things, CEP will inevitably become the focus of attention.

Go language but also a language that can be used to achieve the general goals, such as for processing, front-end display text, or even use it as using the same script.

It is worth noting that, because of the automatic garbage collection and memory allocation, Go language is not appropriate for the development of demanding real-time software.

A growing number of Google's internal large-scale distributed applications are beginning to use the Go language to develop, for example, Google Earth is part of the code is done by the Go language.

If you want to know a number of other organizations using the actual application projects Go language development, you can use the Go to page view of the organization. For reasons of privacy protection, many of the company's projects are not displayed in this page. We will discuss in Chapter 21 using Go to a language developed large-scale storage area networks (SAN) cases.

Go a built-in Chrome browser language compiler for the local Client (NaCl), which is likely to be used to execute applications developed in the Go language in Chrome OS.

Go language can run on Intel or ARM processors, so it can be run under Android, such as Nexus family of products.

Go in the use of language in Google App Engine: May 5, 2011, the official release of the Go SDK for developing Web applications running on the Google App Engine, and before that, developers can choose to use Python or Java. This is mainly the outcome of David Symonds and Nigel Tao efforts. The latest stable version is based on the Go 1.4 of the SDK 1.9.18, on February 18, 2015 release. The current stable version of the Go language is Go 1.4.2.

About 1.7 Characteristics missing

Many properties can be used in most object-oriented languages ​​Go languages ​​do not support, but some of them may be supported in the future.

  • To simplify the design, and does not support function overloading operator overloading

  • In order to avoid confusion and Bug in C / C ++ development and does not support implicit conversion

  • To abandon classes and types of inheritance Go language object-oriented design (Chapter 10-11) by another way

  • Although similar to the variant type of functionality can be achieved in the use of the interface (Chapter 11), but does not support variant types

  • It does not support dynamic loading code

  • Does not support dynamic link library

  • Generics are not supported

  • By  recover and  panic instead exception mechanism (Section 13.2-3)

  • It does not support the assertion

  • It does not support static variables

Go on language development team to discuss these aspects, you can view the page by Go FAQ.

1.8 Using the Go programming language

If you have programming experience in other languages ​​(object-oriented programming languages ​​such as: Java, C #, Object-C, Python, Ruby), after you enter the Go language in the world, you will be like obsessed with your X languages ​​can not extricate themselves. Go language with other languages ​​of different design patterns, so when you try to migrate your X language code to the Go language, you will be very disappointed, so you need to start from scratch with the idea Go to ponder.

If you come to re-examine the use of the concept of Go and analysis at the highest point of a problem, you will usually find a suitable language Go elegant solution.

1.9 Summary

Here are some nirvana Go languages:

  • Simplicity, easy to learn

  • Memory management, simple syntax, easy to use

  • Fast compilation, efficient development

  • Efficient execution

  • Concurrency support, easy to manage

  • Static type

  • Standard library, uniform regulation

  • Ease of Deployment

  • Full documentation

  • Free Open Source

 

Guess you like

Origin www.cnblogs.com/sunweiye/p/11318450.html