4 ms·
"which is just about everything useful". This statement is wildly without merit. Sure, for the typical user facing application HN readers talk about then C++ c
by alfalfasprout 8y ago
"which is just about everything useful". This statement is wildly without merit.
Sure, for the typical user facing application HN readers talk about then C++ can certainly contain vulnerabilities that are worrisome. Many performance critical applications can tolerate vulnerabilities in favor of latency.
It seems to me that the world of realtime systems including avionics, autonomous control software, trading, machine learning, and more is "not useful" as per your comment. The extreme low level control that C++ offers and powerful metaprogramming allows for performance that even Rust cannot hope to rival.
The industry has moved away from C++ for plenty of these user facing use cases. Codebases like Chrome and Firefox can't just be rewritten in Rust overnight. You can try and rewrite eg; SSL libraries but that has its own host of problems (eg; guaranteeing constant time operations).
I encourage the people parroting a move away from C++ to really think about what it is that should move and what the pros/cons are. I think you'll find that many of the things at risk (i.e user facing applications) are already on their way to being rewritten in Go/Rust.
- m_mueller 8y agoYou mention control software as an example. What makes C++ better there? My guess is compiler options for more hardware targets, but is it something else also? Is it really C++ and not C that is most prevalent on embedded systems?
- deleted 8y ago[deleted]
- fulafel 8y ago> The extreme low level control that C++ offers and powerful metaprogramming allows for performance that even Rust cannot hope to rival. Rust has vastly better metaprogramming, and as much low level control, no? And many low-level things are well-defined in Rust, and undefined behaviour or implementation-defined in C++.
- comex 8y agoDepends. Some metaprogramming features in C++ are currently ahead of Rust (values as generic parameters, generic associated types, constexpr, etc.), but Rust is ahead in other areas (procedural macros) and is working on parity in the other cases I mentioned. Meanwhile, Rust has none of C++'s legacy cruft, and its typed, trait-based generics are arguably a better foundation for metaprogramming than C++'s "dynamically typed at compile time" template system.
- PudgePacket 8y ago> The extreme low level control that C++ offers and powerful metaprogramming allows for performance that even Rust cannot hope to rival. Could you expand on this? It's a pretty strong claim. LLVM produces very fast code and is very commonly used for c++ compilation. Rust also has access to the usual low level control suspects, inline asm, manual memory layout & operations, pointer shenanigans etc. Benchmarks are never perfect but they show that rust in usually within the ballpark of c++, if not comparable: https://www.reddit.com/r/rust/comments/akluxx/rust_now_on_average_outperforms_c_in_the/ https://www.reddit.com/r/rust/comments/akluxx/rust_now_on_av....
- dodobirdlord 8y ago> The extreme low level control that C++ offers and powerful metaprogramming allows for performance that even Rust cannot hope to rival. I'm curious if perhaps you're using the word 'performance' here in a way I'm not familiar with, especially given the context of metaprogramming. As far as the usage of 'performance' that I'm familiar with, C++ and Rust come in at about even in benchmarksgame, which matches my experience. The optimization pass of Rust compilation is carried out by LLVM on LLVM IR, so it would be very surprising if it reliably underperformed compiled C++, especially given that the compiler has more freedom to optimize due to more extensive constraints on the language. https://benchmarksgame-team.pages.debian.net/benchmarksgame/faster/rust-gpp.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- rcxdude 8y ago> The extreme low level control that C++ offers and powerful metaprogramming allows for performance that even Rust cannot hope to rival. Rust is developed by mozilla because they needed a language they could write a faster browser in. The first rust component in mozilla was a CSS library they had attempted to parallalise twice in C++ (with some of the best C++ programmers) and failed. Rust treats 'can't be as fast as C' as a bug.