STACK
Ch 03 · Languages & Runtimes
Chapter 03 · The execution layer

Languages & Runtimes — how code becomes computation

Languages give us syntax. Runtimes give us behaviour — and the behaviour is what burns CPU, blows up memory, and surprises you at 3 am. This chapter maps both.

3.1 · Paradigms

ParadigmWhat it emphasisesExamples
ImperativeStep-by-step state mutations.C, Python, JavaScript.
Object-orientedEncapsulation, inheritance, polymorphism.Java, C#, Ruby, Smalltalk.
FunctionalPure functions, immutability, composition.Haskell, Elm, Clojure, F#.
LogicDeclarative facts + rules; engine derives.Prolog, Datalog.
Array / vectorWhole-array ops; minimal loops.APL, J, NumPy in spirit.
ActorConcurrent message-passing entities.Erlang, Elixir.
Multi-paradigmMix & match.Rust, Scala, Python, TypeScript.

3.2 · Type systems — the axes that matter

AxisEnd AEnd B
When checkedStatic (Rust, Go, TS)Dynamic (Python, JS, Ruby)
How strictStrong (Haskell, Rust)Weak (C, JS coercion)
Inferred?Inference (Rust, Haskell)Manual (Java pre-Lombok)
Nominal vs structuralJava, C# (nominal)TS, Go (structural in places)
GenericsHigher-kinded (Haskell)Erasure (Java) / monomorphisation (Rust)
Null-safetyOptional / Result types"$1B mistake" Null
Sum types / pattern matchRust, Swift, OCamlMost OO languages (until recently)

3.3 · The language matrix (2026 picks)

LanguageSweet spotRuntimeGC?
JavaScript / TypeScriptUniversal — web, BFFs, scripts, agents.V8 / JSC / SpiderMonkey, Bun, Deno.Yes (generational)
PythonData, AI, scripting, glue.CPython, PyPy.Yes (RC + GC)
GoNetworked services, CLIs, infra.Native (Go runtime).Yes (concurrent)
RustLatency-critical, safety-critical, embedded, edge.Native; no runtime to speak of.No — ownership
Java / KotlinEnterprise, fintech, JVM ecosystem.HotSpot JVM, GraalVM.Yes (G1, ZGC, Shenandoah)
C# / F#Windows / cross-plat enterprise; gaming (Unity).CLR, .NET 9.Yes (gen GC)
SwiftiOS / macOS native.Native + Swift runtime.ARC
Elixir / ErlangMassive concurrency, telecom-like.BEAM VM.Per-process GC
C / C++Systems, drivers, games, performance.Native.No (manual / smart ptrs)
RubyRails apps; DSLs.YJIT-enabled MRI.Yes
PHPWordPress, classic web; JIT in 8+.Zend.Yes
ZigModern C replacement; comptime power.Native.No
MojoPython-syntax superset aimed at AI perf.MLIR-based.Mixed (manual + GC opt)
GleamType-safe BEAM language.BEAM.Yes

3.4 · AOT vs JIT vs interpreter

AOT Source → binary at build time. Rust, Go, C/C++, Swift, GraalVM native-image, .NET AOT ★ tiny startup · ✗ longer build JIT Compile hot paths at runtime. JVM HotSpot, V8, CLR, PyPy, Ruby YJIT, .NET tiered ★ adaptive · ✗ warm-up Interpreter Walk AST / bytecode line-by-line. CPython, Bash, Lua, classic Ruby ★ flexible · ✗ slower

3.5 · Garbage collection — the four big ideas

ApproachHowUsed in
Reference countingEach object tracks ref count; freed at 0.Swift (ARC), CPython, Rust Rc/Arc.
Mark & sweepWalk reachable graph; sweep unreachable.Many old GCs; conceptual base.
GenerationalYoung / old gens; collect young often, old rarely.JVM, .NET, V8.
Concurrent / low-pauseMostly runs in parallel with the program.JVM ZGC / Shenandoah, Go's GC, .NET background GC.
  • Pause times: ZGC / Shenandoah target sub-ms; Go's GC ~<1 ms p99 typically.
  • Reachability: from roots (stacks, globals); cycles need a cycle collector.
  • Manual: Rust ownership (no GC); C++ smart pointers; C malloc/free.

3.6 · Memory models & ordering

  • Modern CPUs and compilers reorder memory ops. The language memory model defines what's legal and visible.
  • Java Memory Model (JSR-133) + C++ memory model (since C++11) + Go memory model all use happens-before.
  • Atomics: relaxed / acquire / release / acq_rel / seq_cst orderings.
  • Volatile in Java/C# ≠ volatile in C — totally different semantics.
  • Cache coherence: MESI protocol keeps L1/L2 consistent across cores.

3.7 · FFI & ABI — talking across languages

ConceptDefinition
ABIApplication Binary Interface — calling convention, struct layout, name mangling.
FFIForeign Function Interface — calling another language's code.
C ABIThe universal pidgin — almost every language can call extern "C".
JNI / PyO3 / N-API / WASIBridges from JVM / Python / Node / Wasm to native.
WebAssemblyPortable binary; languages compile to it; Wasm components are the future of FFI.

3.8 · Build systems

ToolNotes
Make / CMakeLingua franca for C/C++.
Bazel / Buck2 / PantsHermetic, cached, polyglot. Massive monorepos.
Gradle / MavenJVM standard.
CargoRust's build + package + test in one.
Go modules + go buildBundled with the language.
npm / pnpm / yarn / bunNode.js ecosystem.
Vite / Turbopack / Rspack / RolldownFrontend bundlers (2026).
uv / Poetry / Hatch / RyePython project tools — uv is the new fast default.
Dagger / Earthly / Nx / TurborepoCross-language pipelines / monorepo runners.

3.9 · Package managers & registries

EcosystemRegistryLock file
JSnpm registry (also JSR for Deno)package-lock.json / pnpm-lock.yaml / bun.lockb
PythonPyPIuv.lock / poetry.lock / Pipfile.lock
Rustcrates.ioCargo.lock
Goproxy.golang.orggo.sum
JVMMaven CentralGradle lock files
.NETNuGetpackages.lock.json
RubyRubyGemsGemfile.lock
Systemapt / dnf / pacman / brew / nix / scoop—

Supply-chain hygiene: pin versions, audit with npm audit / cargo audit / Dependabot / Renovate, scan with Snyk / GitHub advanced security.

3.10 · Self-check

Q1 · Go achieves "no GC pauses you'll feel" mostly by…
Avoiding heap allocations
A concurrent, low-pause collector
Reference counting
Manual free()