Sean Baxter not only wrote his own C++ compiler, but he authored this magnificent vision paper for the future of C++ that it moved me to reconsider my views on the safety of the language and its use future projects.

Seldom a man of my age and opinions can change his mind over something so fundamental.

Enjoy: https://github.com/seanbaxter/circle/blob/master/new-circle/README.md

circle/new-circle/README.md at master · seanbaxter/circle

The compiler is available for download. Get it! Contribute to seanbaxter/circle development by creating an account on GitHub.

GitHub
@Migueldeicaza I suspect some degree of sarcasm is involved here, but will read the linked document...
@Migueldeicaza oh boy. I recall how much you were against C++ back during our Linux/KDE/Gnome days 😅.
@glaurent some 25 years later the best interop across languages remains the limited C ABI.
@Migueldeicaza I guess so. But IMHO interop wasn't that important in retrospect.

@glaurent @Migueldeicaza I think the two are self-reinforcing. We almost never use libraries built with, say, Java, from a C++ project. Or consider calling Python from C#. We never do it because it would suck, so it doesn’t feel important.

Imagine a world where there was a stable powerful cross language interop ABI that let you do those things in a nice easy way. In that world people *would* use languages from other libraries a lot, and interop would be critical.

@borland @Migueldeicaza you won’t use a Java lib in a C++ project because if you picked C++ in the first place, it’s for reasons that most likely preclude from using Java.

Are there really that many libs written in a given language that don’t have an equivalent in any other ? And good luck finding a standard for interop’ing things like asynchronous calls for instance.

@glaurent @borland nah, legacy plays a big role, and that’s why things like Mono end up embedded everywhere
@glaurent @Migueldeicaza @borland Quite a lot actually.

An annoying amount of ML-based audio & speech analysis libraries exist only in C++ and not Common Lisp, without any good C-wise bindings.

Which means one either has to use the Clasp implementation for transparent support, write C shims manually or use autogenerated ones.

@glaurent @Migueldeicaza Idk, it kinda boils down whether this (or similar projects) will be successful or not. GTK can quite nicely embrace the current Rust revolution and also integrates surprisingly well with C#, Qt seems to kind of struggling with C++ becoming more of a clutch than GObject was. It's impossible to migrate Qt away from C++ and crazy hard to use it from say Rust.

Their relevance is tied to the progress of C++, while GTK isn't tied to C. The same story may repeat itself in a few decades perhaps, when GTK may be bound to Rust :-p

That being said, Rust tries to be a living language that doesn't need to be replaced by the same virtue and for the same reasons outlined in the document. Most Rustaceans probably philosophically agree with the document, but don't believe that C++ or its committee is ready for such an evolutionary approach.

@Migueldeicaza the feature switch idea immediately reminds me of “use strict” in JS, but the overall approach seems more practical than Carbon going forward
@Migueldeicaza I definitely like the use of feature flags to modernize old languages. It worked for Visual Basic and allowed the language to gradually metamorphose from something awful into C#-with-words, I'm surprised more haven't taken that approach.

@Migueldeicaza This looks like it could be a very interesting low-impact & low-cost way to experiment with language extensions.

This resonates with me:

"I don't want people to have to rewrite anything. Instead, enable one feature at a time and keep at your compile/test cycle until you've resolved any conflicts created by these new "bubbles of code.""

As a user of C++ for 30ish years who is more-and-more frustrated with how complicated the language has become, count me intrigued...

@Migueldeicaza one of my main bugbears with C++ is the explosion of different ways to do things. I get tetchy if a project doesn't have consistent whitespace, so having the option for every file to be written in a completely different language dialect is definitely not going to be the thing to convert me 😅
@nicklockwood @Migueldeicaza in a well managed project I would point this out as a way to facilitate gradual adoption of new features.
@Migueldeicaza This reminds me a lot of Objective-C: You could say Cox wanted a "bubble of new code" that was more like Smalltalk, but wanted to keep his old code (in this case, C). Heck, it's even like C++, which owes its success in large part to compatibility with C sources and its toolchain as well (because that made it quickly available on a huge number of platforms that already had a C compiler).

