Hacker News new | ask | show | jobs
by com2kid 1916 days ago
It is amusing to me because last time I was using C, the problems rust solves weren't the problems I had in C.

Deeply embedded code doesn't use malloc, doesn't use threading.

I could use a better type system, ala Ada, being able to say "this variable is of type distance in meters, this variable is of type time in milliseconds", that'd have cut the # of bugs by a huge amount.

But simple, unsexy, type system changes like that aren't what language designers are focused on.

Who here has never confused Milliseconds and Seconds when passing a variable around? Trivial for a compiler to catch with a half decent type system, but few modern languages bother to try.

Even when writing modern code in newer languages, I rarely directly use threads, and if I need to pass data between them 95% of the time I can get away just doing a deep copy to avoid the hassles of sharing data between threads!

Obviously Rust is meant solving different problems than the ones I face, I have friends who frequently write highly threaded code, but in my day to day, Rust doesn't offer much more safety.

(However, Zig does look super cool and interesting!)

3 comments

Have you looked into the subset of D called "Better C"? I recently stumbled upon it and have been wanting to try it out. It seems to solve the exact same problem you're describing, though I don't know how good of a job it does at that.

https://dlang.org/spec/betterc.html

I work on embedded code with no malloc, no threading. We still find Rust valuable. YMMV :)
This is so normal. You are one of the developers of rust. LoL
The decision was made before I joined. I am also not the only developer.
Re units of measurement in Rust, have you looked at something like https://docs.rs/uom/0.31.1/uom/ ?