7 ms·
The C++ Killers (Not You, Rust)
- sylware 3y agorv64 assembly is the new C.
- bfrog 3y agoC++ itself seems to be working pretty hard year after year on this task of killing C++ with endless half baked features that fail to address real problems
- zabzonk 3y agothey do address real problems - specifically those of people trying to write very efficient libraries. if you are not in that group, simply don't use those features.
- UncleMeat 3y agoAnd yet they can't update the standard library types to not be slow as hell because of ABI concerns. If C++ was really all about speed then we'd have destructive move letting you pass unique_ptr in a register without compiler trickery. The fundamental number one constraint on new C++ behaviors is ABI compatibility. The rest is secondary.
- zabzonk 3y agothe c++ standard does not specify an ABI.
- UncleMeat 3y agoThe c++ standard absolutely cares deeply about abi compatibility. The committee can't even update intmax_t because it is an abi break. "Code compiled today and linked against code compiled years and years ago must behave correctly" is an absolutely premier design constraint when it comes to papers and it has prevented oodles of low hanging performance opportunities.
- zabzonk 3y agoquote from standard where it says that?
- UncleMeat 3y agoHow many papers do you want me to cite that were scuttled because of abi concerns? I've already named several.
- sophacles 3y agoThe standard doesn't say it, but from context clues I presume GP meant "the c++ standard [committee] cares..."[1] And they do care deeply - here's a post from a C++ committee member discussing the issue: https://cor3ntin.github.io/posts/abi/ https://cor3ntin.github.io/posts/abi/ [1] Evidenced by the rest of the post talking about the committee, and referring to people a couple messages up thread: > And yet they can't update the standard library types to not be slow as hell because of ABI concerns. etc.
- jcranmer 3y agoIt's not in the standard itself, because the standard doesn't directly talk about ABI. But there was a vote within the committee not to break ABI, as you can see in the Prague 2020 meeting here: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4855.pdf https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n48... (scroll down to page 11). And if you ever listen into any committee meetings or try to present papers, ABI breaks are very serious concerns that can torpedo proposals.
- Verdex 3y agoYeah. Something doesn't have to be enshrined into the standard to be a major driving point in the language. The very existence of Carbon is due to the c++ committee not wanting to break abi compatibility.
- pjmlp 3y agoNot only that many of the Carbon devs are former clang contributors, and one reason that clang is now on third place regarding ISO support, is that other devs had to step into what was previously contributed by Apple (now busy with Swift) and Google (busy with Carbon/Rust).
- Const-me 3y agoSadly, the C++ standard bodies are actually breaking old code in new versions of the language. For example, C++/11 introduced UTF8 string literals. Great feature which does what you’d expect – declare a string literal in source code, get a const pointer to null-terminated array of utf-8 bytes. Then a decade later, in C++/20 they refactored these UTF8 literals to evaluate into const pointers to the new incompatible data type, char8_t. It’s so bad that compiler developers had to implement switches to disable the new BS. Unfortunately, these switches are incompatible across compilers, -fno-char8_t in gcc, /Zc:char8_t- in msvc.
- pjmlp 3y agoThey address the problems of people that care enough to show at WG21 meetings, endure the multiple rewrites of their papers, and gather as many votes as they can. As simple as that. Many of the modern features aren't even exposed to the comunity as preview features before being voted into the standard.
- ilovefood 3y agoBeautiful and well written article. Unfortunately I made a small mistake in the second quizz :P
- felipellrocha 3y ago> The matter is, none of the languages, especially the so-called “C++ killers” give any real advantage over C++ in the modern world. To you. There are pleeenty of people who want to write performant code in a safe manner.
- WkndTriathlete 3y agoTo anyone. Take C++ vs. Rust, for instance. If I look at this from a business perspective: - Rust compiler can likely help confirm reference correctness, so this is a plus. - Rust language exchanges the cognitive load of memory allocation for tracking reference ownership, so this is a neutral. (In C++ anything that has access to the pointer can technically "own" it so there is no need to track function call traces for ownership, but lifetimes do need to be analyzed against the semantics of the program. Potato, po-tah-to.) - The pool of Rust developers available to work on a project is much smaller. If I'm writing software where memory safety is of high importance and I can afford to take the risk with a smaller developer pool, Rust makes sense. If I'm writing a game? It's going to make far more business sense to hire a bunch of C++ developers that can work with Unreal or C# developers to work with Unity or Python developers to work with Godot or whatever. And for real mission-critical software memory allocation isn't used so in those cases Rust has zero advantages. (Real mission-critical software lays out a static memory map up front to avoid exactly the problems Rust is trying to avoid but to also ensure real-time & predictable response times.) So we're left with niche software like OpenSSL or similar that can benefit from Rust. But it's more likely that we want a language that supports proofs of correctness (think Coq or seL4) in those cases and Rust can't even support that. So why choose Rust at all?
- pipeline_peak 3y ago> None of these questions have a definite answer without context. This is a pretty annoying thing to do considering someone took the time to read through all this. Also not original, I’ve seen posts in here like this 3 times already
- arcticbull 3y ago> But why can’t I just quit then? What’s the matter? The matter is, none of the languages, especially the so-called “C++ killers” give any real advantage over C++ in the modern world. All those new languages are mostly focused on holding a programmer on a leash for their own good. This, very specifically, is the advantage these languages have over C++. The benefit isn't the universe of things you can do (they're all Turing complete, you can do anything) - it's what the language stops you from doing. This is the thing the C++ committee never understood or at the very least never appreciated.
- zabzonk 3y agowhy do you think the designers of those new languages know what is good for you?
- kstrauser 3y agoBecause they tell me to stop managing memory by hand, as we have mountains of experiment proof that no one[0] is good at it. [0] I meant what I said.
- zabzonk 3y agoum, modern c++ has for at least the past 10 years advised people not to manually manage memory.
- dekken_ 3y agonot really, RAII/shared_ptrs is still manual memory management, just less footguns
- zabzonk 3y agowell, i would not recommend shared_ptr except under rare circumstances, but i don't see what can be wrong with RAII. in fact, it is the languages thar don't have RAII that have the problems, IMHO.
- wslh 3y agoGreat article more about different approaches to building software that languages themselves. My two cents: it is improbable that C++ will be ever replaced because it is a mastodon as a programming language: super complex, where complex includes complexity as difficulties and also its vastness. This doesn't mean that it will increase its usage since it is common nowadays to use specific programming languages (e.g. Python) for specific purposes and rely on C++ and others for very specific areas. Personally, I really liked SWIG [1] as a wrapper and interface generator. Don't know how much it is used today. Other experience but similar conclusion than the article.
- logtempo 3y agoIs a language can be too big to fall? That's an interesting question tbh.
- wslh 3y agoGood question. My personal take is that C++ makes many developers happy, comfortable, and you can develop in C++ using different approaches, that is enough. There is no programming language for all and I think this is why we have a lot of them now and even DSLs. I consider myself far from what is considered professional C++ knowledge, but for cryptography I always relied on Crypto++ [1] and that made me decide for the use of C++, at least partially. I think we can apply the same thinking for JavaScript or TypeScript, personally I don't like too much those programming languages but if I need to write a RESTful backend I go that route because they have good modules for that or sometimes I decide for Python. [1] https://www.cryptopp.com/ https://www.cryptopp.com/
- Shawnj2 3y agoC++ is kind of a “language of last resort” type thing where you use it if there isn’t another good option for what you want to do. Eg. Most desktop development was done in C++, but now C# and newer languages have killed off C++ for most desktop apps. So C++ is still widely used in embedded/performance critical use cases, but Rust will replace a lot of it over the long term.
- deterministic 3y ago
- hakdbha 3y ago[dead]
- pornel 3y agoLooks like the author is very focused on maximally optimizing some very compute-heavy signal-processing code, and doesn’t care much what is used outside of the compute kernel. So it may be very true that for their work it’s all the same whether they use C++, or Python with numeric libraries, or some niche DSL, or a macroassembler. But use of C++ is much broader than pure compute, so this perspective does not generalize to C++ or Rust as a whole.
- pjmlp 3y agoBut that is the thing, actually. Little by little, domains where either C or C++ would be the option to go during the 1990's, with exception of areas where VB and Object Pascal (Mac/PC variants) were enjoying adoption, have been slowly taken away from them. Bjarne created C with Classes for his distributed systems research at Bell Labs, nowadays the majority of CNCF project landscape is written into something else. C++ GUI frameworks were all over the place during the 1990's, nowadays one has to go to third parties, as platform vendors rather focus on managed languages. Even C++/WinRT going into maintenaince is an acknowledgemnt from Microsoft that outside Redmond XAML / C++ was a failure in regards to adoption. Long term we might be left with LLVM, GCC, Unreal, Skia, CUDA, and a couple of other key projects that keep C++ relevant and that is about it.
- lamontcg 3y agoYeah if you define the utility of C++ so narrowly to these very highly micro-optimized use cases then Rust can easily capture 100x the mind share of C++ because programmers generally just don't need to care that much. And really seeing what advanced Rust programmers can do when armed with godbolt I'm not convinced even those use cases demand using C++.
- bun_terminator 3y ago> Do you know that in MSVC uint16_t(50000) + uin16_t(50000) == -1794967296? Not only is that insane code and both my compiler and static analysis go for my throat, it's also not true. I think the argument is supposed to be about unsigned integer overflow, but the numbers don't add up. The big negative number wraps to 63744. And the sum (100K) wraps to 34464.
- dzaima 3y agoIt seems the intent was for "*" to be used instead of "+". At which point it's actually undefined behavior even though the operands are unsigned!
- bun_terminator 3y agothat makes more sense!
- lookitsnicholas 3y agomay be slightly off-topic, but that website favicon is suspiciously reminiscent of the logo that Ableton currently use hahah
- omoikane 3y ago> Do you know that in MSVC uint16_t(50000) + uin16_t(50000) == -1794967296? There are two typos in this statement, one is "uin16_t" should have been "uint16_t", the other is that the "+" should have been "*". Searching for 1794967296 yields this answer: https://stackoverflow.com/questions/18161443/type-casting-when-exceeding-the-limit/18161450#18161450 https://stackoverflow.com/questions/18161443/type-casting-wh...
- tomcam 3y ago> I made a simple Lisp-style interpreter to help game designers automate resource loading, and went on a vacation. When I was back, they were writing the whole game scenes in this interpreter so we had to support it for a while. I very much want to hear that story
- mgaunard 3y agoOf course I know that uint16_t+uint16_t gives an int. If you're gonna be programming in C or C++, you need to know these things. And yes, I do agree the fact that I know so much minutiae about those languages is part of the reason why I'm reluctant to go for something else I have a more shallow knowledge of. But that level of attention to detail is also what allows me to deliver high-quality code that does exactly what I intend it to do.
- lifthrasiir 3y ago> If you're gonna be programming in C or C++, you need to know these things. You have to, not you need to. Of course I know plenty of them (so much that I have won IOCCC a decade ago), but most of them are just pure hindrances and do not contribute to anything positive.
- _xivi 3y agoRelated discussion: The C++ Killers (Not You, Rust) - Feb 2023 (59 comments) : https://news.ycombinator.com/item?id=34792932 https://news.ycombinator.com/item?id=34792932 It seems author has published the article last year but moved it to his blog now
- npongratz 3y ago> Just as Latin never actually died, just like COBOL, Algol 68, and Ada, – C++ is doomed to eternal half-existence between life and death. I'm almost afraid to ask, but I'd love to know: are there any Algol 68 projects in active use? Anyone have war stories of maintaining them (bug fixes, new features, improvements to interface with more modern systems) in the last couple decades?
- zabzonk 3y agocertainly not active, but back in the 1980s i got dumped on a program that used algol, bcpl, fortran and cobol to drive a phototypesetter to do ... something. this took advantage of the fact that the dec10 allowed you to mix & match languages, much like the vax. i suppose i was lucky the idiot that originally wrote it didn't throw lisp into the pot. anyway, as i was hired as a microcomputer specialist, and as two dec10 systems programmers had ducked it, i simply said "no can do" - a valuable lesson. this is what i like about HN - recalling things i had completely forgotten!
- jamesfinlayson 3y agoA company I used to work had an Algol system running until 2005. A rewrite had begun in the 1990s and went live in 2001 and the two systems were run side by side until to make sure the new system was correct.
- JohnL4 3y agoPossibly. It was basically the native language of Unisys A-series mainframes and I guess those are still around in some form or other.
- jamesfinlayson 3y agoAh makes sense - I believe the Algol system I mentioned in another comment was running on a Unisys mainframe.
- mgaunard 3y agoThe sine polynomial is bad because it's not written in a way that removes redundant multiplications. Those redundant multiplications cannot be removed without fast math because floating-point operations are not associative. There are well-known optimal ways to evaluate a polynomial, namely Horner's and Estrin's schemes.
- marmaduke 3y agoNumba is great but missing explicit simd, stack allocated arrays, and user defined types, to name a few things. I tried to keep my colleagues in Jax these days.
- aoanla 3y agoIt's also a weird thing to bring up (Numba being great because it can jit-compile python to any arch, including GPUs) when the author discounted Julia... which has exactly the same property.
- shadowgovt 3y agoThe difference is uptake. Julia's good and it's out there, but relative to the users of Python... How many people care how portable the Julia code they aren't writing is? The existence of a tool to jit-compile Python is more useful to a lot more engineers than the existence of another language that is nicely jit-compileable.
- aoanla 3y agoRight, except the author also mentions two obscure languages with very little uptake at all, so it can't simply be a popularity thing - they're not useful at all, by that limited metric.
- xiaodai 3y agoNicely written. I learned a lot
- UncleOxidant 3y agoTIL about Spiral[1] and ForwardCom[2] which both look intersting. [1] https://www.spiral.net/ https://www.spiral.net/ [2] https://www.forwardcom.info/ https://www.forwardcom.info/
- malkia 3y agoTalking about other languages... My fav Go feature is the memory ballast - it's real, lots of go programs have command-line to set it up, and no one cares about it anymore https://blog.twitch.tv/en/2019/04/10/go-memory-ballast-how-i-learnt-to-stop-worrying-and-love-the-heap/ https://blog.twitch.tv/en/2019/04/10/go-memory-ballast-how-i...
- diimdeep 3y ago> user: todsacerdoti > created: January 17, 2020 > number of submissions 10798 Do you auto post from some aggregation script, mind disclosing why you do this, what sources do you use? https://www.alexmolas.com/2024/02/12/hn-index.html https://www.alexmolas.com/2024/02/12/hn-index.html
- logtempo 3y agoRemind me of this: https://www.nature.com/articles/s41586-022-05172-4 https://www.nature.com/articles/s41586-022-05172-4 > Improving the efficiency of algorithms for fundamental computations can have a widespread impact, as it can affect the overall speed of a large amount of computations. Matrix multiplication is one such primitive task, occurring in many systems—from neural networks to scientific computing routines. [...] We further showcase the flexibility of AlphaTensor through different use-cases: algorithms with state-of-the-art complexity for structured matrix multiplication and improved practical efficiency by optimizing matrix multiplication for runtime on specific hardware. Our results highlight AlphaTensor’s ability to accelerate the process of algorithmic discovery on a range of problems, and to optimize for different criteria. And I'll emphasis this sentence, as it seems to be the main goal/critics of the author in this post: > improved practical efficiency by optimizing matrix multiplication for runtime on specific hardware.