brain
tamnd's digital brain — notes, problems, research
42734 notes
A direct ancestor of vm3's 32-bit slab index. V8 squeezes 64-bit pointers down to 32-bit offsets within a per-isolate 4 GB virtual region (the "cage"). Cut V8's heap by 43%, Chrome renderer memory by 20%.
The bootstrapping verified ML compiler, its 2024 PLDI agenda, and the FM-JIT verified-JIT effort that builds on it.
Mutable value semantics with subscript-based projection borrowing, no lifetime variables, and the Law of Exclusivity enforced at call sites.
Six capabilities (iso, trn, ref, val, box, tag) make actor-based concurrency data-race-free at compile time. Production at WallarooLabs and Microsoft; foundation for Verona's region work.
Intel LAM (Linear Address Masking) and the x86 top-byte-tag story
The CG-track answer to "what's beyond a single 4 GB linear memory?" Multiple memories shipped in Wasm 3.0 (Sep 2025). Memory64 shipped at the same time. A formal "segmented memory" proposal in the MSWasm vein has not yet entered the CG track but is influencing design.
Arm PAC + BTI
Scudo & friends: hardened allocators in production
Cerise, the CHERI-C Coq memory model, and capability-safety logical relations as the formal model behind handle-based runtimes.
The CRA's 2026-2027 enforcement timeline and the implicit pressure toward memory-safe languages.
AWS's bit-precise bounded model checker for Rust, deployed in CI on Firecracker and the standard library.
Stenberg's curl CVE data, the Hyper / Rust experiment, and the unresolved 2026 question of whether memory-safe languages are the whole answer.
A deductive verifier for safe Rust that compiles to Why3 and discharges to off-the-shelf SMT solvers.
Java's flagship low-latency collector. Sub-millisecond pauses on multi-TB heaps via colored 64-bit pointers and concurrent everything.
The biggest real-world deployment of Perceus reference counting, layered with Morphic alias analysis and "seamless slices" so functional code rarely allocates.
This book describes the Zig programming language as of Zig 0.16.
A
These are short answers or sketches for selected exercises from the book. Many exercises have several reasonable solutions. The important part is clarity and correctness.
This appendix records the kinds of changes that matter when moving older Zig code to Zig 0.16. It is a practical checklist, not a full release history.
Zig tries to report errors at the point where the program becomes invalid. Many messages are direct: a value has the wrong type, a variable is unused, an error was ignored, or...
One of Zig's central goals is direct interoperability with C. Zig can call C code, compile C code, link system libraries, export functions to C, and translate C headers.
Zig builds programs with Zig code. The build script is named:
The Zig standard library is imported as:
Builtin functions are part of the language. Their names begin with @.
This appendix lists the common operators by use. When an expression is not obvious, use parentheses.
This appendix summarizes the core syntax of Zig 0.16. It is a compact reference, not a tutorial.
This appendix is a quick map of Zig syntax. It is not a grammar. The full Zig grammar is part of the official language reference. Zig 0.16 also keeps the language small enough...
The programs in this chapter are small, but they have the shape of larger Zig programs.
This section combines the ideas from the previous sections into one program structure.
A program is finished only when another machine can build and run it reliably.
Exercise 19-1. Write a program that overflows a u8 using +=. Run it in Debug mode and observe the panic.
Threads are a mechanism, not a design.
A benchmark measures the cost of a program or operation. The result is useful only if the measurement is repeatable and the work being measured is clearly defined.
FFI means foreign function interface. It is the boundary where Zig calls code written in another language, or where another language calls Zig.
A semaphore is a counter used for synchronization.
This section collects the chapter exercises into one working set.
Exercise 16-1. Write a C file containing this function:
Tests should be close to the code they check. Zig makes this easy with test blocks.
A normal struct is laid out for efficient access.
Creating a thread is expensive.
Zig can build the same source code in different optimization modes.
A C program and a Zig program can share data only when both sides agree on layout.
These exercises use the material from Chapters 15.1 through 15.8. Most are small. The goal is to practice reading and writing build.zig files until the structure becomes familiar.
Zig can build for a different target than the machine running the compiler.
A Zig package may depend on another package.
Examples are small programs kept inside the project.
This section collects the exercises for Chapter 14.
Zig has built-in support for tests.
The standard library gives access to process information through std.process.
This section collects the exercises for the chapter.
Zig 0.16 changes how I/O code is written in the standard library.
The standard library gives access to files and directories through std.fs.
Input and output can fail.
A library is code meant to be used by another program. In Zig, a library can be built from the same kind of source files as an executable. The difference is in how the build...
Most memory in a program behaves normally.
Zig once had async functions as a language feature.
A program is made from object code.
C can call Zig when the Zig function is exported with a C-compatible ABI.
Zig has tests in the language.
Zig uses format strings to turn values into text.
A program usually has three standard streams:
The exercises in this section are meant to make allocation habits precise. Each one should be written as a complete program unless stated otherwise.
Allocation creates a responsibility.
A fixed-buffer allocator uses memory that already exists.
An arena allocator is used when many allocations have the same lifetime.
An integer type can store only a fixed range of values.
An HTTP client opens a network connection, sends a request, receives a response, and writes the response body.
A mutex protects shared data.
A Zig target may use a C library, or it may use none.
Calling a C function is only half the job. The linker must also find the code for that function.
A build option is a value passed to build.zig from the command line.
A hash map stores key-value pairs.
Reading or writing one byte at a time is expensive.
The general-purpose allocator is used for ordinary heap allocation.
Exercise 11-1. Write a generic min function for values that support <.
Generic functions in Zig are specialized at compile time.
Zig has no built-in interface keyword.
A line filter reads text, changes or selects some lines, and writes the result. Many Unix programs have this shape.
A pointer has a type.
A mutex makes one thread wait while another thread uses shared data.
The architecture part of a target tells Zig what kind of processor the program will run on.
@cImport does two jobs.
A build file describes steps.
std.ArrayList is a growable array.
Writing bytes is the opposite of reading them.
The page allocator gets memory from the operating system.
Zig does not have a formal trait or interface system.
1. Write a program that computes several Fibonacci numbers with comptime. Print the results at runtime.
A file copier is a useful small program. It opens one file for reading, opens another file for writing, then copies bytes from the first to the second.
Zig inserts safety checks for operations that are valid only under certain conditions. These checks are present in safe build modes. They catch mistakes at the point where the...
A mutex is a lock for shared data.
The operating system part of a target tells Zig what kind of system the program will run on.
Writing every C declaration by hand is tedious. Zig can read C headers directly.
The file build.zig is a Zig program.
The std.mem module contains operations on memory, slices, bytes, and basic data movement. Much of Zig programming eventually passes through std.mem.
A file is read as bytes.
An allocator is a value that knows how to allocate and free memory.
A generic struct is a function that returns a type.
A Zig function can return a type.
Many programs begin the same way: they read command-line arguments, decide what the user requested, then execute an operation.