←back to thread

Zlib-rs is faster than C

(trifectatech.org)
341 points dochtman | 2 comments | | HN request time: 0.404s | source
Show context
johnisgood ◴[] No.43381735[source]
"faster than C" almost always boils down to different designs, implementations, algorithms, etc.

Perhaps it is faster than already-existing implementations, sure, but not "faster than C", and it is odd to make such claims.

replies(10): >>43381810 #>>43381813 #>>43381820 #>>43381959 #>>43382108 #>>43382124 #>>43382267 #>>43385171 #>>43386202 #>>43392542 #
tdiff ◴[] No.43381959[source]
Nevertheless Russinovich actually says something in the lines of "simple rewriting in rust made some our code 5-15% faster (without deliberate optimizations)": https://www.youtube.com/watch?v=1VgptLwP588&t=351s
replies(2): >>43382117 #>>43386236 #
pinkmuffinere ◴[] No.43382117[source]
I’m sure I’m missing context, and presumably there are other benefits, but 5-15% improvement is such a small step to justify rewriting codebases.

I also wonder how much of an improvement you’d get by just asking for a “simple rewrite” in the existing language. I suspect there are often performance improvements to be had with simple changes in the existing language

replies(5): >>43382207 #>>43382269 #>>43382320 #>>43383954 #>>43385793 #
turtletontine ◴[] No.43382269[source]
Far better justification for a rewrite like this is if it eases maintenance, or simplifies building/testing/distribution. Taking an experienced and committed team of C developers with a mature code base, and retraining them to rewrite their project in Rust for its own sake is pretty absurd. But if you have a team that’s more comfortable in Rust, then doing so could make a lot of sense - and, yes, make it easier to ensure the product is secure and memory-safe.
replies(2): >>43382335 #>>43386853 #
maccard ◴[] No.43386853[source]
Disagree - a rewrite for “maintainability” is an engineer saying they want to rewrite in their preferred language. I wouldn’t allow someone on my team to rewrite a core dependency for “maintainability”, but I absolutely would if they suggested it would be faster and safer.
replies(1): >>43387543 #
ForTheKidz ◴[] No.43387543[source]
> a rewrite for “maintainability” is an engineer saying they want to rewrite in their preferred language

Not necessarily—sometimes languages are especially poorly suited for tasks or difficult to hire for.

replies(1): >>43388224 #
maccard ◴[] No.43388224[source]
We’re talking about a rust rewrite of a fairly core level library. I don’t think C is inherently unsuitable or difficult to hire for. If the library was in Fortran then maybe.

But yes you are technically correct, congratulations.

replies(1): >>43390693 #
1. ForTheKidz ◴[] No.43390693[source]
I was responding to a general claim. In any case, I certainly disagree that C is suitable in 2025 for the vast majority of possible use-cases. For fun? Sure, but not for shipping code you want to rely on.

Obviously the code isn't going anywhere, and obviously we DO have reliable code we've built with C. But acting like C and Rust deliver equivalent value is simply farcical: you choose C for rapid development and cheap devs (or some other niche concern, like using an obscure embedded arch), and you choose rust to solve the problems that C introduced.

replies(1): >>43391622 #
2. johnisgood ◴[] No.43391622[source]
Million dollar question: why Rust over <insert any memory safe language>? Common Lisp? OCaml, Ada / SPARK, etc. if not C?