Live data from Hacker News

Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

ziggit.dev

171–180 of 202 posts

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#171

Earlier quoted context omitted.

The port was line for line and full of unsafe code. It didn't prevent any bugs. They're not using Rust for its strengths.

The original Zig code is metaphorically one big unsafe block. Even if the Rust port is made up of 3% unsafe blocks, that still means 97% of the original Zig code has been made safe (in the Rust sense).

The safety of safe rust is created by extremely strong and subtle invariants that unsafe rust must maintain perfectly (or all bets are off). The idea that a program with tens of thousands of lines of vibe coded unsafe Rust is memory safe is mind boggling.

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#174

Earlier quoted context omitted.

The port was line for line and full of unsafe code. It didn't prevent any bugs. They're not using Rust for its strengths.

You should give the article[0] a read. "A large percentage of bugs from that list are use-after-free, double-free, and "forgot to free" in an error path. In safe Rust, these are compiler errors and RAII-like automatic cleanup with Drop. Compiler errors are a better feedback loop than a style guide." "At the time of writing, about 4% of Bun's Rust code sits inside an unsafe block (~13,000 unsafe keywords across ~27,00…

The way I'm thinking of it is that they ported Bun from Zig to Unsafe Rust, and are still working on now porting it from Unsafe Rust to Rust (not 100% safe, but a reasonable amount).

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#175

Earlier quoted context omitted.

The port was line for line and full of unsafe code. It didn't prevent any bugs. They're not using Rust for its strengths.

You should give the article[0] a read. "A large percentage of bugs from that list are use-after-free, double-free, and "forgot to free" in an error path. In safe Rust, these are compiler errors and RAII-like automatic cleanup with Drop. Compiler errors are a better feedback loop than a style guide." "At the time of writing, about 4% of Bun's Rust code sits inside an unsafe block (~13,000 unsafe keywords across ~27,00…

I'm optimistic for that refactoring. But if one in 30 lines sprinkled all over everywhere is unsafe then you haven't actually done much to improve safety. When you have a large percent of fully safe functions and modules, that's when you're making a difference. Counting the lines is not a very helpful metric.

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#176
post #146

Earlier quoted context omitted.

Not sure about op but if I post here from my phone I get those. Example: “quoted string”

huh interesting, I've never realized this, is it iOS or android?

It’s a macOS thing too. I turn it off because it burns me when copying code

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#177

Earlier quoted context omitted.

That one’s interesting to me because it speaks to both sides of the debate. Yes, safe Rust is good for catching those kinds of errors at compile time. But also, it should theoretically be very easy for a compiler to avoid those problems in Zig, too, if you are using the language the way it wants to be used. Which, from what I’ve experienced so far, does seem to take a whole lot more effort if you’re using a coding ag…

> using the language the way it wants to be used. This sounds like just the coding conventions dependency they're trying to avoid.

IMO it's the same problem with Rust. LLMs are trained on vast quantities of code that violate Rust soundness in safe code.

LLMs are prediction engines: you can move the needle (heavily) on the predictions from lazy to correct by construction, but the defaults even on high end models like Opus are always riddled with shortcuts.

LLMs can produce coherent & safe Rust 1.92, LLMs can produce coherent Zig 0.16, but that's dependent on in context learning & instruction following.

Re: Buz – A fork of Bun using modern Zig, with sub-1s incremental builds

#179
post #131
post #125

Earlier quoted context omitted.

Since they did a one-to-one translation to start with, hypothetically, if these were the true numbers, you could probably get a static analysis tool to guarantee you that 97% of the zig code was safe and tell you which of the 3% were unsafe. Zig has a lot more syntax and conventions to encourage safe code compare to C after all. It just doesn’t have way to mark which parts are safe or unsafe. An LLM could probably al…

No you cannot get a static analysis tool to guarantee 97% of zig code was safe. Well, you can - the tool is called the borrow checker. Do you know what's infinitely cheaper and faster than an LLM running nightly reviews of all of the code and infact mathematically provable that the code (and any new code) is memory safe? It's called the borrow checker.

it seems like a reasonable enterprise to intercept the data dependency graph from the zig compiler and subject it to analysis to prove memory safety parameters:

(my wip experiment: ) https://github.com/ityonemo/clr

Post reply on HN