This post is the result of two independent events:
- I am learning the Bun project in order to use some parts in my code
- Bun is being ported from Zig to Rust
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.sysinstead ofstd.fsorstd.posixfor cross-platform syscalls with proper error handling…Preferbun.sys.Filewrapper for most file operations…For sockets, useuws.Socketnotbun.sys