4 ms·
It's the first time since I'm alive a language that is higher level than C/C++ can compete with C/C++ in the benchmarks. If you have experienc with large C++ c
by xiphias 9y ago
It's the first time since I'm alive a language that is higher level than C/C++ can compete with C/C++ in the benchmarks.
If you have experienc with large C++ code bases you probably know how impossible it is to write safe code. Also after you use only unique/linear types, single inharitance (which is advised when working with a big code base), you are writing something that's easier to express in Rust than in C/C++.
Inlined asm will stay of course, Rust doesn't try compete with it.
- blub 9y agoSafety is many shades of grey instead of being black and white and it is intertwined with the concept of risk. The fact that large C and C++ code bases exist and the products they drive are successful proves that it is possible to write code in those languages that offers a good enough risk/reward balance. This is what many Rust fans are missing: you want to sell 100% memory safety, but you're assuming that everyone wants 100% instead of 80 or 90% and that they're willing to pay the price of switching.
- steveklabnik 9y agoIf you want to work in a memory-unsafe superset, you can; that's what unsafe is.
- blub 9y agoIt looks like you didn't understand what I meant. Each company/project/person needs to make a decision: * I can work in C and C++, which I can get to X% safe using the techniques and tools A, B, C at the cost of M. OR * I can invest in learning Rust and integrating it with my environment to get to 100% at the cost of N. Is the difference from X% to 100% big enough to pay N instead of M? How big of an X do I need? Is it even possible for me to use A, B and C? This is how an informed decision would look like, but Rust proponents just keep repeating that X < 100.
- rcxdude 9y agoNot saying there's a cost-benefit analysis to be done, but there's a pretty nonlinear jump from under 100% to 100%, however. In my experience existing tooling for static analysis on C and C++ tends to be it can point out a lot of bugs, but it can't prove that there's are not bugs (of a particular class). This helps me catch things I miss, but it doesn't free me up from worrying about them (X% safe doesn't been I don't have to worry about X% of the code, which would be great, it means all of the code has a (1 - X%) chance of containing a safety bug, which is far less useful). This cost-benefit analysis also is substantially different between switching an existing codebase and starting a new one. The fact that Mozilla considers it worthwhile to switch an extremely large C++ codebase to Rust is worth noting.
- steveklabnik 9y agoYeah, we mean slightly different things. I agree with what you're saying, but what I'm saying is about the cost of N; if you find yourself fighting with Rust's rules, you can drop back to unsafe, and use the rules you already know. Well, similar ones anyway. This reduces the cost of N.
- blub 9y agoN however can only be decreased by improving Rusts UX. If one is able to write unsafe code in Rust, they already paid the full N.