4 ms·
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
by com2kid 6y 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!)
- steveklabnik 6y agoI work on embedded code with no malloc, no threading. We still find Rust valuable. YMMV :)
- wjjvk 6y agoThis is so normal. You are one of the developers of rust. LoL
- steveklabnik 6y agoThe decision was made before I joined. I am also not the only developer.
- paragraft 6y agoRe units of measurement in Rust, have you looked at something like https://docs.rs/uom/0.31.1/uom/ https://docs.rs/uom/0.31.1/uom/ ?
- asalahli 6y agoHave 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 https://dlang.org/spec/betterc.html