Hacker News new | ask | show | jobs
by gnull 1264 days ago
If C/C++ works for you so well, good for you :) Maybe you don't need Rust.
1 comments

Fair comment.

The one thing I never understood is why Rust was created instead of a stricter C++ compiler/standard? In some jobs I have worked some of this stuff has been enforced by purposefully making the compile crash if you try to do some black magic - I'm sure it could be done more elegantly.

I think this would have been the easiest way to get C/C++ people onboard if 99% of their code just worked as is.

Making things safe by default requires throwing away backwards compatibility. The C++ standards committee is (reasonably!) not interested in throwing away backwards compatibility.
I understand that, I just don't understand why another committee didn't get created to implement a stricter subset of standards. Kernels, micros, automotive, aeronautic, and many more, all have very strict requirements for safely running code.

I quite liked the (C#?) method where you have to strictly mark code as "unsafe" in order to use some features. I remember reading some code where in the comments there was a brief discussion about why it exists and alternatives explored.

Some of my old code even had to be robust against bit flipping (extremely safety critical). We had many code paths that could only be entered if bits were flipped in the execution triggering a reset, but also we had methods for ensuring the data memory was not tampered. I/O operations were purposefully difficult to initiate so that even if the entire execution memory was corrupted, there was an insanely low probability it would start I/O without triggering a reset.