Earlier quoted context omitted.
It is highly debatable if a 200k cost engineer that is suitable for the job wouldn’t bring in more value. Also it is debatable they got any value at all from this. Anyone who wrote unsafe rust and also wrote zig would know that unsafe rust is much much more unsafe in comparison
It's only 4% unsafe and most of it is single-line pointers that came from C++ > At the time of writing, about 4% of Bun's Rust code sits inside an unsafe block (~13,000 unsafe keywords across ~27,000 lines / ~780,000 lines), and 78% of those blocks are a single line — a pointer that came from C++, or one call into a C library. I don't know much about Rust but I imagine this is safer than 100% 'unsafe' code in Zig or…
Rewriting Bun in Rust
331–340 of 560 posts
Re: Rewriting Bun in Rust
#332Article did a decent job of showing discipline and care and human involvement to assert the automated rewrite was done diligently, as best as it can be when using AI for it. I does make me feel a bit more comfortable about it. As an aside, I don't know why anyone would not want to use a memory-safe (and possibly race-safe) language in 2026. Rust gives you that in a performant package, so if you are turned off by GCs…
I would love that Java and .NET would provide all layers like several managed languages in the 90's,
However it has taken a quarter century to get back features we already had in Modula-3, Mesa, Oberon and co.
Re: Rewriting Bun in Rust
#333Earlier quoted context omitted.
It depends just how fast you need it. C++ is much easier to get to zero abstraction code. In Rust you are constantly fighting the stdlib and other libraries, and you have to litter your hot code with unsafe blocks to get it to stop adding a branch to nearly every object access, be it for bounds checks or over/underflow checks. C++ does a much better job at giving you a zero abstraction API, and you can always drop do…
How is not having to mark your unsafe code as unsafe a good thing? You couldn't have come up with something more incomprehensible. If 99% of your code doesn't use unsafe, why contaminate 100% of your code base with footguns?
> How is not having to mark your unsafe code as unsafe a good thing?
The problem with unsafe code in Rust is that IIRC nobody actually figured out yet the "rules" of unsafe i.e. which invariants you can stretch and which can cause UB. My (not super up to date) understanding is that this is an active area of research and progress is being made and also that in practice there are many well understood usages.
In short unsafe rust is somewhat worse than C++ as the boundaries of UB are less well understood/defined
Re: Rewriting Bun in Rust
#334Earlier quoted context omitted.
> As an aside, I don't know why anyone would not want to use a memory-safe (and possibly race-safe) language in 2026. The rust compiler is very slow. The best way to speed it up appears to be organizing a codebase in many crates. This is not preferable ergonomics to many. Beside that, for many problems, a garbage collector eliminates a large amount of defects (including the ones stated in the article) without any add…
Game engines are typically in two languages, one for the engine itself and one for scripting. That even goes for Unity: in Unity, C# is a significantly more powerful than average scripting language (for lack of a better term), but the engine itself is still C++. That's not to say that you couldn't write a commercial game engine with something like C# that stands shoulder-to-shoulder with unity and unreal, but it does…
Re: Rewriting Bun in Rust
#335Earlier quoted context omitted.
> I can understand when you need the absolute best performance and you decide to drop to down to C++ Rust is just as fast as C++.
Is it though. There are so many situations where something is guaranteed to be safe but there is no way to express that in the Rust typesystem, so the only thing you can do is to wrap everything in Arcs and Mutexes, which introduces allocations, pointerchasing and locks
Re: Rewriting Bun in Rust
#336I wonder how much the authors now understand their project? Like, if they were given a bug, would they be able to intuit a possible location in their files that might be causing it? Or are they now essentially locked in to using LLMs to write/rewrite their code?
I don't think this is a value anymore for them.
Re: Rewriting Bun in Rust
#337>Many projects opt to answer these kinds of questions through a style guide. TigerBeetle's TigerStyle is an example in Zig and Google's 31,000 word C++ style guide is another. The challenge with style guides is enforcement.
TigerStyle[1] is a bit more than just a style guide. The key rule for this discussion, uplifted straight from of NASA[2], is *static memory allocation*: all memory is allocated in the startup phase, and there's absolutely zero `alloc`s afterwrads . This plus crash only[3] design means that we never call `free`.
This rule is self-enforcing and compositional, in Zig. There's no global memory allocator, so the code after startup simply hasn't the API to allocate. You can't circumvent this by accident. Of course, if the programmer is byzantine, they can stuff allocator in the global, or just directly `mmap` and `unmap` pages of memory, but, at our scale, we don't have problems with that. This is a similar in kind (not degree) to Rust, where untrusted code generally can circumvent safety guarantees, even without literally spelling `unsafe`.
And, naturally, never `free`ing goes a long way towards solving many memory errors by construction. Empirically, they just haven't been a problem for TigerBeetle. It's hard to untangle contribution of static allocation in particular from everything else we are doing, but it would make sense for it to play a leading role.
(As a footnote, we aren't actually do static allocation to avoid memory errors, we use it as a linter to check that every quantity has a known _logical_ static limit, the main property we care about)
[1]: https://github.com/tigerbeetle/tigerbeetle/blob/main/docs/TI...
[2]: https://spinroot.com/gerard/pdf/P10.pdf
[3]: https://www.usenix.org/legacy/events/hotos03/tech/full_paper...
Re: Rewriting Bun in Rust
#338Earlier quoted context omitted.
> The rust compiler is very slow. It's not “very slow”, that's a tired meme. It's slower than it could/should, but complaining about rustc being “very slow” is a clear misrepresentation, especially when everybody seems to have been fine with tsc's historical performance for instance. It could be nice if it was faster indeed, but people claiming it's “very slow” are just showing they never worked with it. > The best w…
Why do you think it is not slow? As far as I know the only language that compiles slower is C++, and even then the compilation speeds between c++ and rust seem to be comparable. I believe c, Fortran, zig, C#, Java and golang are all faster compiling languages. That makes rust pretty slow in my book. I get that it doesn’t bother everyone, but that doesn’t change the facts.
Additionally there are ways to have interactive code reloading, e.g. Visual Studio and Live++.
Or even a proper REPL, ROOT, CINT, Xeus.
Naturally all things that Rust could also have, only it hasn't been the focus and there are several decades to catch up.
Re: Rewriting Bun in Rust
#339Earlier quoted context omitted.
> As an aside, I don't know why anyone would not want to use a memory-safe (and possibly race-safe) language in 2026. The rust compiler is very slow. The best way to speed it up appears to be organizing a codebase in many crates. This is not preferable ergonomics to many. Beside that, for many problems, a garbage collector eliminates a large amount of defects (including the ones stated in the article) without any add…
> The rust compiler is very slow. It's not “very slow”, that's a tired meme. It's slower than it could/should, but complaining about rustc being “very slow” is a clear misrepresentation, especially when everybody seems to have been fine with tsc's historical performance for instance. It could be nice if it was faster indeed, but people claiming it's “very slow” are just showing they never worked with it. > The best w…
Re: Rewriting Bun in Rust
#340Earlier quoted context omitted.
> Why do you think it is not slow? The average cargo check for the projects I've worked on, usually finish in less than 1 second, with `cargo build` completing in a single digit second (often below 2s), it's not slow by any means. > I believe c, Fortran, zig, C#, Java and golang are all faster compiling languages. Sure, but the difference between type checking is 10ms and type checking in 500ms is barely noticeable f…
Typescript's compiler is much slower than Rust's, but it's plenty fast enough for most people and you almost never see complains about it because it mostly doesn't matter But you have to compile Rust code to run it. You can run TypeScript code without type-checking it. That’s a massive difference in the development workflow. The new TSC, supposedly 10x faster, will be very pleasant to have but not as much of a game-c…
And yet I'm waiting for TSC every day while almost never thinking about rustc…
> The new TSC, supposedly 10x faster, will be very pleasant to have but not as much of a game-changer as you might expect.
It will be very nice, but I don't expect it to be a game changer, tsc isn't fast but it's fast enough to get the work done, the annoyance is there but it's objectively minimal. Anything else is pointless internet language war.
> A 10x faster Rust compiler would be incredible.
For development? Not really, not for me at least. Against the endless rants about rustc's performance on HN, absolutely.