@uliwitness @Migueldeicaza mainstream systems programming languages have allowed piecewise migration from the last one, since otherwise large codebases will not transition. You can embed ASM in C, C in C++ or Obj-C.

I think C++ is so large that it won’t be able to be embedded in any other language than C++. This approach seems very pragmatic

@tomfinnigan @Migueldeicaza I’d say the same about Swift and other modern languages. Once we moved beyond functions and simple data structures, the impedance mismatch just got too big (except for closely related languages). Generics in C++ and Swift just aren’t similar. Heck, ObjC generics barely map to Swift, and those languages are arguably closely related.
@tomfinnigan @Migueldeicaza It will be interesting to see how more similar languages fare when it comes to bridging. Like, I could see Kotlin and Swift's superficial similarities make integration easier. Similarly, Carbon's 'choice' construct looks like it may map over to Swift enums with associated values well enough.
@tomfinnigan @Migueldeicaza Oh, regarding ASM in C: I wish there was a reliable standard for that. Half the compilers had different conventions (define a C function with an asm body, define an arbitrary range of assembler inside C code, Intel vs. AT&T syntax, how clobbering specifications look, whether C declarations can be accessed by assembly language sections ...). The most portable mechanism was still a second .S file defining a C function, plus a hand-crafted C header.
@Migueldeicaza More than a whiff of "I do not know what the language of the year 2030 will look like but it will be called C++" to this.
@davidm @Migueldeicaza Having read a little bit more of the essay now, David's comment hits the nail on the head for me. The syntax of these new features is alien to a lifelong C++ programmer, and learning to make a borrow checker happy is the same experience regardless of the underlying language. If you're going to learn a safe language, why would it be the C++ of tomorrow rather than the Rust of today?
@abr @davidm @Migueldeicaza I believe the whole point here is too move to something more modern when you have large C++ code base that you want to continue to work on seemlessly. For a standalone project that doesn't have to integrate with C++ there are a lot of good options.
@abr @davidm @Migueldeicaza oh wait this whole discussion is a year old.... Oops not sure how I got here 😁
@roytries @davidm @Migueldeicaza you and everyone else. There’s been quite a few interactions with this post today and yesterday for some reason.

@Migueldeicaza It is really easy for people like me to think of C++ as what it was like a quarter century ago. But modern C++ and the kinds of tooling described there and elsewhere show that there is no reason to discard C++.

I still favor #Rust for new projects, but I agree that a great deal of prejudice against C++ is based on outdated assumptions.

