Reference

Programming languages

Choose TypeScript, Go, Rust or C++ and find syntax, everyday APIs, standard libraries and tools in one place.

Scope and conventions

TypeScript/Node, Go 1.23+, Rust 2024 and C++23: from a first CLI to files, JSON, HTTP, concurrency and testing. Complete programs are labeled; other examples identify their surrounding code/imports. Optional libraries and version requirements are named in each entry.

Names & values

Declare, infer, reassign

Go

:= declares inside a function, inferring types; at least one name must be new in that block. = assigns. const names a constant.

Fragment

Fragment inside a function.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
const label = "north"
var count int = 2
count, extra := 3, 1
count += extra

Distinguish shadowing from assignment

Go

:= in an inner block declares a new binding and can shadow an outer name; = assigns an existing binding. In the same block, := may reuse names only when at least one non-blank name is new. The inner count below leaves the outer count unchanged.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
count := 2
inner := 0

{
  count := 5
  inner = count
}

outer := count // 2

Initialize values and defaults

Go

var without an initializer supplies the type’s zero value: numeric 0, false, empty string or nil for nil-capable types. Structs and arrays recursively zero their fields/elements.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
var count int
var text string
var active bool
var values []int // nil slice

Compare values and object identity

Go

Comparable arrays/structs compare their components. Slices/maps generally cannot use == except against nil. slices.Equal compares slice elements; pointer equality compares addresses.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
import "slices"

first := []int{2, 5}
other := []int{2, 5}
sameValues := slices.Equal(first, other)

Recognize copying and shared storage

Go

Arrays and structs are copied as values. A copied slice still refers to backing storage; copied maps refer to the same map. A struct containing slices/maps therefore need not be an independent deep copy.

Fragment

Fragment: imports and type/function declarations at file scope; usage statements inside a function.

main.go
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
original := []int{2, 5}
alias := original
alias[0] = 9 // original[0] is now 9