15 ms·
What If C++ Abandoned Backward Compatibility?
- badsectoracula 7y agoIt'll most likely be abandoned in droves. One of the main reasons to stick with C++ (and C) is that the investment you put in the code you're writing right now, no matter how fugly it is, will be there and keep working in the future. Also: > I think it also makes sense for C++ developers whose projects are relatively short-lived, e.g. some games. There is a difference between games and engines - the games might be short lived, but most C++ engines are very long lived, going back decades (e.g. see how the recent Half-Life Alyx can trace its codebase back to Quake 1 or pretty much anything based on the Unreal Engine going back to the mid-90s - there are screenshots of UE1 running on what appears to be either Windows 3.1 or NT 3.51). Even when "engines" are being made "from scratch" this is often a marketing gimmick and the "from scratch" was just renaming the engine because it got a new rendering model and people can't tell the difference. EVEN when this isn't case, often new engines are based on existing code and/or libraries.
- bruxis 7y agoAgreed, I think looking at the Python 2 and 3 migration catastrophe gives a glimpse into what this could look like, but I imagine it would be much worse given the types of (large) projects that are backed by substantially "dated" C/C++ code.
- santamarias 7y agoI agree about the "rocky transition" from Python 2 to 3. Still if the Python migration story gives any inference towards the outcome of an eventual C++ transition, the new language would be an even more massive success; it seems that Python 3.x is doing alright right?
- roenxi 7y agoThat is somewhere in the logical region of saying 'Stephen Hawking was really smart, maybe amyotrophic lateral sclerosis is a good thing'. The transition to Python 3 was not pretty. Still isn't; Python 2 documentation features prominently when I'm trying to look up information. The to abandon backwards compatibility in C++ is to make a mockery even of the name of the language (see the "C" in there). If they want to create a new language they should call it something different. Willfully abandoning backwards compatibility and keeping the name is an abuse of one of the great brands in software.
- santamarias 7y agoI was just trying to get a response to how the Python transition mentioned was so (edit:) "catastrophic". I don't understand the need to bring fiction writers, fatal diseases or laden words like "mockery" or "abuse" to the debate.
- ComputerGuru 7y agoStephen Hawking was not a fiction writer. Stephen King does not have a horrible disease.
- santamarias 7y agosorry, my bad
- bsder 7y ago> Python 2 documentation features prominently when I'm trying to look up information. I consider this more a case of the ossification of search. Neither search engines nor specific sites like Stack Overflow deal with the fact that information can switch from right to wrong with age.
- tempay 7y agoYeah, I think Python 2 has been successfully killed at this point. There are a decent number of projects which still need to migrate (and I recently became responsible for a couple) but it’s been a long time since I heard anyone claim they can keep Python 2 forever. The maintenance burden of keeping Python 2 is rapidly increasing as libraires drop support.
- phire 7y agoYou could do so much better than the python 2 to 3 transition. If the python 3 interpreter could still run python 2 code. If you could mix and match python 2 and 3 code on a per-module, per-file or even per file basis, then the transition could have been so much smoother.
- BiteCode_dev 7y agoThe reasons the transitions worked were that: - the languages were not that different, so no need to learn the new version - python core devs gave 10 years to make the transition. Then extended it. - it was possible to write code running on python 2 and 3 - python is very expressive, hence the code base have way less numbers of lines than in C++ - python cared only about one implementation, Cpython. The rest of the world needed to follow. Some didn't, like Jython and stackless, and the community didn't blink. Despite all that, the transition was very painful.
- otabdeveloper2 7y ago> python is very expressive, hence the code base have way less numbers of lines than in C++ This doesn't match reality. In reality, many Python projects have way more lines of code than equivalent C++ projects. Probably because of the 'expressiveness' you cite; you can't really showcase your love of coding and job security though artificial complexity without 'expressive' bells and whistles. (This is the idea that lead to languages like Go, I'm pretty sure.) That said, C++ is plenty 'expressive' itself.
- BiteCode_dev 7y ago> many Python projects have way more lines of code than equivalent C++ projects. That is mathematically impossible. Even if the syntaxes were exactly the same (which they are not, python syntax is on average shorter), the low level nature of C++ requires your code to do operations that Python does need to do, such as memory management. It's like stating the sky is red.
- snovv_crash 7y agoOnce you've written sufficient unit tests to prove your code works as well as a C++ equivalent does just by compiling, I don't think Python ends up being more dense though. I'd also argue that operator overloading etc lets C++ be just as expressive as Python, the libraries just need to be designed with that in mind.
- pletnes 7y agoSince python3 has many more users than python2 this is not a relevant comparison. It was not smooth, but now it’s done and it worked. There have been many C++ forks which have failed to replace it, e.g D, Rust, ...
- MaxBarraclough 7y agoD and Rust are not forks of C++, they're entirely different languages.
- amelius 7y ago> One of the main reasons to stick with C++ (and C) is that the investment you put in the code you're writing right now, no matter how fugly it is, will be there and keep working in the future. Except slowly people will be writing parts of it in Rust, or they would be using libraries written in Rust (because availability), and then after a while people get annoyed of using more than one language and the whole project will be rewritten in Rust. Of course, at that point, a new language will be invented and Rust code will be looked at as rusty :)
- otabdeveloper2 7y ago> Except slowly people will be writing parts of it in Rust Wishful thinking.
- pjmlp 7y agoWishes sometime turn into reality. https://kennykerr.ca/2019/11/05/rust/ https://kennykerr.ca/2019/11/05/rust/ https://twitter.com/benwilliamson/status/1240113606374686721 https://twitter.com/benwilliamson/status/1240113606374686721
- kllrnohj 7y agoRewriting parts in Rust would require Rust to have good C++ interop, which it doesn't. At all. Rust has good C interop, so if your code is already divided into C-abi shared libraries then you're golden. But if it's not then Rust migration really isn't an option. And realistically I'm not entirely sure how you can add C++ interop to Rust without also ruining Rust. It's a hard problem to say the least.
- fctorial 7y ago> see how the recent Half-Life Alyx can trace its codebase back to Quake 1 Source?
- garblegarble 7y agoHalf Life Alyx is built on Source 2, which was extended from Source 1, which is a heavily modified version of GoldSrc which was based on the Quake 1 engine. John Carmack said in 2004 that "there are still bits of early Quake code in Half-Life 2" - https://github.com/ESWAT/john-carmack-plan-archive/blob/master/by_day/johnc_plan_20041231.txt#L17 https://github.com/ESWAT/john-carmack-plan-archive/blob/mast... https://en.wikipedia.org/wiki/Source_2 https://en.wikipedia.org/wiki/Source_2
- badsectoracula 7y agoYes :-P. In all seriousness, Half-Life Alyx is based on Source 2 which itself is based on Source 1 which is based on GoldSrc which is based on Quake 1.
- kllrnohj 7y ago> but most C++ engines are very long lived, going back decades While true the engines are also staffed and can absolutely keep up with changes. They regularly are tasked with new toolchains, platforms, OSes, and APIs to leverage already. This would just be more of the same, and if you look at the goals of the paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2137r0.html#goals http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p213... That lines up pretty damn well to what game engines want as well. > One of the main reasons to stick with C++ (and C) is that the investment you put in the code you're writing right now, no matter how fugly it is, will be there and keep working in the future. I think you should read the actual paper instead. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2137r0.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p213... The things they talk about actually abandoning are things like byte sizes other than 8-bits or source code in file systems that don’t support file extensions or nested directories. Chances are any existing C++ codebase is already not compatible with such systems that they want to more formally deprecate/abandon in the first place.
- theamk 7y agoYou are talking about section 1.8. I agree, it is not that scary. What is scary, however, are sections 2.1 and 2.2. They contain stuff like this: > Our experience is that providing broad ABI-level stability for high-level constructs is a significant and permanent burden on their design. It becomes an impediment to evolution, which is one of our stated goals. This does not name it, but doesn't this refers to all those discussions about changing internal representation of std::string, std::vector and so on? This does sound pretty scary. Once you have separate classes for "C++23 std::string" and "older std::string", you can no longer link together files built with different versions.. and this means you lose a lot past compatibility.
- kllrnohj 7y ago> you can no longer link together files built with different versions True but this is already something that isn't really "supported" broadly. Some standard libraries work hard to keep that working, but others tend not to, and nobody knows if it's supposed to work reliably or not. And support for this binary compatibility also varies across platforms, like I don't think Microsoft bothers since you're supposed to always bundle a specific version of the runtime with your binary. Single-version prebuilt libraries become more of a problem, but are those that widespread vs. source-based libraries? But I think the broader point here that the paper is really pushing is for the committee to actually make a statement on things like this instead of their historically vague "it sort of works but we're not saying it will or indeed saying anything at all"
- ncmncm 7y agoThere would then be two C++ languages. The overwhelming majority of users would stick with the old one, a scant few would take up the new one, and the rest would move on to some other language.
- rumanator 7y agoThis. I'm currently working on a C++ project that has been taken out of cold storage and when the old rewrite question pops up the tech stacks considered for the job do not feature C++ at all. The main reason is that nowadays there are better tools and frameworks to implement non-performance critical parts of an application such as the GUI, which incidental takes over more than half the total lines of code, and the rest can be implemented easily with small support services developed in whichever tech stack you choose. Thus C++'s "jack of all trades" trait is no longer a major factor in the decision. Meanwhile the lack of a stable ABI starts to feature prominently as a reason not to adopt C++.
- ncmncm 7y agoMost of the pressure to break compatibility comes from Microsoft and Google, representing a truly minuscule fraction of C++ users. However, both are heavily represented on the ISO Standard committee, and very, very little happens there without their express approval. Introducing a new ABI in competition with the current ones (e.g. ia32 and x64) would be less destructive than officially abandoning those currently in use.
- mihaaly 7y agoIt would become C# :)
- felixguendling 7y agoI think the concept would look more like Rust. It is still compiled to machine code, not VM opcode. You do not need a VM and do not require a garbage collector, JIT, etc. which makes it suitable for more use cases. But: if it's a completely new language (no backward compatibility to C++) - why do we need this? Can't we just use one of those new languages that are already available (Rust, Zig, Odin, Nim, just to name a few).
- roca 7y agoThe rational argument for what is being proposed is that companies with (total) hundreds of millions of lines of C++ code can migrate it incrementally and (hopefully) mostly mechanically as the language evolves ... which should be much cheaper and less risky than porting code to a new language. There are probably also strong non-rational components, e.g. C++ people would like to keep working on C++, leveraging their existing skills and status, rather than jump to another community.
- santamarias 7y ago> But: if it's a completely new language (no backward compatibility to C++) - why do we need this? Would backwards compatibility to "modern C++" make more sense than no backwards compatibility?
- DangitBobby 7y agoThose languages are all pretty different from C++, right? I'm assuming the new C++ would be very similar to old C++ with a bunch of things "considered harmful" removed.
- throwaway17_17 7y agoWell I’ve seen at least three recent CppCon talks where they say that ‘for’ loops are harmful and a template function should be used always, so I would hope there would not be a removal of these things, just a non-concern with requiring that changes don’t break the compilation of 10+ year old code.
- Too 7y agoFor this to work you would need stable bridge for calling between old and new version, and with c++ lacking stable ABI and high dependency to header-template interfaces (which is part of the bad c++ one would want deprecated), this could be an issue. Sure, extern C already exists but it's a leaky abstraction and it won't be added to existing libraries overnight. Without this you can look at python 2 to 3 migration to see what will happen.
- beefhash 7y agoThen you'd just repeat the Perl 5/Raku split. You'd have a "new" C++ that isn't actually C++ but it's called C++ with a different version number and people will then bicker for a few years until they realize that the "new" C++ isn't actually C++ and that the "old" C++ just vehemently refuses to die, so they name it something else. The C++ standards committee can standardize a backwards-incompatible "new" C++ for all I care as long as they don't call it C++.
- eternalny1 7y agoI believe it's called Rust :)
- The_rationalist 7y agoSadly rust lack some big features that c++ has like polymorphic inheritance, function overriding and function overloading.
- SaxonRobber 7y agoI think that is for the best. I prefer less implicit behaviour in my code, even if it means my identifiers get longer.
- NotCamelCase 7y agoRust doesn't have function/operator overloading yet or it won't have it at all? I am vastly for clarity and simplicity over vague, implicit stuff but doing e.g vector operations can get very unreadable very quickly without it.
- pjmlp 7y agoRust has operator overloading, https://doc.rust-lang.org/rust-by-example/trait/ops.html https://doc.rust-lang.org/rust-by-example/trait/ops.html
- 7y ago
- vbezhenar 7y agoIf C++ abandoned backward compatibility, then this C+++ would compete with modern languages like D, Rust and it's absolutely not clear what the winner would be. As long as C++ is backwards compatible, it have tremendous advantage of having billions of LoC which don't have to be rewritten.
- pjmlp 7y agoLike all systems languages, the winner would be those that are sponsored by OS vendors for their platforms.
- amelius 7y agoYou would get D ...
- ComputerGuru 7y agoYou would get a runtime and GC?
- AH2mdte8kPnJS 7y agoD is able to run without its runtime and GC. https://dlang.org/spec/betterc.html https://dlang.org/spec/betterc.html And an older link: https://www.auburnsounds.com/blog/2016-11-10_Running-D-without-its-runtime.html https://www.auburnsounds.com/blog/2016-11-10_Running-D-witho...
- roca 7y agoAble to run, yes. But it is not the default, ergonomic way to write D code like it is in C, C++ and Rust.
- pjmlp 7y agoThankfully, GC offers productivity and allows for safe code by default, while D still offers the necessary language features to do all the low level tricks from C, C++, Rust, Objective-C, if one actually needs to go down that level.
- ComputerGuru 7y agoIf I hadn’t already embraced C# for that sort of thing, I’d probably have turned to D years ago. Between C# and Rust, I rarely find myself needing other tools aside from Makefiles and shell scripts.
- roca 7y agoI like being able to write safe and GC-free code by default. Rust would be even better if it was possible to opt into GC, but I would still want to to be GC-free by default. It's good that the entire library ecosystem has grown up GC-free and that should continue.
- lytigas 7y agoSome here are saying "Why not just use Rust/D/Zig/Nim/Crystal if you're going to break backwards compatibility?" I believe the proposal is closer to "We've removed this old feature, run this tool to replace it with the new one." C++ will keep looking like C++, not like Rust. Here's Google's "Codebase Cultivator" explaining the idea for their Abseil library: https://youtu.be/tISy7EJQPzI?t=2209 https://youtu.be/tISy7EJQPzI?t=2209 I remember watching another talk where they propose something similar for the language itself, but I can't find it at the moment.
- simias 7y agoUnless you manage to integrate this directly into the compiler stack and have it work 100% of the time with no "ifs" or "buts" I don't think it'll work. Maybe you could do like Rust with their "Epoch" system that lets you interoperate code using various standards in order to migrate progressively without breaking backward compatibility. I suspect that it would be a lot harder to make it work for C++ however, mainly due to its extreme reliance on #includes (especially for anything using templates) and more common use of macros. I'm not saying it's impossible but I suspect that it would fragment the ecosystem quite a bit. Removing "old features" tends to have massive side effects in a language like C++ with metaprograming, overloading, multiple inheritance, unlimited macro usage and complex symbol resolution rules. So I think "why not just use Rust/D/Zig/Nim/Crystal" is warranted feedback for these proposals (and you could probably add Go, C#, Java and a few others).
- steveklabnik 7y agoFunny enough, Rust doesn't call them "epochs" anymore, we switched to "edition" before the release. However, there's an active (and in my understanding, decently received) proposal based on it for C++ that is called "epochs".
- pjmlp 7y agoBecause C++ is not a single implementation language, rather driven by a standard with multiple implementations. Such a solution is only possible if driven by the standard, otherwise it will never be fully available, just like the static analysis tooling varies by vendor.
- gurkendoktor 7y agoMany people don't realize just how conservative C++ is (the OP only briefly mentions this). The committee not only avoids breaking existing source code, but even binaries, although binary compatibility is not defined in the standard at all. C++ 11, 14, 17, 20, and 23 are all binary compatible (modulo some possible oversights). There are many quality-of-life improvements that got voted out because then a binary compiled in C++11 wouldn't be compatible with one built in C++23 anymore. As a simple example ([1] has many more): the only reason we have both std::scoped_lock and std::lock_guard is because changing the definition of the latter would have required re-compilation of existing code, so a new class had to be introduced. ABI stability even overrides performance in committee decisions (see the std::regex example, but I also heard it affects the footprint of unique_ptr - edit: found it [2]). tl;dr breaking source code compatibility seems way off if implementors don't even dare to break binary compatibility. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2028r0.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p202...
- snovv_crash 7y agoAt this point they should just standardize the ABI. It would solve so many headaches, and allow C++ to be used as a proper systems language.
- pjmlp 7y agoIn Windows we at least have COM and now UWP.
- AllanHoustonSt 7y agoI personally wouldn’t mind seeing the language go the “editions” route a la Rust.
- steveklabnik 7y agohttp://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1881r1.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p188...
- AllanHoustonSt 7y agoI remember seeing murmurings of this on reddit. Cool to see it’s a paper now, thanks for sharing.
- protomyth 7y agoSo, the author wants something between FORTRAN's Ratfor and F. I can see it as a supplement to the C++ standard but not being the actual standard. It would make people distrust C++ greatly if implemented as the standard.
- jefftk 7y agoReading the paper that this is responding to is helpful if you want to get a better understanding of the proposal and the motivation behind it: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2137r0.html http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p213...
- santamarias 7y agois there a discussion thread around that proposal somewhere?
- jefftk 7y agoYou're reading one ;)
- himinlomax 7y agoWell we'll have to maintain the old version. It'd be simpler to keep on calling it "C++," but then we need a catchier name for "new C++." How about "Rust?"
- olafure 7y agoThe catastrophe would be worthy of inclusion in Randall Monroe's What If? book.
- glouwbug 7y agoIsn't C++'s selling point that it is compatible with almost 45 years of code? Seems like a terrible thing to break this late
- gigatexal 7y agoIt’d probably be 20% as big
- hawski 7y agoIt would be nice to have a compiler option, that would deprecate things from earlier standards, that would work per file or per pragma block.
- hedora 7y agoSometimes I wish Google would just stop participating in open source and standardization. The proposal actually suggests supporting Fuschia at the language level, but not any of the BSDs, and replacing the ABI with protobuf (or similar). Much of this proposal would create insurmountable engineering problems for everything except the Google monorepo, or similar infrastructure at $1T companies building monoliths. Historically, most innovation has happened outside of those environments. Sabotaging the toolchains of smaller shops is not going to pan out well for the industry at large.
- google234123 7y agoThey list an "initial non-exhaustive list of platforms" which includes "OS/kernel." I don't think it's fair to say that they are excluding the BSDs even if they aren't explicitly mentioned. The point is that new C++ shouldn't need to support old and historical platforms.
- api 7y agoYou'd get Rust or maybe something in between Rust and Go. We have Rust and Go, so there's no point.
- throwaway17_17 7y agoI don’t see how you can draw this conclusion. Taking C++ and breaking backward comparability just means you can move the standard for C++ foreword without concern for supporting 10+ year old source code. I cannot see a reason this would impose some stringent, immutable by default ownership/borrowing requirement, a radically different type system, a lose of template meta programming for macros (in the case of Rust) or the adding of garbage collection and an invasive runtime with a language imposed concurrency model to the exclusion of others (in the case of Go). Sure as time passed, the non backward compatible C++ would add features not currently in scope for C++, but the radical redesign of the fundamental language is not what this proposal suggests.
- wvenable 7y ago> I don’t see how you can draw this conclusion. Those two languages were created without consideration of backwards compatibility with C/C++ source code and were designed for the same job. It stands to reason that given no constraints of compatibility, you'd get something similar to those languages. Now obviously, those languages do not have all the features of C++ nor the same design principles. But as soon as you have all the features of C++ with the same principles, you have something so close to C++, that it doesn't make sense to break backwards compatibility.
- gameswithgo 7y agoit would be rust
- jmakov 7y agoWe have Python2, Python2.7 and Python3.x. Everybody happy. Loose backward compatibility and evolve.
- SaxonRobber 7y agoI’ll never understand the portion of the C++ community that insists on modernizing the language to the detriment of everything else. When is enough enough? Just let the language be and focus on improving the standard library, not changing language features.
- google234123 7y agoYou do realized that the standard library is also specified? You can't change bad things in the std without breaking backward compatibility.
- SaxonRobber 7y agoI mean standardizing libraries that are widely useful for minimizing external dependencies. Like networking support, serialization for ubiquitous formats like JSON, etc.
- beached_whale 7y agoYou are missing the point. Almost all of this has to do with the binary compatibility of the std library, not the core language. Things like unordered_map/map cannot be improved because the binaries would not longer be compatible. lock_guard could not go from one mutex to one or more because it would have a different name in the symbol table for some compilers, so we get a new scoped_lock that adds another name to do the same thing. push_back on vector cannot return a reference as does emplace_back for similar reasons too. All of those would leave the source code compatible, but break linking, often silently. These are some of the ones off the top of my head, there are more. So the fix in these cases is another name, and that has the problem of making the language needlessly more complicated and harder to learn.
- ImprovedSilence 7y agoIt would become Rust?
- cbsmith 7y agoYou mean, exactly like D?
- santamarias 7y agoI think this discussion is awesome, such a readworthy mix of opinions, experience and large scale digressions :)
- alpineidyll3 7y agoIt'd def. be better to lay it next to COBOL in Valhalla and move on. Breaking the Bkwds comp. makes it C++ in name only.
- T3RMINATED 7y agoC# is the worlds best programming language. Stop using C++ and problem solved.