177 points · by cratermoon · 11mo ago · 72 comments
Remember people, 10,000 CPU hours of fuzzing can save you 5ms of borrow checking!
(I’m joking, I’m joking, Zig and Rust are both great languages, fuzzing does more than just borrow checking, and I do think TigerBeetle’s choices make sense, I just couldn’t help noticing the irony of those two sentences.)
This is what makes TigerBeetle context somewhat special --- in many scenarios, security provided by memory safety is good enough, and any residual correctness bugs/panics are not a big deal. For us, we need to go extra N miles to catch the rest of the bugs as well, and DST is a much finer net for those fishes (given static allocation & single threaded design).
Mathematically speaking, any simple (i.e. non-dependent) type system catches 0% of possible bugs :) That's not to say it can't be very useful, but it doesn't save a lot of testing/other assurance methods.
[1]: https://cwe.mitre.org/top25/archive/2024/2024_cwe_top25.html Also, spatial safety is more important for security than temporal safety. As far as language guarantees go, Zig and Rust only differ on #8 on the list.
I concur with the suggestion of 2^19, because even though fewer people would recognize it immediately, many of them would question the significance, and their eventual realization would be more satisfying.
I think you might be overestimating the curiosity of the average person.
I'm regularly baffled / saddened by how many people care so little about learning anything new, no matter how small.
Is it a woe of modern times? Or has it always been this way?
Mad props to them for picking up my joke and turning it into a recurring donation.
Having a serious, dedicated, and smart partner, in industry, working hard to operationalize and turn a profit on the language is a massive boon to the whole project (and it would be even if they didn't choose to give back monetarily, but all the more since they are!).
Having a modern language that attempts to directly model low level systems is very important.
Edit: Thank you all for your responses!
For some people the huge 'surface area' and strict type system of Rust is a big turn-off, while others want exactly that from a programming language.
One main difference is that Rust is guaranteed memory safe with generally no runtime overhead for that safety. It also has protections and abstractions to make multithreaded code safe and generally correct.
Depends on your definition of safety and correctness. Async Rust does not prevent deadlocks and make them very difficult to detect
Systems programming can be done in ocaml or any language really where there is some documentation on the runtime how not to trigger the GC or flags that can be passed to custom set GC policy
Hacker News discussion: https://news.ycombinator.com/item?id=46153466
For hobby projects, zig will get you *much* closer to the underlying system. So if your goal is systems programming where you're responsible for and get to play with the system itself. Zig will get you there much faster, and the language wont take much time to learn and have fun with.
Surely someone will now attempt to correct me, by asserting it's impossible for anyone to write safe code without rust, and it's improper for me to even suggest Zig. But I'm enjoying the language a lot. It's easy to pick up and understand, and importantly it gets out of your way quickly so you can build exactly the system you want.
For more complex or professional projects however, I would still recommend Zig but more because I can't stand rust. It bothers me that it rejects valid programs because the compiler is unable to prove what I can. So the additional dance rust requires ruins an otherwise fine language.
edit: my default language before zig was also python, so feels reasonable to also mention that I'm pretty sure it'll be significantly easier to transition from python into Zig rather than into rust. There's a number of idioms and expectations from python that fit well in zig, but dont fit in rust.
If you don't have time to learn both, then learn Zig, as it requires much smaller time investment (though do try to find time for both).
I see Zig as being a lot more in C tradition and lineage with nicer and safer memory management techniques. Also comptime (Lisp-ish there?)
My two cents
It links out to the standard library documentation, which is also comprehensive and easy to navigate: https://ziglang.org/documentation/master/std
no, the docs really don’t cut it.
it is strongly opinionated about the correct way to do things but it leaves you to your own devices to piece together an understanding from source code, ziggit, and discord.
Zig is gaining integration into larger projects (Ghostty, TigerBeetle, Roc, Ubers build system come to mind), but it's not yet achieved Rust's success
Rust feels like "let's take the best safety features from both", while Zig feels like "let's take the best transparency from both". In a way, Rust's traits are more foreign to C++ than Zig's comptime, as Zig has similar duck typing (though the ergonomics are much cleaner, especially with @compileError).
Note that there are a number of domains where Zig might be a practical option in the future, but aren't now due to library support. With Rust, you will reinvent wheels more than most people have an appetite for. In Zig, you will do this for most things.
The main complaint about the borrow checker is that what seem like trivial changes can have subtle implications that require wildly different ownership patterns to be made correct. Rust tells you something's wrong. If you don't thoroughly understand how you're using pointers (which few people do), it can feel like trivial changes exploding into much larger refactors than you'd need in languages where the rules aren't statically enforced.
- Do you like filling out the type annotations in Python (making sure linter check passes)? Do you like TYPES in general?
- Do you like working with memory (crushing memory bugs, solving leaks)?
- Do you prefer imperative or functional approach more?
I do like working with memory, seeing a custom slab allocator used in production code was one of the more interesting aspects of the little experience I had with c++, but always having to be "on guard" so as to not shoot myself in the foot with pointer manipulation was kind of exhausting.
I like both.
It really depends what you mean by "interesting" :-)
Disappointingly as a Rust dev, I don't actually see a lot of Rust being used for "systems" development (OS, driver, DB internals, embedded, etc), but increasingly for network services/web services/web stack work, heavily biased towards tokio async driven applications. It's a lot of engineers living further up the stack, leaning on frameworks, and in applications with very large dependency tree footprints. As a % anyways. There's a lot more Rust code out there than Zig.
I think Zig has a far more minimalistic thing going on and I like that. I find its type system a lot more primitive, and would miss ADTs/enums, and the borrow checker etc. but I like its overall philosophy better.
Still I use jom for building but I may move to Zig build
Discussion then: https://news.ycombinator.com/item?id=45703926
The Rust Foundation on the otherhand…
I might miss your point, but I don't see the difference.
> There are no plans to move the NATS server to Zig.
> Zig will become a Tier 1 NATS client, and Synadia will utilize Zig in resource constrained environments to bridge OT/IT for manufacturing, IIOT, connected cars, robotics and embodied AI.
i understand zig as a better C, but in what world is another memory unsafe language a good idea?
i mean i kinda get if the thing you are writing would require LOTS of unsafe, then zig provides better ergonomics
however most programs can definitely be written without unsafe and in that case i dont get why wed do this to ourselves in 2025
why not take advantage of memory safe, and data race safety?
Conceptually C and C++ are also in that potential solution space, but I'm sure they feel that Zig's properties are superior for what they want.