C is fun to me because the syntax is easy to understand and straight to the point.
You probably had never the pleasure to search for bugs caused by C Undefined Behaviour in multithreaded code.
When I was writing my diploma thesis, I was writing multi-threaded code for an embedded DSP system. Results were wrong all the time. I tracked it down to atan2() giving wrong results. I searched for about six weeks how to fix that and it disappeared when I changed the position of the program’s data segment.
The above debugging experience was 25 years ago. We have better languages now. Rust has no Undefined Behaviour. That means you can track any bug (except compiler bugs) deterministically down to where the actual logic of the code, and the model of it which was in your head depart. This is great.
Rust is fun because you can compile a complex program and it runs.
But industry is still working with a fifty year old language written for systems where 32 kilobytes were a lot of memory. At work, I am still searching for bugs in multi-threaded C code with manual memory management (the previous developer didn’t think this needs locks), and I have to explain to the CTO that no, wo won’t have a release this fall, while the company literally drowns in technical debt.
I searched for about six weeks how to fix that and it disappeared when I changed the position of the program’s data segment.
So it was a linker issue? I wouldn’t call that undefined behaviour in multithreaded code.
But industry is still working with a fifty year old language written for systems where 32 kilobytes were a lot of memory.
Especially for embedded and DSP stuff there are so many architectures that aren’t even supported by the Rust compiler. And on those systems 32 kiB of RAM is sometimes a lot of memory.
No, that would have resulted in a linker error, not random undefined behaviour
But industry is still working with a fifty year old language written for systems where 32 kilobytes were a lot of memory.
Especially for embedded and DSP stuff there are so many architectures that aren’t even supported by the Rust compiler. And on those systems 32 kiB of RAM is sometimes a lot of memory.
These niches still exist but they get rapidly smaller every year. Because:
Cheap hardware gets more powerful
Demands rise… even some electric toothbrushes are networked now
Rust support for embedded devices is rapidly expanding
Plus:
In some domains, security is becoming a real issue
You probably had never the pleasure to search for bugs caused by C Undefined Behaviour in multithreaded code.
When I was writing my diploma thesis, I was writing multi-threaded code for an embedded DSP system. Results were wrong all the time. I tracked it down to
atan2()giving wrong results. I searched for about six weeks how to fix that and it disappeared when I changed the position of the program’s data segment.(If the concept of Undefined Behaviour is new to you, I can recommend the web pages of Jens Regehr).
The above debugging experience was 25 years ago. We have better languages now. Rust has no Undefined Behaviour. That means you can track any bug (except compiler bugs) deterministically down to where the actual logic of the code, and the model of it which was in your head depart. This is great.
Rust is fun because you can compile a complex program and it runs.
But industry is still working with a fifty year old language written for systems where 32 kilobytes were a lot of memory. At work, I am still searching for bugs in multi-threaded C code with manual memory management (the previous developer didn’t think this needs locks), and I have to explain to the CTO that no, wo won’t have a release this fall, while the company literally drowns in technical debt.
That is simply not true. See here for a list of behavior that is considered undefined in Rust: https://doc.rust-lang.org/reference/behavior-considered-undefined.html
However, most (all?) of these require the use of
unsafe, which helps narrow down where the problem might be, if you trigger any of this behaviorOk fair point. I mainly code in C for making GBA games and random projects, so I haven’t done much multithreaded work
So it was a linker issue? I wouldn’t call that undefined behaviour in multithreaded code.
Especially for embedded and DSP stuff there are so many architectures that aren’t even supported by the Rust compiler. And on those systems 32 kiB of RAM is sometimes a lot of memory.
No, that would have resulted in a linker error, not random undefined behaviour
These niches still exist but they get rapidly smaller every year. Because:
Plus: