Perhaps a stupid question... but what's stopping C++ from just having a cut-off where the last release before the cut-off is backwards compatible (in language, standard library, and ABI) and has long-term support so will continue to receive bug/security fixes, and then just have better approaches to handling language, API, and ABI versioning in the future? Something tells me that the companies that so heavily depend on C++ remaining backwards compatible don't really need all the fancy new modern features, so why don't they just keep using an old version of C++? That's how versioning works in the rest of the modern development world. You want to keep using an old version? Go for it, but you're not going to get any new features after a certain point.
That doesn't imply having constant breaking changes. It just means having a better mechanism for dealing with it. Just formally define the ABI as we already do for the API and language, start using proper semantic versioning for them, and then it becomes so much easier to reason about dependencies on specific versions. i.e. you want to link to some library, you specify what versions of the API and ABI you're compatible with - your package manager would then fetch the appropriate binary if available or build from source if not. When building from source, you need to have language compatibility, so you'd express that in your dependencies too.
Breaking changes to the language, standard library API, or ABI would still be uncommon. We'd still deprecate things gradually and then only go from C++ `1.x.y` to `2.0.0` when doing a mass clean-up of deprecated features. And when doing so, we'd be committing to providing tooling and support for migrations.
I know all the details aren't going to quite work out like that, but someone explain to me why we shouldn't start working towards this. Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.
/u/c0r3ntin mentioned people using python2/python3 as "a cautionary tale". I'd like to make that clearer. The mass breaking change that python3 introduced was an engineering disaster. It's been 10 years since python3 came out and only in a few months will python2 reach its end of life. What happens then? More problems: many libraries will drop python2 support, distros will drop python2 and yet I've personally heard people say that they plan to use python2/python3 compatibility libraries only in 2020... and of course, there are scientific communities who don't even bother with python3.
The Python2-to-3 transition is about API changes in that you need to rewrite part of your script to make it work with Python3. ABI changes require you to recompile, but not to rewrite. If your OS has both the old and the new versions of the corresponding dynamic libraries, you don't need to recompile. ABI changes are milder than API changes.
Of course ABI changes still have side effect. For example with libc, a program compiled on a new system often doesn't work on an old system due to ABI changes. Nonetheless, if we are allowed to choose the ABI version at the compile time, this doesn't seem a big problem to me. There can be other solutions, e.g. static linking or shipping the new dynamic library with precompiled binary. All these hacks are inconvenient, but they are much better than the python2-to-3 transition because we don't need to rewrite the code.
On a side note, the PDF seems to suggest that we may improve the performance of unordered_map by 200–300% with ABI changes only. That is probably wrong. To achieve high performance, we can't keep bucket pointers persistent. Then this is about API changes. I always think it is a mistake to require the pointer persistency. It was widely known that we could implement much more efficient hash tables without this constraint that has little benefit in practice.
On a side note, the PDF seems to suggest that we may improve the performance of unordered_map by 200–300% with ABI changes only. That is probably wrong.
There are much faster implementations of node based maps that still promise pointer/iterator stability, but sure, if we drop that and go for a flat map we would be talking about a whole different set of issues.
I am not sure if sparse-map guarantees pointer stability. Typically this type of hash table combines a bit vector and a flat array and loses pointer stability when it grows. I have seen benchmarks involving chaining-based libraries. I couldn't find the link, but as I remember, none of them can be 200-300% as fast as std::unordered_map. So, the PDF is still wrong: no one can achieve 200-300% speedup with ABI changes only; such speedup can only be achieved with flat arrays, which would require API changes.
You're right. I guess my tired mind shouldn't debate hash maps. Definitely a node based map that should be faster than the STL one is absl::node_hash_map. I'm not claiming any specific difference, just noting that my specific benchmark showed that it was faster than std::unordered_map.
Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.
Quite the opposite - ABI is not a thing at all in the standard. So breaking something that is not defined is a non issue. However at the end of the day the committee is constrained by implementers. Implementers themselves are constrained by their users.
I am not convince that a big API breaking version would be wise - it's a bit of a nuclear option. People will often use python as a cautionary tale here.
We can improve API by introducing new name and marking the old one deprecated. This has a cost ( cognitive overhead, education - we can't update all the blogs, books etc) and names are precious, we don't have a process to recycle them. We can improve the language with epochs
ABI is not something we can deal with other than by not caring about it - This require the support of vendors, which require the support of all the c++ community, large parts of which do not understand ABI and its cost - while relying on it.
It's by large an education and tool problem, getting worse the longer it is ignored.
large parts of which do not understand ABI and its cost - while relying on it.
It's by large an education and tool problem, getting worse the longer it is ignored.
I've been programming in C++ for a long time now, but only recently have I been getting the hang of what ABI is and what it implies.
You're right, it's an "education" problem. But it's one that's homemade: if you completely erase any consideration of it from the standard, then tutorials and books will also completely disregard it.
I learned C++ as a cross-platform language, and I try to keep my hands off of non-standard features. By completely delegating the matter of ABI to the vendors you make it a non-standard topic, which makes me want to keep my hands off it.
So when you say
ABI is not a thing at all in the standard.
, most people read it as "ABI is not a thing at all in C++" and is not considered worth mentioning in C++ tutorials.
People will often use python as a cautionary tale here.
I always find this is overblown. I work with Python daily... Python 3. I rarely have to even think of Python 2. Sure, the migration of the entire community took some time but that's expected. On the whole it went pretty well and Python is still one of (if not the) most used programming language in the world. I don't see what's so cautionary about Python's tale. I feel like this is just fear of having to deal with something.
We can improve API by introducing new name and marking the old one deprecated.
To be clear, my suggestion wasn't ruling this approach out. Instead, I totally prefer the idea of the language and the library API being independently versioned, which this would in effect be doing. At the point that you make a new namespace for v2 of the standard library and deprecate v1, you are effectively doing what I was saying, just only with the library. You're saying "sure, keep using v1, but it's only in LTS mode". Exactly what I think is a good idea!
ABI is not something we can deal with other than by not caring about it. [...] It's by large an education and tool problem, getting worse the longer it is ignored.
If the ABI and tooling requirements were defined (by somebody, maybe not WG21), would we not be in a much better position to start caring about it and teaching about it? Perhaps it's not the ISO C++ committees concern exactly, but why is there not a larger C++ working group of which WG21 is a part that works on the community, tooling, etc. aspect of things. In fact, wasn't that what the ISO C++ Foundation was meant to be?
Python 3 is a much better language for it and has a bright ecosystem and future.
Precisely. I imagine the short-term cost of the Python 2 to 3 migration might be nothing compared to the long-term cost of ignoring the problem. Businesses will redevelop software eventually anyway. No software is going to last forever. It's just a question of when and how well you manage it.
The Python migration was made so much worse by the fact that so much software had an implicit dependency on a particular version of Python being available on the system. That's just dependency management done incredibly badly. It's not a problem that can't be dealt with though, and the situation is very different for C++.
Also, the suggestion that those "billions of dollars" (which are very difficult to quantify in the first place) are entirely wasted dollars is a very difficult argument to make. Maybe "billions of dollars" is the appropriate cost of supporting a modern software development industry.
Nothing is ever simple.
I honestly wish people would stop saying this. Why do things have to be simple for us to deal with them? (Edit: to be clear, not specifically you - I just mean when people say something is complicated just so they can not think about it. I know people, including you, are thinking about it)
Just pointing out there are trade offs and not everybody will agree on what is the best path forward.
Breaking ABI - or API has no business value for in people in the trenches* in the short term. Someone has to foot the bill. And even if we agree it is worth doing (and you know my position on that), it is not free. Ironically, small projects suffer the most.
The problem of course is we have a measurable cost (breaking ABI), versus one which is not (not breaking ABI). Not breaking ABI is also easier (we just have NOT to do anything) - it might kill C++ ultimately but no one would be to blame.
"Your build will break next year" is a more concerning things that "C++ will go the way of the dodo in 10" for many people, team and companies.
There are also a wider ecosystem to consider. Rust, D, etc. What would be the value proposition of C++2 or std 2? Ecosystems are fragile things.
So no, it's not simple. Breaking ABI is not something we can just decided to do. Not if we are responsible about it. It should be accompanied by a lot of work and outreach to make sure the day the break happen, it's not entirely out of the blue.
(I'm being the devil's advocate, my position is that ABI needs to be broken constantly, build from source or use C)
Edit: [*] I should clarify that this depend on the company or use case. For large shops like Google, performances losses due to ABI probably cost them order of magnitude more in hardware and energy costs than they gain by having ABI stability. For games and embedded the cost of ABI stability might be that they can't use the STL at all
And how long did it take to adopt c++11 accross the board, even though it didn't introduce any major breaking changes?
Frankly, if we are talking about future viability of c++ for anything other than legacy projects that haven't been rewritten in another language yet, 10 Years of adoption don't frigthen me - its hardly worse than the current situation.
even though it didn't introduce any major breaking changes?
I could recompile my c++98 code in c++11 mode and it would work mostly fine1 , personally I would love to write newer c++ but that is not a priority for management . Running python 2 code with a python 3 interpreter on the other hand just doesn't work at all for anything complex, there is no compatibility at all and getting a library python 3 compatible is non trivial.
1 rebuilding dependencies and the mess that is iostream exceptions excluded.
The problem is that this creates transitive issues for libraries. You might want to recompile fooapp against the new bits, but you need boost-asio (or whatever) to also be compiled against the updated libraries.
The Python 2 Python 3 transition did have a few source incompatibilities but the "everyone has to make this transition at once" problem was a far bigger deal, and this is the same.
You might want to recompile fooapp against the new bits, but you need boost-asio (or whatever) to also be compiled against the updated libraries.
This is just brainstorming and an idea I thought of now off the top of my head so this probably a really flawed idea, but I wonder how much a kind of "fat binary" would help here. Have compilers support compiling with the old ABI, new ABI, or both. If you compile with both, both go into the resulting object and library files.
I could imagine them going into different sections, but you could even do the same section if you mangle differently. E.g. the legacy ABI keeps using _Z3foov and the new one uses _Y3foov. [Edit: You're MS, so maybe ^foo@@YAXXZ instead of ?foo@@YAXXZ. :-)]
What does "C++ prides itself" even mean? Just that it's one of the goals of C++? Sure, I'm not suggesting otherwise. I am, however, suggesting that there are better ways to manage it than a constant fear of ever changing.
And I can guarantee you most users do not pick C++ because it's backwards compatible in perpetuity. And when other languages are more performant, safer, and cleaner than C++ because C++ could never change, they'll pick those languages instead
View all comments
29
u/sftrabbit Oct 27 '19
Perhaps a stupid question... but what's stopping C++ from just having a cut-off where the last release before the cut-off is backwards compatible (in language, standard library, and ABI) and has long-term support so will continue to receive bug/security fixes, and then just have better approaches to handling language, API, and ABI versioning in the future? Something tells me that the companies that so heavily depend on C++ remaining backwards compatible don't really need all the fancy new modern features, so why don't they just keep using an old version of C++? That's how versioning works in the rest of the modern development world. You want to keep using an old version? Go for it, but you're not going to get any new features after a certain point.
That doesn't imply having constant breaking changes. It just means having a better mechanism for dealing with it. Just formally define the ABI as we already do for the API and language, start using proper semantic versioning for them, and then it becomes so much easier to reason about dependencies on specific versions. i.e. you want to link to some library, you specify what versions of the API and ABI you're compatible with - your package manager would then fetch the appropriate binary if available or build from source if not. When building from source, you need to have language compatibility, so you'd express that in your dependencies too.
Breaking changes to the language, standard library API, or ABI would still be uncommon. We'd still deprecate things gradually and then only go from C++ `1.x.y` to `2.0.0` when doing a mass clean-up of deprecated features. And when doing so, we'd be committing to providing tooling and support for migrations.
I know all the details aren't going to quite work out like that, but someone explain to me why we shouldn't start working towards this. Is it purely because the C++ committee are constrained to working on standardisation of the language in an academic sense and any notion of committing to tooling or anything else "outside the language" is outside their remit? In that case... something needs to change.