Go
The rogue's Sprint: a small language that compiles to one fast binary. Fast to build, fast to run, fast to hand to a server.
Wears the Classic spell Sprint.
Coming from Python: Functions, packages, and testing transfer directly. The new discipline is explicitness: every variable you ignore must be ignored on purpose, and errors are values you return, not exceptions you throw.
Summoning the language
First summoning
Install Go, make a module with go mod init, and run the classic. The language fits in an afternoon; the standard library does the heavy lifting.
package main
import "fmt"
func main() {
fmt.Println("Hello, Azeroth")
}
// $ go run main.goThe temper
Errors are values: if err is not nil, you handle it, right there. And a web service is ten lines of standard library, no framework required for a first one.
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "ok")
})
log.Fatal(http.ListenAndServe(":8080", nil))First real chore
Build the JSON API from the Python project ladder in Go instead: one endpoint, one struct, json.Marshal. Then run go build and feel the deploy: the output is ONE file you can copy to any server and run. No runtime, no dependencies.
type Spell struct {
Name string `json:"name"`
Rank int `json:"rank"`
}
// json.NewEncoder(w).Encode(spells)