Go Language

From bibbleWiki
Jump to navigation Jump to search

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")
}