News for hackers. Stuff that matters.
Re:Google Launches Carbon, an Experimental Replacement for C++ by jandrewrogers on Monday July 25, 2022 @11:52AM (#32226180)
It is difficult to tell sometimes due to its religious backward compatibility, but C++ has been becoming significantly less complex over time. I have a large C++ code base (originally hundreds of thousands LoC) that I aggressively modernize, essentially rewriting it idiomatically in new versions of C++. It was originally written in C++0x/C++11, rewritten in C++17, and is currently being rewritten in C++20. You can barely tell the code bases are related beyond being functionally similar.

It is also important to separate C++ the language from its standard library.

As C++ the language has modernized, it has dramatically reduced the lines of code to express a given thing. And the more modern way of expressing the thing has stronger type safety, more flexibility, and better composability. Things that used to require a lot of template metaprogramming magic to pull off are now clean one-liners. Particularly in C++20, which is probably the biggest step-change since C++11, metaprogramming is simultaneously much more powerful and much more readable. A lot of code that used to be written is now metaprogrammed. Previous use cases that required C macros largely have native C++ equivalents at this point.

The major issue that makes C++ seem complex is the standard library, which was largely designed and written for legacy versions of C++. If you use the standard library heavily, it tends to want to be used in the style of C++ for which it was originally written. If you built a standard library for C++20 from first principles, it would look quite different from the one we have. Hence the proliferation of non-standard "standard" libraries for C++.

Re:Google Launches Carbon, an Experimental Replacement for C++ by kinjba11 on Wednesday July 27, 2022 @12:27AM (#32246844)
> You can barely tell the code bases are related beyond being functionally similar.

Not sure if you've missed this, but this is a number one reason many consider C++ absurdly complex. To actually know C++ is to know many different similar languages based on the year the code was written. C++20 is very different than C++03 as noted. Now compare this with C, or Go, Java, etc. which in comparison have barely changed.

Re:Google Launches Carbon, an Experimental Replacement for C++ by flakiness on Monday July 25, 2022 @08:07PM (#32232640)
> Hence the proliferation of non-standard "standard" libraries for C++.

Any examples for this? My knowledge stopped at boost and I guess there are more.

Re:Google Launches Carbon, an Experimental Replacement for C++ by flakiness on Monday July 25, 2022 @08:07PM (#32232634)
I'm not sure your code is simplified either because of the modern features of C++ or because of the rewrite.

That said, I like the idea of rewriting old C++ code with modern C++. That'd be also a good way to learn modern C++ in a practical way and having legacy code serves well for this context ;-)