This document provides an overview of the Go programming language for developers familiar with C#. It outlines some basics of Go including its native compilation, syntax inspired by C, and suitability for system/server development. Key aspects of Go covered include its concurrency model using lightweight goroutines, interfaces, and garbage collection. The document also discusses perceived disadvantages like the lack of generics and tooling challenges but emphasizes Go's simplicity and suitability for server and CLI applications.
7. Basics
•Native
•Wide OS Support (Win, MacOS, *BSD, Linux)
•Simple syntax (C inspired)
•Produces single binary
•Best used for system/server development
8. Basics
•Native
•Wide OS Support (Win, MacOS, *BSD, Linux)
•Simple syntax (C inspired)
•Produces single binary
•Best used for system/server development
•Traded “trendy” for practicality
11. The Good
• Small syntax (fits in your head)
• Great concurrency model (goroutines)
12. The Good
• Small syntax (fits in your head)
• Great concurrency model (goroutines)
• Interfaces (same but different)
13. The Good
• Small syntax (fits in your head)
• Great concurrency model (goroutines)
• Interfaces (same but different)
• Garbage collection
14. The Good
• Small syntax (fits in your head)
• Great concurrency model (goroutines)
• Interfaces (same but different)
• Garbage collection
• Runtime performance (personal experience, but could find
benchmarks proving one way or the other)
15. Go Routines
• Think of them as very light weight TPL Tasks with queues for inter task
comms
16. Go Routines
• Think of them as very light weight TPL Tasks with queues for inter task
comms
• Can have hundreds of thousands of them without issue
17. Go Routines
• Think of them as very light weight TPL Tasks with queues for inter task
comms
• Can have hundreds of thousands of them without issue
• Think GreenThreads (ish) but done right (IMHO)
18. package main
import “fmt”
func doSuperComplexCalc() {
// super secret incredibly complex calculation
// writes results somewhere.
}
func main() {
doSuperComplexCalc()
// do more complex work in main thread.
fmt.Printf(“done!”)
}
19. package main
import “fmt”
func doSuperComplexCalc() {
// super secret incredibly complex calculation
// writes results somewhere.
}
func main() {
go doSuperComplexCalc()
// do more complex work in main thread.
fmt.Printf(“done!”)
}
24. The Ugly Cliché
• Tooling
• Editors/IDEs (VS Code, Sublime Text, Gogland, Vim…. Emacs if you’re
that class of person)
25. The Ugly Cliché
• Tooling
• Editors/IDEs (VS Code, Sublime Text, Gogland, Vim…. Emacs if you’re
that class of person)
• No exceptions, check every function return
err := DoSomething()
If err != nil {
// we have an error.
}
27. The Strange
• Object Oriented…. “yes and no” (Golang FAQ)
• No classes only structs (no inheritance)
28. The Strange
• Object Oriented…. “yes and no” (Golang FAQ)
• No classes only structs (no inheritance)
• Think of methods as C# extension methods
29. Methods
type Calculator struct {
total int
}
func (c *Calculator) AddToTotal(x int) {
c.total += x
}
func (c *Calculator) DisplayTotal() {
fmt.Printf("Total is %d", c.total)
}
30. Overall thoughts
• Great for server work
• Great for CLI tools
• Very easy to become productive
• Very helpful community
• Missing some nice-to-haves (eg Nuget, LINQ)
32. Similar Concepts
C# GO
Task GoRoutine
Class/Struct Struct
Dictionary Map
Array Array
List Slice (wrapper around Array)
Class Composition Embedded Types