The benefit of Golang is as follows:
1. Quick compile time than the C , C++
Golang provides lightning-quick compiler by using a smart compiler and simplified dependency resolution algorithm.
When build the golang program, the compiler only looks at the libraries that you directly include. (C,C++,JAVA. those programming language will traverse entire dependency chain…)
2. Concurrency
go-routine
Golang can create go-routine
, which is like thread but use far less memory and require less code to use.
Golang can create many go-routine
on a single thread.
1 | func log(msg string){ |
channel
channel
are data structure that let you send typed messages between goroutines with sychronization built in.
Channel can also avoid the share memory problem in concurrency modification problem.
Warning
: channel isn’t provide data access protection.
3. Go type system.
Golang provides flexible hierachy-free type free system that enables code reuse with minimal refactoring overhead.
In tradictional OOD, like JAVA, need to implenment all the method declared in interface.
1 | interface User { |
But in golang type system, you only implement the method you would use.
1 | type Reader interface { |
4. Memory management
Golang has modern garbage collector
that does hard work for you.