Live data from Hacker News

Why Rust is worse than C for programming low-level hw

infosec.exchange

1–10 of 22 posts

Re: Why Rust is worse than C for programming low-level hw

#5

Such fameous hacker like Zalewski should better distinguish language and library interfaces design issues.

This was my first thought as well. Rust certainly lends itself to unnecessarily complicated API designs, but so does C: OpenSSL requires something like 5-6 layers of indirection to do basic things like converting a sequence of X.509 structures into a buffer of PEMs.

I've yet to discover a language that doesn't allow a sufficiently clever engineer paint themselves into a corner with API complexity. Even deliberately simple languages like Python suffer from this.

Re: Why Rust is worse than C for programming low-level hw

#6

Such fameous hacker like Zalewski should better distinguish language and library interfaces design issues.

Yeah, this is just trolling. There's nothing inherent to rust that requires ( or even recommends) writing code like this. There's nothing inherent to C that prevents bad API designs like this.

Nothing about this post is notable or interesting. It's low-effort rage bait.

Re: Why Rust is worse than C for programming low-level hw

#7
post #3

It it what happens when you try to make an universal API for any thinkable and unthinkable use-case.

Your mention of a "universal API" reminded me of the paper "Some Were Meant for C" [1] in which the author argues that one of the most important feature of C is its "communicative design", i.e., its ability to manipulate any memory -- whether this memory originates from the program or is foreign -- with the usual C operators (+, *, [], >, etc.)

[1] https://www.humprog.org/~stephen//research/papers/kell17some...

Re: Why Rust is worse than C for programming low-level hw

#8
Yeah, not a big fan of the library ecosystem in embedded rust, but then again I've never been a big fan of the libraries I get off the shelf for the vast majority of embedded C. The rust libraries have the additional complication of trying to keep you from doing bad things with the registers, but then commonly don't expose enough for doing anything beyond example applications.

Either case it's way easier to just twiddle the bits yourself, and can be clearer is that code is tailor made to your use case.

FWIW, I still jump to Rust to begin with, just ignore most libraries.

Re: Why Rust is worse than C for programming low-level hw

#9
I don’t know if this one of the embedded Hal libs or not. But what they do is to move the state of GPIO etc into the type system. So the type system maps a state machine. In practice it’s impossible to flip a bit on a pin which is not in the right configuration etc. My understanding was that this is the hot stuff that rust offers to embedded programming. Compiletime error handling. But in reality it can look overly complicated. Again I don’t know if this is a direct example or some other library. I played around with one on my blue pill a couple of years back. And yes the c api brings you faster results.
Post reply on HN