What I learned about Bun&ZIg

This post is the result of two independent events:

The post above contains a lot of information about Rust and almost nothing about Bun & Zig.

But Bun is a very interesting project, and knowledge regarding its use of Zig may help us.

Bun uses Zig as “better C” - modern low-level language with excelent coordination with existing “battle-tested” C code (not libs), custom allocators.

Bun minimized usage of Zig std, as less stable part of Zig.

Not related to stability - it’s impossible using current Io implement what bun did using vendored C based usockets.

And funny fact - bun uses Claude code, at least System Calls & File I/O in Zig (it’s human created text - don’t warry) contains following sad rules

Use bun.sys instead of std.fs or std.posix for cross-platform syscalls with proper error handling…Prefer bun.sys.File wrapper for most file operations…For sockets, use uws.Socket not bun.sys

3 Likes