@jpgoldberg @Migueldeicaza C++ is 10 different programming languages pretending to be one
@jpgoldberg @Migueldeicaza
The problem with so called modern C++ is that it has to interoperate with old C/C++ codebases, which limits the use of modern techniques, and there isn't a way to have a clear boundary between safe and unsafe code the way #Rust does it.
@hjvt @jpgoldberg @Migueldeicaza you can usually get to the point of using modern C++ constructs only in new code by constraining the scope of the legacy code and providing wrappers (much like you would in Rust). The modern code is still full of pitfalls and tricky semantics (and no safe/unsafe distinction as you say)
@jpgoldberg @Migueldeicaza But are the outdated assumptions? Can you write secure safe code in C++, 100%. Question is how many people can, and more importantly how many people do? C++ is hugely complex, even tracking the changes in C++ seems like nearly a full time job. Generally C++ programmers will use the codes/ideas they have used over their coding careers, and not often discard or re-evaluate what they have already learned. Takes an expert to know which pieces to use and not use.
@jpgoldberg yes, but … anyone can still write C++ in the style of 25 years ago, right? Even in a project where you’re “not supposed to,” right?
@scouten I don’t know. You can certainly build various linters into your CI.
@jpgoldberg @Migueldeicaza sure, but you’re kind of helping me make my point. People who try to portray Rust and C++ as similarly safe underestimate the difference between opting OUT of safety vs opting IN to safety. Having worked in both languages for major parts of my career, I can tell you that the difference is incredibly important.
@scouten @Migueldeicaza I want at all suggesting that they are equally safe. I do advise Rust for new projects. I was expressing relief that at least portions of the C++ community have been developing tools to move away fro the monstrosity I had envisioned based on what I’d seen 25 years ago.
@jpgoldberg @Migueldeicaza ok, then we are well aligned. Nice to have met you!
@Migueldeicaza He kind of missed me first thing out the gate by omitting a fifth key attribute of successor languages: package management. This isn’t even new; Python, Ruby, and Perl have had this for decades (CPAN turns 30 this year!), and they’re core to Rust and Go. Integrating C++ libraries remains a time-consuming and error-prone ritual, and keeping up to date is a huge point of friction. I dread nothing more about going back to C++ than external dependencies.
@Migueldeicaza What Sean is doing is breathtaking, TBH
@Migueldeicaza Oooh, this is nice. The feature masks are very clever!
@Migueldeicaza This looks interesting, and is certainly an impressive technical achievement, but I'm worried that I see no mention of the ever-increasing cost of maintaining a toolchain that can can compile all the possible feature combinations. E.g. "The compiler still knows how to perform function overloading", and it has to keep this knowledge ("perhaps the most complex part of C++"!) until the end of time.
@Migueldeicaza I'm also not convinced all desirable features work as per-file flags, e.g. it's not clear to me how a per-file borrow checker would interact with other source files that don't specify whether they own, borrow or mutably borrow something...
@Migueldeicaza why does it disallow function overloads by default? 😭
@Migueldeicaza This is both full of really important ideas, and full of the blustery false certitude (“These are content-free statements”) that accompanies projects that are making a play for users with strength of personality over strength of engineering (cf Perl). Which is sad, because AFAICT there is strength of engineering aplenty here.

@Migueldeicaza that is very cool. I love this quote in particular:

“There is nothing inherent about software. Software does what it does, and with effort, can be made to do something new.”

The article shows that C++ *can* move in a good direction, but unfortunately I’m pretty confident it *won’t* because all the people in charge are afflicted with that thing where you get used to something and become so invested in it to the point you’re blind to it’s faults.

@borland @Migueldeicaza

Well, and he's obsessed with 100% backwards compatibility. As long as you have a bunch of stuff you won't touch, that limits the flexibility and plasticity of software.

Software can be made to do something new, but not in places where you said "no new here, it has to do the bad old thing."

@Migueldeicaza Feature with n bits mean 2^n different dialects of C++ to build into our brains, our IDEs, our linting tools, our debuggers, and so forth. It means 2^n different sets of feature interactions to consider as the language evolves. Editions make some sense, but individual flags maybe not.

There are also a lot of C++ problems that can’t be fixed on a file-by-file basis. Let’s say I want to define away UB entirely. Can I?

@Migueldeicaza Very very interesting. On that same path and fwiw (which is less than 2 cents) vlang.io is shaping up really good also.

@Migueldeicaza

It's a fun manifesto. Some of it is a bit silly. For instance, in "Will this cause an explosion of features, and will the C++ community crumble like the Tower of Babel?", all his arguments there apply to JS, which takes constant and gigantic penalties because it's so fragmented, for precisely the reasons he mentions.

He *is*, to a significant degree, opting into those same difficulties.

@Migueldeicaza

He also seems to be saying that backwards compatibility with weird stuff should never be a problem for app developers, only toolchain developers.

But that's just not true. You can't just change how, say, bit shifts work because a ton of old code depends on bad old behaviour.

I suppose you could declare bit-shift bankruptcy and create a whole new operator. But you have to avoid the old one at a minimum.

Backwards compatibility is *ugly* here.

@codefolio the world is big enough for this :-)
@Migueldeicaza Yeah, it's truly amazing work. The focus and dedication and brilliance that has to come together to get these results has been really exciting to watch.
I wish for whatever it takes for this to get more traction.