Zig has a reputation for binaries measured in kilobytes, and its standard library has had an HTTP client with TLS in it for a while. That made it the language most likely to take the top of the leaderboard, and it has, by a margin I did not expect: a fully static binary of 488 KB that streams the reply and completes the tool round trip, against 1.4 MB plus libc for Rust and 5.8 MB for Go.
The code is at github.com/AndyCross/claude-hot-path, 179 lines of code, built with Zig 0.17.0, which shipped on 1 October. The spec every client passes is on the leaderboard page.
Everything goes through Io now
Zig 0.16 introduced an std.Io interface, and by 0.17 everything that touches the outside world takes one: files, sockets, clocks, child processes, the HTTP client. A program gets its Io from the runtime, along with an allocator and the environment, by declaring main with an init parameter:
pub fn main(init: std.process.Init) !void {
const gpa = init.gpa;
const io = init.io;
const env = init.environ_map;
const key = env.get("ANTHROPIC_API_KEY") orelse "";
...
var client: std.http.Client = .{ .allocator = gpa, .io = io };
defer client.deinit();
Reading stdin, writing stdout and opening the timezone file for the tool all take that same io. The standard library's docs site renders from the source and the 0.17 release notes do not cover the change, so the way to learn the API in October 2026 is to read lib/std/http/Client.zig. It is 1,900 lines and well commented, and the tests next to it have a complete POST example. That is where most of the time on this client went. The code itself compiled on the first attempt, which I do not expect to happen again.
The request
A request is three calls: open it with the method, URI and headers, send the body, receive the head. Then the response hands you a Reader over the body, with a buffer you supply:
var req = try ctx.client.request(.POST, uri, .{ .extra_headers = &headers });
defer req.deinit();
try req.sendBodyComplete(payload);
var redirect_buf: [1024]u8 = undefined;
var response = try req.receiveHead(&redirect_buf);
// One SSE line has to fit in this buffer. Tool inputs can be long.
const transfer_buf = try gpa.alloc(u8, 1 << 20);
const reader = response.reader(transfer_buf);
The buffer you supply is the line limit, which is the same decision Go's scanner made explicit with sc.Buffer. The Reader interface then has exactly the function an SSE loop wants. takeDelimiter returns the next line without the newline, or null at the end of the stream:
while (try reader.takeDelimiter('\n')) |line| {
if (!std.mem.startsWith(u8, line, "data: ")) continue; // event:, ping, blank
const ev = try json.parseFromSliceLeaky(json.Value, gpa, try gpa.dupe(u8, line[6..]), .{});
const kind = str(ev, "type");
const index: usize = if (ev.object.get("index")) |i| @intCast(i.integer) else 0;
if (std.mem.eql(u8, kind, "content_block_start")) {
try content.append(ev.object.get("content_block").?);
try partial.append(gpa, .empty);
} else if (std.mem.eql(u8, kind, "content_block_delta")) {
const delta = ev.object.get("delta").?;
const dkind = str(delta, "type");
if (std.mem.eql(u8, dkind, "text_delta")) {
const text = str(delta, "text");
try ctx.out.writeAll(text);
try ctx.out.flush();
...
The gpa.dupe on the line is the one Zig-specific trap in the loop. takeDelimiter returns a slice into the reader's buffer, and the next call invalidates it. std.json.Value parsed leakily keeps pointers into its input for strings, so without the copy the tool-use block collected on one line would be pointing at bytes overwritten by the next. Rust's borrow checker would have refused to compile that. Zig compiles it, and the bug only shows once a second line has arrived. The doc comment on takeDelimiter says it invalidates previously returned slices, which is the only reason the copy was there before the first run rather than after it.
Everything is parsed into std.json.Value, the dynamic tree, and built back the same way with std.json.Stringify.valueAlloc. A Value is a tagged union, so field access is a switch or a comparison against the tag, and a six-line helper that reads a missing or non-string field as an empty string does most of the work the C# and Rust versions got from indexing syntax.
Half a megabyte, static, with TLS and a timezone parser
RUN /opt/zig/zig build-exe client.zig -OReleaseSmall -fstrip -femit-bin=/client
That is the whole build. ReleaseSmall optimises for size, -fstrip drops the symbols, and Zig links statically by default on Linux, so there is no libc and the runtime column on the leaderboard is zero. Inside those 488 KB are an HTTP/1.1 client, a TLS 1.3 client with its own certificate verification, a JSON parser and serialiser, and an allocator. There is no official Zig Docker image, so the Dockerfile downloads the 0.17.0 tarball for the build architecture and checks its SHA-256 against the one on the download page.
It is a tenth of Go's size because of what Go's binary carries: a garbage collector, a scheduler, and reflection metadata for every type encoding/json might meet, because its net/http is written against all of that. Zig's standard library has none of it to carry, and ReleaseSmall with lazy compilation means only the functions the program reaches are in the binary at all. Rust is the fair comparison, since it also has no runtime, and the difference there is mostly rustls and its crypto provider against Zig's own std.crypto.tls, and glibc against nothing.
Where the time goes instead
| Zig | Rust | Go | C# Native AOT | bash and curl | |
|---|---|---|---|---|---|
| Artefact | 488 KB | 1.4 MB | 5.8 MB | 5.4 MB | 3.7 KB |
| Runtime | 0 | 2.0 MB | 0 | 2.4 MB | 23.7 MB |
| Ship | 488 KB | 3.3 MB | 5.8 MB | 7.8 MB | 23.7 MB |
| Cold start, median of 100 | 1.4 ms | 1.1 ms | 1.7 ms | 3.0 ms | 7.0 ms |
| Turnaround, median of 100 | 1.0 ms | 0.7 ms | 1.2 ms | 1.4 ms | 19.1 ms |
| Client total, median of 100 | 3.7 ms | 3.2 ms | 4.8 ms | 7.1 ms | 35.3 ms |
| Peak RSS | 2 MB | 3 MB | 6 MB | 7 MB | 11 MB |
| Lines of code | 179 | 184 | 156 | 102 | 75 |
| Third-party packages | 0 | 36 | 0 | 0 | 0 |
Zig 0.17.0, linux/arm64, Apple M4 Max under Docker.
The size column is Zig's and so is memory: two megabytes of peak RSS is the lowest on the board, a megabyte under Rust. Cold start is a shade behind Rust and Go. The turnaround, the time between the first reply finishing and the second request arriving, is a tenth of a millisecond ahead of Go's and a quarter behind Rust's, and it did not start there. The first version spawned date for the timezone, because Zig's standard library has no timezone database either, and had keep-alive switched off by a line I wrote without thinking. That measured nearly four milliseconds. Zig's std.process.run sets up pipes and a reader for each of them, and the whole spawn cost over two milliseconds on its own.
What replaced it is in the standard library after all: std.Tz parses the TZif format, so the tool opens the zone's file from /usr/share/zoneinfo, walks the transitions to the one in force now, and formats the local time with std.time.epoch. Twenty-five lines, no process, and the connection stays open for the second turn.
How to run it
git clone https://github.com/AndyCross/claude-hot-path
cd claude-hot-path
./bench/bench.sh zig
Docker and Python 3, no key. The build stage downloads Zig once and compiles in about a second. Next is C, with libcurl and a JSON scanner written by hand.
Top comments (0)