Vlad's Diving Into Go : Chapter 1 : Introducing Go
- Solving Modern Programming Challenges with Go
- Takes much of the overhead out of object-oriented development to focus on code reuse
- Has a garbage collector
- Development Speed
- Uses a smart compiler and simplified dependency resolution algorithms
- Compiler only looks at libraries that re included in the entire dependency chain
- Needs a test suite to avoid discovering incorrect type bugs at run time
- Concurrency
- Go's concurrency support is one of its strongest features
- goroutines are like threads but use less memory and require less code
- Creates a model where you can send data between goroutines rather than letting goroutines fight to use the same data
- Goroutines
- Goroutines are functions that run concurrently with other goroutines
- Many goroutines execute on a single thread
- Goroutines use less memory than threads and the Go run time will schedule the execution of goroutines against a set of configured logical processors
- Each processors is bound to a single OS thread which makes more efficient with less development effort
- "go" is needed to schedule log function to run as a goroutine and for that goroutine to run concurrently with other goroutines
- one can continue executing the rest of your application while the logging happens concurrently
- Channels
- Channels are data structures that enable safe data communication between goroutines.
- Channels help avoid problems seen in programming languages that allow shared memory access
- Allow only one goroutine at any time
- Channels don't provide data access protection between goroutines
- When pointers are exchanged each goroutine still needs to be synchronized if reads and writes will be performed by different goroutines
- Go's Type System
- Flexible hierarchy-free type system that enables code reuse with minimal refactoring overhead
- Composition, embed types to reuse functionality in a design pattern
- Interface does not need to be declared because the compiler determines whether values of your types satisfy the interface
- Many interfaces in the standard library are very small
- Types are Simple
- Built in types and user defined types
- Similar to structs in C
- Types may declare methods that operate on that data
- Builds long inheritance structure and build small types
- Go Interfaces Model Small Behavior
- Interfaces allow you to express the behavior of a type [Duck Typing]
- If a value of a type implements an interface it means the value has a specific set of behaviors
- Interfaces only need to be implemented not declared
- Go interfaces usually provides a simple way to declare that your type has data to be read in a way that other functions in the standard library understand
- Allows advantages in code reuse and composability
- Memory Management
- Garbage collector adds a little overhead to program execution time
- Hello, Go
- Introducing the go playground http://play.golang.org
- Summary
- Go is modern, fast, and comes with a powerful standard library
- Go has concurrency built in
- Go uses interfaces as the building blocks of code reuse
Comments
Post a Comment