Go Language: Difference between revisions
Jump to navigation
Jump to search
Created page with "=Introduction= ==Characteristics== Google was using c++, java and python. * c++ high performance, type safety, slow compile, complex * java rapid compile, type safety, complic..." |
|||
Line 46: | Line 46: | ||
package main | package main | ||
import ( | import ( | ||
"fmt" | |||
) | ) | ||
/ | // Comments are here | ||
func main() { | |||
fmt.Println("Hello World") | |||
func main() | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 05:37, 18 August 2020
Introduction
Characteristics
Google was using c++, java and python.
- c++ high performance, type safety, slow compile, complex
- java rapid compile, type safety, complicated eco system
- python easy to use, lack of type safety, slow
So Go was created which had
- Fast compilation
- Fully compiled, better performance
- Strongly typed
- Concurrent by default, threaded
- Garbage collected
- Simplicity as a core value, for example Garbage collected, Strongly typed.
Whats Go Good At?
Good
- Go is easy to learn
- Easy concurrent programming with goroutines and channels
- Great standard library
- Go is performant
- Language defined source code format
- Standardized test framework
- Go programs are great for operations
- Defer statement, to avoid forgetting to clean up
- New types
Bad
- Go ignored advances in modern language design
- Interfaces are structural types
- Interface methods don't support default implementations
- No enumerations
- The := / var dilemma
- Zero values that panic
- Go doesn't have exceptions. Oh wait... it does!
Ugly
- The dependency management nightmare
- Mutability is hardcoded in the language
- Slice gotchas
- Mutability and channels: race conditions made easy
- Noisy error management
- Nil interface values
- Struct field tags: runtime DSL in a string
- No generics... at least not for you
- Go has few data structures beyond slice and map
- go generate: ok-ish, but...
Hello World
package main
import (
"fmt"
)
// Comments are here
func main() {
fmt.Println("Hello World")
}