2 ms·
If C++ was that good at that, what need for Rust would we have? Both C and C++ face the problem that memory management is hard. In different places because the
by shakna 10y ago
If C++ was that good at that, what need for Rust would we have?
Both C and C++ face the problem that memory management is hard. In different places because they use different approaches to the same problems.
Sometimes C is appropriate, sometimes C++, and sometimes Rust.
There is no reason these languages can't coexist peacefully, and no reason we can't all learn from each other.
- pjmlp 10y agoBecause while C++ offers the language features for writing good code, it doesn't prevent that many use it as "C with C++ compiler". Which is both a path to its successful adoption as better C replaced, but also a curse to language improvements. So we need languages that share the same spirit as C++ in programmer tooling, but don't allow copy-paste of C code. Also because Ada compilers were too expensive and most younger generations of developers never heard of it. Hence Rust, which while a good progress towards safety still needs to match C++'s IDEs, debugging tools and being available on OS vendors SDKs as first level language. I am looking forward to it, but it still isn't quite there.
- shakna 10y agoC too offers language features for writing good code, but is also cursed by the power it gives the programmer. It's fantastic flow controls allowed us to move beyond ASM and its convoluted jumps that can become difficult to reason about. C++ gave us abstraction models that made reasoning about state easier in many ways, but spoils us by allowing us to try and abstract everything, and still possesses unexpected dangers. Rust gives us abstraction over memory addresses, protecting us from ourselves, but still giving us some power, but sometimes getting in the way of the programmer. There is a place for all of these. I like that my RTC uses ASM, I like that my watch uses C, I like that my word processor uses C++, and I like that my web server uses Rust. No one must be superior to the other. They aren't successors to each other. I think we find ourselves here: [0], and I think you and I may have to agree to disagree, because none of these languages is perfect, and they all impact each other. [0] https://news.ycombinator.com/item?id=13173723 https://news.ycombinator.com/item?id=13173723
- pjmlp 10y agoI rather that neither C and eventually C++, are no where to be seen on that stack. Being almost the same age than C, and older than C++, means I know there were better ways of doing systems programming than any of them. Right now C++ is the lesser of both evil, until Rust, Swift, .NET Native, D, other safe language of the month, eventually takes over most of its use cases.
- duneroadrunner 10y agoBut that argument doesn't necessarily call for a new language, it only calls for the prohibition of the unsafe elements of the existing language. Intuitively one might assume that potentially unsafe elements (like pointers, references, parts of the standard library, etc.) are so ingrained in C++ that prohibiting them would cripple the language. But actually, C++'s preprocessor is powerful enough that instead of abandoning those potentially unsafe elements, you can instead replace them with safe compatible substitutes. SaferCPlusPlus[1] is a collection of such substitutes. And since the substitute elements are themselves pure C++, you can still use your existing IDEs, debugging tools and SDKs. And the migration of existing code can be done completely incrementally, and much of it won't need to be changed at all. [1] shameless plug: https://github.com/duneroadrunner/SaferCPlusPlus https://github.com/duneroadrunner/SaferCPlusPlus
- pjmlp 10y agoIt doesn't work in the enterprise context where I am yet to see any code review taking place. The very few I happened to see weren't real ones, rather some meetings to tick a few check boxes, usually faded away after the managers realize the amount of "wasted money" doing them.
- duneroadrunner 10y agoYou mean, that if there isn't some kind of (automated) enforcement, programmers will continue to "taint" code with unsafe elements? Yes, but just like one might anticipate the development of a good IDE/tool/libray/SDK ecosystem for Rust, you could imagine the development of a memory safety enforcement/verification tool for either SaferCPlusPlus or C++ in general. The C++ "Core Guidelines Lifetime Checker"[1] is intended to be such a tool for C++ in general. And such a tool for SaferCPlusPlus would be simple enough that, if it didn't want to wait for one, an enterprise could implement one itself. I mean, all it would have to do is identify any instances of potentially unsafe elements in the code. Right? Or are you suggesting that it would be "politically" unrealistic to impose a prohibition on unsafe C++ code in the enterprise context? So it would be more realistic to adopt a new language, like Rust, that doesn't have the baggage that C++ does? [1] https://blogs.msdn.microsoft.com/vcblog/2016/03/31/c-core-guidelines-checkers-preview-of-the-lifetime-safety-checker/ https://blogs.msdn.microsoft.com/vcblog/2016/03/31/c-core-gu...