[1] Sidenote - I find it really fascinating how Rust can also use the stronger static checks to prevent things like race conditions in a way few (/no?) other languages can.
[1] Sidenote - I find it really fascinating how Rust can also use the stronger static checks to prevent things like race conditions in a way few (/no?) other languages can.
A concrete example that I've run into recently when trying to write C++ code. I figured that, for safety reasons, I needed to make my type be move-only. I then had to spend about two hours trying to figure out why the program was blowing up. The reason was that I was reusing the variable after moving from it, and the compiler never gave any warning (even on -Wall -Werror) telling me that what I was doing was wrong. In Rust, the same situation would be a compiler error.
The two hours seems on the high-end, if someone's able to e.g. use ASan and the program is crashing reproducibly.
So you either have a C++ shop where everyone is on board regarding security, with the caveat of third party dependencies, or no one cares and writes something along the lines of C with C++ compiler, without any kind of static analysis.
Relying on external tooling means it usually gets ignored if it is not enforced. After all C's first version of lint goes back to 1979.
Sadly JetBrains latest questionnaire results prove exactly that.
So having safety as integral part of the language semantics matters a lot. Defaults matter.
But it definitely can't be? There are plenty of open source projects (Chromium, Firefox) that develop and leverage state of the art static analysis tools and best practices. It's very clearly not enough, and the costs (built/ test time) are really significant.
Only with further increase in lawsuits and returned faulty software, like in other commercial areas, will companies start paying attention to QA budgets.
Static analyzers work better, but often have a terrible signal-to-noise ratio. I think Rust can on average prevent more errors than all of those things out of the box, which is impressive.
The downside is obviously the increased complexity, and that it sometimes feels one is forced to work around the limitations of the "static analysis tool". Which likely comes from the fact that the borrow checker is some kind of analysis tool, where the annotations are directly included into the language.
Regarding with Rust having a kind of analysis tool directly built into the language, fully agree, that is what is so nice about safer systems languages, and what I liked in Algol/Wirth languages.
Since most new cars are Internet connected and have whole hosts of complex safety features dependent on software correctness, I sure do hope you are wrong about this.
They not only make writing software a lot more difficult and expensive, they also restrict the kind of software you can write.
Considering Rust shows can enforce so many things in the compiler, to me it's clear that a better compiler/language is a better way to address this problem than QA people.
Also the built in testing with cargo test makes TDD so much more attractive.
There was a funny discussion on the Rust subreddit, where even some language contributors have started having doubts about that complexity. One of them was trapped in his own programming language theory ivory tower, the other was trying to convince them that they are losing developers if they keep adding stuff to the language.
That discussion was a clear hint that the Rust developers don't have C and C++ programmers in mind when designing Rust. They have their own ideas about how a modern systems programming language should look like, and they're doing that. Perfectly fine, but we need to correct the misconception that C or C++ programmers will rush en masse to learn Rust.
Rust can prevent all data races but not all (any?) race conditions. Related question: can you use the type system to catch a subset of race conditions?
https://stackoverflow.com/questions/49023664/could-software-...
That being said, I think Rust macros are much worse compared to C++, if you ignore templates.
Don't get me wrong, I really like Rust. I just think that it's macros make for some of the most unreadable code I've ever seen.
I've written fancy macros for assembly language programming to support my own looping, iterating, argument passing etc. but I noticed that the other programmers on the team weren't interested in using them.
On the other hand, I'm so grateful to John Wiegley for his use-package macro for emacs lisp.
They always have the alternative of reading the expanded code, which is very similar to what the author of the macro could have written by hand instead of the macro.
Clean C++ 14/17 is less cluttered.