Hacker News new | ask | show | jobs
by egorfine 10 days ago
What does %LANGUAGE% have anything to do with the goal? Totally same principles apply for any other lower level language: Zig, C.

While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling.

Update: like I said, Rust is awesome and has so many advantages over C it's not worth a discussion really. But again I see that many projects are choosing Rust not because of merits but simply because it's a fashion.

8 comments

> the only apparent reason to chose Rust over C is virtue signaling

If you'd said another memory safe language I might have been on board, but C? We've seen a complete collapse in the ability of software to go un-hacked and un-exploited. Not all of that is down to poor memory safety of course, but it's a category of vulnerability that is massively increased in both surface and risk by choosing to write C.

Choosing Rust alone might be virtue signalling, but choosing a memory safe language is just pragmatic.

In this particular topic (performance) Rust matters because it will deliver excellent performance. You could write a container -> map -> map -> container flow in fifty memory safe languages, but probably it would be a bit slower than the nasty hack you'd write in C to convert the data in place. Rust isn't, if you're intrigued you will discover that Rust 1) figured out that the two containers must be the same size in memory so it can re-use the original container and 2) did the in-place conversion even though that wasn't what you wrote, because it's faster.

So magically the Rust was just as fast, but much more readable and when a junior (or an LLM) modifies it slightly so that the output container is bigger it won't suddenly segfault due to that scary in-place conversion loop now being a bounds miss, the Rust won't attempt the in-place conversion now that it can't work.

In the age of machine-generated code, why not ask LLMs to write "safe C"?
You've received downvotes, but I'll do you the kindness to actually answer you.

Firstly the obvious, LLMs aren't perfect yet, they still make mistakes.

But even if they could achieve safe C by asking them to "Write Safe C, Make no mistakes", there would still be a significant benefit to achieving safety by using Rust or a memory safe language.

LLMs work best when they have a combination of clear objective functions and guardrails. In this case, the compiler acts as a guardrail to keep it safe while trying to solve the problem that needs solving.

Having a compiler step prevents the LLM taking a "shortcut". Despite models improving, they will still take shortcuts, sometimes absurd ones, to meet some definition of a "job done".

The other massive benefit is cost and speed. Having an LLM analyze and reason about the safety is expensive and wasteful. Having this done at compile time is cheaper and quicker. The earlier in the feedback loop, the cheaper it will be.

Save your tokens for "real" work, not stuff you can check at compile time.

That's a pile of bollocks.

Rust protects you from a whole class of bugs (borrow checker) and lets you enforce almost as many invariants as you chose, through the type system.

LLM are just as bad as humans at enforcing/tracking ownership and invariants.

We maintain two code bases; one is TS and the other Rust.

Both are by now written foremost by agents (since August 2025, I'd say).

We had numerous non-(business)-logic bugs in the TS code base over this period.

Zero such bugs in Rust. Because the compiler catches them for us. All bugs we had in that code where actual logic bugs. I.e. the spec already had the bug or contained an oversight.

Zero.

We have since started rewriting the TS code base in Rust and will likely switch over in the next three months.

> a lot of times the only apparent reason to chose Rust over C is virtue signaling.

Quite the opposite. Outside of a couple of very specific kind of cases (for example working with microcontrollers not supported by Rust toolchain), there is no good reason to choose C when you could choose Rust.

Choosing C over Rust means throwing away the memory safety features that Rust gives you for free. And for what? There is just no upside to choosing C in the vast, vast majority of cases.

Today I added Rust checked arithmetic which detects and protects math bugs such as integer addition overflow and division by zero.

Rust checked arithmetic is built into Rust's standard library (std) via explicit methods on primitive integer types (such as checked_add, checked_sub, checked_mul, and checked_div), which return Option<T> and evaluate to None on overflow. There's a known tradeoff of some speed, which is fine for my purposes because I need reliability more than raw speed.

I'm longtime C coder so I know how to do this in C. Rust strong types and static analysis make it so much easier to do correctly.

This is in the C23 standard library as well, just without nice sum types sadly.
It is very easy to add one yourself though.

https://uecker.codeberg.page/2026-10-24.html

> virtue signaling

Seems like just virtue to me. The guy who volunteers every week to pick up garbage from the beach isn't virtue signalling, he's just virtuous. The guy who came once, with a film crew and left once they'd got the shots they wanted - that is virtue signalling. They're both shown in the film, but only one of them actually does the signalled virtuous activity when the cameras aren't rolling.

You could argue that RIIR was conducted as virtue signalling if what we saw was one of those translations smeared in unexplained unsafe blocks, with rats nest logic that no human is going to untangle. But that doesn't seem to be the case here.

> While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling.

That seems like an extremely dubious claim.

Rust is just a lot more pleasant to work with in every possible way. C has the abstractive capabilities of a deaf-blind toddler.

I found that you can not build good abstractions in C is mostly a myth.
You can build okay abstractions and then to maintain them you have a pinky-promise system so it doesn’t matter. You basically can’t build any abstraction in C because you can’t make a guarantee about… well… anything. Anyone at any point can just break your abstraction. And they will. At 100 lines of code maybe you can see that they don’t, but most projects are bit larger than that.

Even very basic abstractions possible in basically every language, like say a type that holds JSON text, is not possible in C.

You can build types around structures and access them via wrappers. This works perfectly fine for many abstractions. Sure, one can break those abstractions, but not accidentally, and this is true also in other languages.

Update: In fact, you can also build quite reliable abstractions around incomplete structure types. Those abstractions are better than what C++ adds, where the abstractions in the header are all very fragile.

This is very unreliable overall and since the type system is so primitive, you’re limited on what you can enforce on the structure. You can easily break stuff accidentally.

For example: suppose you need a container to hold ints. But it also needs to be able to hold other types. In C++ this is trivial, as in virtually all modern languages. In C this is impossible.

You can have a generic memory backed storage + accessors. But if you rely on void pointer functions, you have to remember every time to cast and pinky promise to only store one type. It’s very, very easy to make a mistake, and you will.

Most abstractions that we take for granted in modern languages are straight up not possible in C, or at least they are extremely incomplete. Part of that is because you can’t get C to do anything automatically. Every function call must be manual.

You are switching topics to polymorphic types. But you can also implement them in C in a type safe way without void pointers.

Here is an example for a generic vector type: https://godbolt.org/z/7MdGqcdbq

Your mistake is believing that you need native syntax for such feature to be possible. But this is not true.

You can do anything you put your mind to, given that you're willing to ignore how brittle the result is and how easy it is to misuse.

For example, you cannot even write type-safe generic data structures in C. You just have to muck around with void pointers. You might reach for macros to make it "nicer" to use, or write "type-safe" functions that cast for you, but that's mostly a veneer.

That's actually why we chose Rust over C at my new company, Virtual Signaling as a service™. We rewrite anything in Rust for companies looking to virtue signal.
Rust's incredibly strict and detailed static analysis, while a huge headache for human developers, is really useful with LLMs.