C++23 “Pandemic Edition” is complete
herbsutter.com
herbsutter.com
how / why is that a frustration
Given work on Circle (, Carbon, etc.) -- a "radically opinionated" Edition of C++ as a fork in the standard seems required (where Edition = Fork).
Incrementalism towards a "more polished" C++ won't be enough; not least due to branding.
Compiler Explorer lists it under Cpp2-cppfront. [3]
[1] https://herbsutter.com/2022/12/31/cpp2-and-cppfront-year-end...
There's a lot of "@nogc" D code out there. Audio FX plugins that do realtime DSP and game/graphics stuff come to mind.
I'd rather have the language give me a choice because it's very convenient to have. You'd be surprised how performant even GC'ed code in D's can be.
Not if you wish to use the standard library though right ?
All functions in the stdlib that are nogc are marked "nogc" in their definition
Now C++, Java and C# have many capabilities where D had an upper had back when Andrei's book came out, and naturally new competition also came into play with better corporate support.
If you make extensions for R/Tcl/Lisps for computations, plotting, abstract mathematics,
why the Garbage collection is bad?
You have native performance!
The only complaint is that D might think of adding some of the ergonomics of ML-family of languages. But it has its opinion (like Lisps) and I respect that.
Ergonomics and possibly safety could be goals.
I think it was a bit of a misnomer b/c it sounded like some glorified style guide. But it was actually a set of tools and helpers/wrappers that effectively made it impossible to write a lot of unsafe pre-modern C++.
For whatever reason it's never really caught on, though it looks like it's still being worked on: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines
In principle it seems to kinda strikes the right balance where the language is narrowed - it's still all valid C++ (not an entirely new thing), but not all C++ is valid under the Core Guidelines
I'll be honest - I never tried it myself so I don't know it's deficiencies. Maybe someone who's given it a good try could weight in
There's only a few things I'm not a fan of, mostly around mutable out parameters (I prefer pointers not refs to make it clear at the call site it's a potential mutation)
That's my experience as well. Clang-tidy, clang-format, cppcheck and Core Guidelines. I don't recall the last project I've worked that didn't used that combo.
I don't believe this is true at all. I don't recall working on a single C++ for the last half dozen years which hasn't adopted the Core Guidelines up to the code review level.
Of course it's a blend of survivorship bias to claim that no project uses the Core Guidelines if you personally fail to consider it to start with.
Seems like something I would be interested in; I've increasingly felt overwhelmed by the endlessly growing scope of C++, and the challenge of understanding which parts are and are not "Modern C++".
I think the problem is a "safe C++" might look a lot like C++ but will have enough fundamental differences to be like a new language from a practical standpoint... devs will have to learn and use new patterns, new tools. Old code will need to be ported and possibly significantly rewritten, since we're talking about memory and threads. At that point, you might find using one of these other safe languages a better option.
C++ already crossed that threshold many years ago. Today's C++ is essentially a different language from C++ of yore. But it maintains compatibility with the old C++.
This is, I think, the central flaw in modern C++. Because of trying to keep that compatibility, so many newer features are bags-on-the-side and the language is bordering on unmanageable.
I think it would have been better to have branched off from C++, given it a new name, and waved goodbye to code compatibility. It would have been a better language for it.
And given that, if we have people working on Rust, Circle, Carbon etc, what would your idea actually change?
I guess most reasons are 'use what we know well', and 'use what we have tooling for'. But there's probably some others.
competitors will compete
For example:
- I think they bungled the Unicode transition by being too dogmatic and it took them a few point releases to include some quality of life improvements for migration that really allowed legacy libraries to transition
- the GIL dependency didn't go away
- typing was added later
Python 3 would have been a huge jump with those changes. Instead, Python 3.0 was very interesting but a major annoyance for limited benefits to 99% of Python app devs.
There's some serious work going on with the GIL these days. And also about immutability and reducing reference counting.
> [...] it took them a few point releases to include some quality of life improvements for migration that really allowed legacy libraries to transition
I wouldn't hold that against the transition too much. No one gets everything right from the start.
About typing: owing to Python's culture, I don't think mainstream Python will be statically typed by default (or even obligatorily) anytime soon.
As an opinionated js, definitely. Probably also incremental, in a way.
Browser frontends (in general) set not such demands (size, memory, speed guarantees) and its bloat more often comes from things outside of code (images, videos, trackers), so there's freedom to use whatever floats ones boat.
Combined with the ever increasing demands on app complexity, frameworks and born left and right. The strong movement into functional programming in this area has also led the way for other languages (SMLs, Lisps) that better fit that model.
Bjarne Stroustrup’s previous article which basically tried to minimize memory safety because it was a subset of program safety shows that Standard C++ really doesn’t have a great answer.
I feel C++ needs to do the following to be able to survive:
1. Adopt language epochs so that the language syntax and semantics can be evolved without having to fight backwards compatibility. For example, the integer promotion rules are very confusing and a source of bugs.
2. Adopt solid dangling reference analysis into the compiler itself (using language epochs above). Static analysis as an external tool or command line flag is not good enough.
With Rust, C++ now has a free, popular competitor language that is also focused on creating zero overhead abstractions, but that can guarantee memory safety and which also doesn’t have a bunch of language warts. If C++ doesn’t come up with a good story real soon to deal with memory safety at the language level and deal with the mess of language complexity, it will be relegated to a legacy language.
If you don't mind, what do you think are the main reasons for that?
* It's too different. This is to be expected because it was never designed to be like C++. For example, if I have an OOP-heavy application, moving it over to Rust is not a matter of fixing up a few ideas here and there like it might be with, say, Java or C#. It calls for a redesign/rewrite. I don't think a memory safe C++ successor would need to be more like Rust than like C++.
* The language is not substantially simpler than C++. I find traits to be particularly difficult to reason about and to follow, to the point that I find myself just trying to find the right incantation that will appease the compiler. And that complexity shows up at build time just like it does with C++.
You seem to know quite a bit. What drives this opinion?
absolutely. unfortunately, saftey oriented proposals tend to focus on a weaker warning-esque approach ([[nodiscard]], contracts, etc.), which, in my opinion, will ultimately only make things worse. i'll stay away from my type-systems-are-great soapbox :)
the refusal to break ABI, remove non-destructive moves, the strengthening of concepts more akin to their original proposal, are not even on the horizon of discussion, despite us having exemplars of all 3.
it's perplexing, to say the least.
I guess the issue has always been that no one can agree on particular language subsets?
However, one could view projects such as Google's Carbon as precisely that. A restricted safer subset of C++ with a more succinct syntax.
That's what Javascript got surprisingly right IMO: you can target the latest bleeding edge features, and still be able to compile and run them on 20-year-old browsers through code re-writing (aka transpilation) and polyfills [1]
I often wish this was available for other languages, too.
[1] Well, not all features because some if them are notoriously hard to polyfill (IIRC Proxies are one such unpolyfillable feature). And there's the huge issue of the entire world relying on just one guy: https://github.com/zloirock/core-js/blob/master/docs/2023-02...
The problem with C++ is the other way: you can't compile 10 year old code because the language has "evolved".
If you choose to write new code in the same way as you did in pre-11 C++, though, people might have a lot of questions for you.
These pointer-based data structures are used a lot when you are manipulating large structs in C and C++, as they let you "move" then between data structures without copying a ton of memory.
Joking aside, some stuff are currently really hard in Rust, but the rate of change slowed down, and all I can see now is everyday ergonomic improvements, so there is hope for (slightly) simpler syntax in the future.
And if you really need a linked-list type structure, and are competent to make it and use it properly/safely, unsafe {} is waiting for you.
Specifically, linked lists do well when objects are: 1. Large, specifically 100s of bytes 2. Moved frequently between collections 3. Intrusively linked (meaning that the pointers are part of the struct, not a separate library) and 4. Never randomly accessed
One size does not fit all when it comes to performance of list structures, unfortunately. In particular, large items tend to break standard library structures, since they are not the usual case.
I'm personally not entirely sold on Rust's memory safety model, though I did learn to work with it when I was getting paid to work in it.
The problem with c++ was never writing simple data structures, but was writing complete programs without a single mistake in the informal contracts between functions. Static analysis tools and other crutches help but having a stricter ruleset to enforce is what makes rust a winner.
https://isocpp.org/std/meetings-and-participation
As far as epochs go, you’re not the only one:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p18...
C++ still has lot of momentum for the upcoming decades, regardless how much we would like to RIIR everything.
Also AUTOSTAR/MISRA are funny to bring up because they are desparate and only semi-successful attempts to bring a semblance of safety to fundamentally unsafe languages. You get all of the safety of them (and more) in Rust with the 2 rules of 1. don't use unsafe. 2. have tests.
Apparently AUTOSAR and MISRA are relevant enough for Rust, that efforts are being made to allow a Rust certification subset as well.
That's exactly the purpose of WG21 SG23, convened for the study of safety and security for C++26 and beyond. You can complain or you can join and influence the future.
Rust is so oldtimer. C++ is at version 24 and counting.
C++ the language is not at all a problem as much as C++ the tooling and developer ergonomics. For a language that has been in existence for 4 decades, you would think the ergonomics would be better but it seems all the graybeards want us all to suffer the way they did.
I just use vcpkg and NuGet, done.
The problem with clang is called Apple and Google, as they decided to focus on their own languages (Swift, Objective-C, Carbon, C++17 being good enough), the compiler vendors that profit from clang forks haven't cared that much to contribute to upstream.
Meanwhile VC++ and GCC are quite green on C++20 compliance, and GCC modules are almost there as well.
These days I still use macOS and exist in the Apple ecosystem. I wouldn't mind moving to Linux, but unfortunately I need a MacBook to do work where I build iOS apps. I wonder if there is a way around that.
You're pretty much stuck with clang, unless you feel like hacking around the toolchain workflows.
So they were very inclusive and gave a warm welcome to their convicted rapist and child porn hoarder on the committee, over whom several other members resigned. They might have purged all women instead. I see one irl, and several others over Zoom.
https://www.change.org/p/ban-convicted-sex-offender-from-iso...
Now I feel it's either making-c++-memory-safe-while-breaking-back-compatibility or die slowly. I was told by c++ experts there is no middle ground.
I actually started to shift focus onward Rust. Rust also provides a more consistent build tooling albeit build time is still very slow. Plus Rust does cross-platform decently. For C++, I need create my CMake manually each time, and cross build also involves manual creation each time.
And not that long ago most people would agree that C++ is the language that is hardest to master.
Modern C++ is actually quite nice to code in. Its just a real pain to get started - project setup, documentation, cicd setup, ease of dependency/pkg management, cross-compilation, unit-tests, etc. Developer ergonomics are poor and not standardised. (There are also some critical features that are missing - like reflection that make things a pain)
Rust the language is far harder to learn (even if it is safer), but the tooling is mouth-wateringly superb.
In today's world, a language can live and die on developer ergonomics alone. Nobody really has the patience to do all the cruft-work that they could tolerate before - there is a lot of choice in the programming landscape.
editted: just checked out conan briefly, it's pretty close to cargo and go toolings, going to use it more
Could anyone expand on how this was broken?
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p27...
[0]https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_a...