1. Language Features#
Go language implements concurrent programming at its core (in terms of programs and structures).
Because Go language does not have the concept of classes and inheritance, it does not look the same as Java or C++. However, it achieves polymorphism through the concept of interfaces. Go language has a clear and understandable lightweight type system, and there is no hierarchy between types. Therefore, it can be said that this is a mixed type language.
In traditional object-oriented languages, using object-oriented programming techniques can be very cumbersome. They always build large type hierarchies through complex patterns, which goes against the purpose of programming languages to improve productivity.
Functions are the basic components in Go language, and their usage is very flexible. In Chapter 6, we will see the basic concepts of functional programming in Go language.
Go language uses static typing, so it is a type-safe language, and when combined with building native code, the execution speed of programs is also very fast.
As a strongly typed language, implicit type conversion is not allowed. Remember one principle: make everything explicit.
In fact, Go language also has some features of dynamic languages (through the var keyword), so it is also very attractive to developers who have moved away from the Java and .Net world and use Python, Ruby, PHP, and JavaScript.
Go language supports cross-compilation, for example, you can develop applications that run on Windows on a computer running Linux. This is the first programming language that fully supports UTF-8, which is not only reflected in its ability to handle strings encoded in UTF-8, but even its source code file format is also encoded in UTF-8. Go language has achieved true internationalization!
2. Usage#
Go language is designed as a system programming language for web servers, storage clusters, or similar large central servers. For the field of high-performance distributed systems, Go language undoubtedly has higher development efficiency than most other languages. It provides massive parallelism support, which is ideal for game server development.
A very good goal of Go language is to implement so-called Complex Event Processing (CEP), which requires massive parallel support, high abstraction, and high performance. As we enter the era of the Internet of Things, CEP will undoubtedly become the focus of attention.
However, Go language is also a language that can be used to achieve general goals, such as text processing, front-end presentation, and even using it like a script.
It is worth noting that due to garbage collection and automatic memory allocation, Go language is not suitable for developing software with high real-time requirements.
More and more large-scale distributed applications within Google are starting to use Go language for development. For example, a part of the code for Google Earth is written in Go language.
If you want to know about some other organizations' practical application projects developed using Go language, you can check the Organizations Using Go page. Due to privacy considerations, many companies' projects are not displayed on this page. We will discuss a case study of a large Storage Area Network (SAN) developed using Go language in Chapter 21.
The Chrome browser has a built-in Go language compiler for native clients (NaCl), which is likely to be used to execute Go language-developed applications in Chrome OS.
Go language can run on Intel or ARM processors, so it can also run on Android systems, such as products in the Nexus series.
3. Missing Features#
Many features that can be used in most object-oriented languages are not supported in Go language, but some of them may be supported in the future.
To simplify the design, function overloading and operator overloading are not supported.
To avoid some bugs and confusion in C/C++ development, implicit conversion is not supported.
Go language abandons the inheritance of classes and types by implementing object-oriented design through another approach (Chapter 10-11).
Although it can achieve similar variant types in terms of interface usage (Chapter 11), it does not support variant types itself.
Dynamic code loading is not supported.
Dynamic linking libraries are not supported.
Generics are not supported.
Exception mechanism is replaced by recover() and panic() (Section 13.2-13.3).
Static variables are not supported.
Summary#
Here are some killer features of Go language:
Simplified problems, easy to learn
Memory management, concise syntax, easy to use
Fast compilation, efficient development
Efficient execution
Concurrency support, easy to handle
Static typing
Standard library, unified specifications
Easy to deploy
Comprehensive documentation
Free and open source