Uttered, from friends recommended Golang to the publication, the use of Golang has been more than 1 years. This kind of time is a rookie level experience for the old-C + + Java elders.
But as a new generation of language features is the actual combat. Golang this year, the project has provided a stable server and strong expansion capabilities, and the client's unity3d in the C #, are powerful, the ultimate development efficiency represents the excellent development language.
Use article
What the hell is Golang doing? Do I need it?
Efficient (performance, development) server language. Including web, games, apps
Writing a desktop-level UI is not a good fit
Do I need to change the current C + +, Python, Erlang and other servers into Golang?
Performance has bottlenecks, development efficiency is low, money has time, can completely
Evaluation article
Listen to too many people's evaluation of Golang, probably divided into such several categories:
C/S Performance party
Such party members pursue the ultimate performance of everything. Fortunately Golang is directly generated native code, otherwise it will be batch of pieces. However, some systems, such as GC, scheduler and allocator, which are made for concurrency and development efficiency at the bottom of the Golang, can lose a lot of performance on the language layer. So there is a reason for the C/s Party to Golang poor performance
Erlang Concurrent Party
As a telecommunications veteran, Erlang has a well-deserved model and architecture, and the OTP is super-extensible. The perfect Actor model also makes logic writing more intuitive than OO
The difference between CSP and actor is only a matter of the channel's attribution, but this nuance is very different from the development of the two languages.
Golang chose CSP on the concurrency model to consider leaving the architecture design to the consumer. Build a world of class libraries like C #, not the same framework world as MFC. Make development More free
Erlang's actor is right. Make development more intuitive, let the crash come early and deal with it ASAP
Rust Party
Rust was released at the time of posting 1.0. This makes the R powder exciting shuttle to the major technical forums and discussion groups
But Rust's idea seems a little paranoid to me, and it's important to expose all kinds of errors in the compilation period, so there are many types and concepts that are not needed, and even languages are more symbolic than C language.
Plain English, someone with a bit of programming experience sees JavaScript completely understood, but watching rust is like a heavenly book.
Compare typescript with the same period, Dart, Swift. Rust is a little bit more inventive.
The party members often compare Golang with various characteristics and pursue the excellence of single characteristics.
But in fact, Golang itself is a complete philosophy. Many language features are associated with each other. There are areas of improper design, of course, more complete system. Do not sum other languages than
Only the speed of solving the problem
Custom Party
Cloud Wind has seen Golang, because the language itself is an enhanced version of C, so it is popular cloud wind like. But after a bunch of evaluations, the cloud was determined to choose the combination of the C+lua to write the Skynet
Although I do not know the reason, but I guess, after all, the control of the language itself is not so optimistic
At the same time, we found that Skynet used the actor model and found that the big-god programmer was the seer.
Reprint Please specify: War Soul small Build Http://www.cppblog.com/sunicdavy
Feeling chapter
Design
Don't try to design a pattern when stepping into Golang
The traditional oo here is illegal, trying to simulate just a funny
Change oo in Golang to compound + interface
For the implementation, the various structures are combined to expose one or more interfaces, as if the user had a lot of holes in the implementation model
Don't be afraid. The global function, the package, can control the scope of global function usage.
There's no need for anything. Interface external package, struct is also a good encapsulation method
Golang no inheritance, so no class derivation diagram is required. There is no derivation of this point-to-point dependency, so a complex and immutable tree structure is not formed when a large number of class relationships arrive
Container
It took a long time for map to discover that Golang had removed the API features of the external map when it was built as a language feature in the map. All access and acquisition is done by language characteristics, atomization
The array can be understood as the underlying object, and you usually use slices, not arrays, and slices are pointers, pointing to arrays. The slice is lightweight, even if the value copy is low-loss
Memory
Golang in actual operation, you will find that memory may go crazy. But after a long run, it stays steady. This has a relationship with Golang memory allocation, garbage collection.
The memory management of modern programming languages is not very rude to allocate a lot of memory directly from the OS. Instead, the memory that is constantly allocated as a block is on demand.
For non-massive applications, the memory model of the Golang itself can be completely stretched. No need to do a memory pool and thread pool for each project like C + +
Channel
Channel and lock who light weight? A word tells you: the channel itself is implemented with a lock. As a result, it is necessary to minimize the use of channel, but the channel is supported by the language layer, moderate use, can improve the code can read and write
Reprint Please specify: War Soul small Build Http://www.cppblog.com/sunicdavy
Error
Think Golang constantly handling err? That is because in other languages do not deal with errors at all, or it is the root of a one-time try to pass all the anomalies, this is a dangerous behavior
Panic can be captured, so when you write a server, you can do it without hanging
Dangerous interface{}
This thing is as dangerous as the void* in C + +, nil is interface{} package will not equal nil, but print out is absolutely nil
Template estimation solves the problem with interface{} inside the container. But the introduction of new things, the estimate will make the present philosophy some messy
Reprint Please specify: War Soul small Build Http://www.cppblog.com/sunicdavy
Beginner Tips
Language learning in accordance with the teaching of the official website to go, run out of the basic will be
Download a liteide, with the Golang runtime, the basic open environment has
Golang class library design and c#/c++ are different, if there is Python experience will feel no vainly disobey sense
There are 10,000 reasons to make wheels stop, there's something you want in the library.
Write big project Search: Golang project directory structure organization
Golang language itself did not find the bug, even if there is also long been caught by the great gods. The only one that feels like bugs is often the first letter of the struct member lowercase, but JSON can't be serialized ...
Use CGO with caution. Officials have stated that the future does not provide complete compatibility with CGO. Any language needs to support C in the early days, but later, after the completion of the incompatibility is the norm
Reference: http://www.cppblog.com/sunicdavy/archive/2015/06/04/210823.html
Golang Full Contact