|
|
Subscribe / Log in / New account

Herb Sutter on increasing safety in C++

Herb Sutter on increasing safety in C++

Posted Mar 12, 2024 20:00 UTC (Tue) by ebee_matteo (subscriber, #165284)
Parent article: Herb Sutter on increasing safety in C++

The problem that I see, is that new poorly-designed features keeps being added to C++ every iteration.

Look at the problems inherent in the C++ module system. The lack of proper packaging. No test framework integrated with the language. Clunky header+implementation file separation with inconsistent marking of attributes. UTF-8 strings without built-in UTF-8 support. It took 30 years to get imperfect timezone handling...

It's unfixable. It's far too complex. The only *good* thing would be *breaking backwards compatibility* and only say "use this subset".

It does its job for the person who can spend 10 years learning it. It sucks for somebody who wants to get their stuff done and go home.

Using C++ if you are a violinist like Paganini is great. Most people play it like a first year student.

So I think it has its place and it will stay. I myself have 18 years of C++ experience, of which more than 10 professional experience. And yet, if I can avoid it because I don't need to squeeze out the last 30 milliseconds performance, I will turn to something else (typically Rust).

It's good when you need those last 30 milliseconds. Terrible otherwise.


to post comments

Herb Sutter on increasing safety in C++

Posted Mar 14, 2024 10:23 UTC (Thu) by farnz (subscriber, #17727) [Link] (1 responses)

It's unfixable. It's far too complex. The only *good* thing would be *breaking backwards compatibility* and only say "use this subset".

It does its job for the person who can spend 10 years learning it. It sucks for somebody who wants to get their stuff done and go home.

Using C++ if you are a violinist like Paganini is great. Most people play it like a first year student.

With that context in mind, it's worth noting that the people trying to fix C++ are people who've spent at least 20 years mastering the language, if not more. These are the "violinists like Paganini" of the C++ world.

And it's not surprising, in this context, that they're trying to avoid a world in which C++ gradually fades the way COBOL has; it's not dead and buried like PL/I, but it's becoming less and less relevant over time. Worse, for C++ expertise, Rust is getting good at squeezing out as much performance as C++ can, if not more (because it doesn't have to care about compatibility with C++98 source code in the standard library), and there's a real risk that in the not too distant future, for every niche C++ currently sits in, Rust (with targeted use of unsafe) will be a better choice than C++ assuming you have no legacy code.

And while COBOL isn't a bad skill to have (there's well-paid jobs, for a start), just knowing COBOL and nothing else removes you from "exciting new" code, leaving you on "maintain legacy only", with other languages used for "exciting new" code. Pushing C++ into that bucket is not what people whose careers are built on using C++ for "exciting new" code want to see happen.

Herb Sutter on increasing safety in C++

Posted Mar 14, 2024 23:12 UTC (Thu) by khim (subscriber, #9252) [Link]

> there's a real risk that in the not too distant future, for every niche C++ currently sits in, Rust (with targeted use of unsafe) will be a better choice than C++ assuming you have no legacy code.

I think that's already the case: if you don't have legacy C++ codebase which you couldn't rewrite then using Rust is the best choice 10 times out of 10.

But if you do have such a codebase then this “subset of a superset” approach wouldn't work either!

> If they would have started talking about that 10 years ago (that's year 2014, before Rust hit 1.0 milestone, before it's stability declaration arrived and before it was tested by time) then chances are very high that Rust adoption would have been slowed down significantly and people would have patiently waited for promised “safety profiles” and everything.

Today… they are already developing schemes which would allow them to escape (things like crubit) and when promised “subset of a superset” would actually materialize one attempt or another would reach the usable state.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds