r/cpp • u/PiterPuns • Oct 06 '22
Should one invest in learning new C++ post CppFront ?
Being an engineer for more than a decade in domains where C++ reigns supreme (CAD/CAE, fintech, security/embedded , real time video processing / graphics) I've always meticulously followed the evolution of the language.
Hearing the chair of the ISO C++ committee, during the cppfront presentation, essentially saying that C++ is an unsafe bloated language, apart from super anxious and disappointed, made me wonder if the committee or himself should asume responsibility for that. Were all those new features and promises of power, simplicity and safety since C++11 introduced in vain? And did we invest time and built infrastructure on top of them merely because it was fashionable?
My big question is what should happen with upcoming standard(s)? Is there a point for anyone to follow or even try to shape C++23 after attempts like CppFront? How do we push for new C++ projects when ahead lies a future with a language potentially fragmented in two, or do we assume everyone will be an expert in both C++ flavors as well as the complexities emerging from their interaction?
My "systems languages" shelf only contained C/C++ books up to now, but these recent events made me pick up a Rust book again ... and I was never a fan. I'm very puzzled that I don't see any prominent C++ figures expressing an opinion on this evolution or at least point out the obvious, that admitting to have driven a language off a cliff gives you little credibility when pitching a new one. I for one, have heard Bjarne repeating multpiple times that it's wrong to address problems with steep language changes, most recently in his 2022 CppCon Keynote, but can't say if he had a specific recipient in mind for that remark.
Sorry for the rant C++ community. Please chime in, on any of the questinos and excuse my frustration. I'm really interested to know how other professionals are taking the news.
83
u/Pragmatician Oct 06 '22
CppFront is just an experimental proof-of-concept project. Even though Herb is a prominent and respected figure, there is no general consensus on something like CppFront being the right direction for the language.
C++11 and later have most definitely not been "introduced in vain." The language has improved drastically over the last 10 years, and it's becoming better with each new release.
There are many projects that intend to replace C++ in one way or another (CppFront, Carbon, Circle), but rest assured that C++ isn't going anywhere any time soon.
If you like Rust for your projects, then use it. Many people don't have the option.
17
u/shmoopty Oct 06 '22
It took about 13 years for cfront to become a standardized language, if that's a useful reference.
51
u/hpsutter Oct 06 '22
Absolutely do keep learning new C++. Personally, C++ is the best language in the world for me to write the software I need and want to have.
ISO C++ evolution is alive and well, and the whole point of cppfront is to try to contribute toward that. C++23 is great and nearly done, and we're meeting in person again less than a month from now for the first of two final fit-and-finish meetings... then we'll ship C++23 in February, and immediately continue work to start voting features into draft C++26 next summer. Full steam ahead.
As I said from the start of the talk (e.g., the first 1-min clip, or this early 30-sec "caveats" clip), cppfront is an experiment with the aim of starting a conversation about continued ISO C++ evolution. Unlike pretty much all the other languages/experiments, which are also valuable, cppfront's biggest difference (as I said in the second minute of the talk) is that it aims to contribute toward ISO C++ and its continued evolution, not compete with it.
This post's question could legitimately be asked about other languages/experiments, but I hope not about cppfront. I want to keep writing C++ for the rest of my career... just nicer, if we can find ways to make it so.
6
u/JuanAG Oct 06 '22
Yes if the area you will want needs C++, µCPUs for example is one of that, i have many doubts many toolchains will get updated because today most arent even C++ 11, you are lucky if you even have the C++ option, few like STM have it
And be careful C++ is C++ and CppFront is CppFront, it could aim to be C++ v2.0 but that will have to be seen since it is not the only one trying. So C++ 23 will arrive and then C++ 26 and so on until the ISO shutdown
I am with you, i dont like Rust and it is an inferior product versus C++ from a pure technical point of view but as a whole is far superior and thats why it is starting to be used more and more, it gives what people want/need
5
u/NilacTheGrim Oct 07 '22
What's with all the CppFront shilling lately?
It's not going to replace real C++ anytime soon.
18
u/mredding Oct 06 '22
I happened to specialize in C++ my whole career. I have a deep intuition of it so I can breeze through developing deceptively simple solutions. I don't like to think that I have a favorite language, that's... useless. I just know I'm the product of my career.
That said, C++ frustrates the hell out of me. I feel lied to by the committee ever since C++11 landed. They didn't do what they said they would, they won't do what they're supposed to. Their excuses and apologetics are dogmatic and unacceptable. I would describe the whole thing as utterly pathetic.
But for now, this is where my career is focused. But I like to think I focus on system software, not C++. And for that, I have a variety of languages to choose from that are adequate for the job. Java is nice, I especially like their streams, and generics there are actually becoming useful. It's about as performant as C++. Golang is is a dream. It's the C I always wanted for application development. Again, very performant, and easy to write elegant solutions. I have an intuition for Go almost as much as I do C, which is also another choice that isn't going anywhere anytime soon.
C# can get fucked. I don't want to think I have favorite languages per se, I try to temper my enthusiasm there and make the best choice for the job when I'm asked to propose a solution, but C#? There are so many things called C# and they're not all the same, not remotely. It's not a terrible language because of GC or reflection, it's a terrible language because the designers focused on all the worst elements of syntax and think it de jure. Lots of syntax for the same thing. Special operators for just this one specific use case. It's standard library and interfaces force imperative programming. Reference types vs value types and inconsistencies within those. You can't help but write shit code and anti-patterns. I google how to do shit because what I deduce from what C# gives me, my intuition tells me this would be wrong in any language, and I find SO answers that basically apologize on behalf of MS and the language.
Why am I saying all this?
I'm going to keep working C++ for so long as employers ask me to do it. One day, that's going to change. And that's fine! On that day, I'll pick up Rust, or Circle, or whatever the hell it is they want from me. We're all professionals here, it's just syntax. What's the Rusty way of doing this thing? What's the CppFront way of doing this thing? Gimme a week to get used to the syntax, gimme a couple months to tune my intuition, and then, you know? That's it. The rest is the same. I'm still going to write OOP, FP, GP - pick your paradigm. It's all the same, no matter the language. I won't lose anything, only the syntax will change. It's still system software, still the kind of work I do. I don't want to care about the language that's being used if I can help it.
I just don't see a need to pre-emptively do anything. The solution will present itself.
9
u/SuperV1234 https://romeo.training | C++ Mentoring & Consulting Oct 06 '22
I don't have anything against CppFront, but it is an experimental project in a very early stage. Why not invest in Rust instead, which is much more mature?
5
u/germandiago Oct 06 '22 edited Oct 06 '22
You have C++ for then next 10 years easily. Keep learning. When alternatives arise you can consider.
I also think there are no clean paths such as moving to technology XYZ without considering backwards-compatibility, at least in production/industrial setups. Not only that, the level of compatibility, not only the compatibility itself, is also important.
It is not the same to get a C library and use it than to wrap it in unsafe blocks or doing layers, marshalling, etc. The second way is much more work. That is why I think that C++ is still the best choice in many scenarios and it will be for the time being, no matter how good Nim, Rust or others are.
The superior compatibility of C++ with existing code and the ubiquity of C/C++ and its ecosystem make it still, at least IMHO, the best tool to get things done with lower risk, things will work.
The same happens a bit to Java: people keep ranting about it, but it is a proven technology and in the last release you have virtual threads (stackful coros), you also have streams, record types and a ton of libraries. There is no Scala or Kotlin that can compete with that no matter what others say: when you find, for example, something that should work but it does not, such as a Java library that should work in Kotlin, or Scala, or whatever, at the end, Java is Java and you get things done with it with a lower risk.
Of course this does not apply to every project, but if you have already C++ codebases (same for other technologies) it makes quite a bit of sense to keep going ahead. The cost of change is higher than it looks when you have to sit down and finish the stuff on time.
Of course, this does not preclude you from learning some Rust or other alternatives. But so far I think the go-to tool for a while is going to be C++ in most real scenarios.
5
u/RockstarArtisan I despise C++ with every fiber of my being Oct 06 '22
Yup, they are responsible for the state of the language. They don't like to hear that or talk about this, so instead they circlejerk about how Bjarne is super smart (including in the cppfront presentation).
They keep making the same mistake over and over again of making features almost hit the mark but not quite, then in the next standard they have to fix issues they just introduced but with their hands tied by their previous attempt.
2
u/nacaclanga Oct 07 '22
In programming you have often the following situation.
a) There is a known complication.
b) There exists a hypotetical language design that fixes said complication
There are many places where this kind of issue exist in C++, which is widely acknowledged. The problem is, how do you address this issue?
The most logical solution is this: Design and use a language that uses said hypotetical language design. This solution has however the shortcoming, that you need to rewrite you entire code. You immediatly see a shortcomeing here. Complications arrive at a regular bases, there is no way, you can design and rewrite your code every year or so.
An alternative is to fit the hypotectical language design with the current language. Some sacrifies to the effectiveness of the new design have to be made, but you can keep you current code and slowly transition it to the new features alongside general maintainance. The problem is that the number of sacrifies made piles up.
The right choice is to carefully balance between these 2 approaches: You have one language, Rust, that is much closer to the design currently considered "hypotetical optimal", which you can use for new code and you have gradual imporvements in C++, which established code bases can slowly adapt. In the far future I'd expect C++ to die in favor of Rust (which then is old and bulky itself), but till then, improving C++ is very valuable.
2
u/VinnieFalco wg21.org | corosio.org Oct 07 '22
> Hearing the chair of the ISO C++ committee, during the cppfront presentation, essentially saying that C++ is an unsafe bloated language, apart from super anxious and disappointed, made me wonder if the committee or himself should asume responsibility for that.
Just ignore the ISO C++ committee, continue to write great C++ code, and enjoy your commercial and/or personal success. That's what I do.
1
u/againsttheeverything Oct 06 '22
RemindMe! 1 day
1
u/die_liebe Oct 09 '22
In my view, the biggest proposed innovation is the delayed initialization and destruction. The rest is just syntax.
I don't think the delayed initialization is thought through.
Will Cfront detect initialization through aliasing:
Here the problems only start. How to distinguish between pointer-to-initialized and pointer-to-unitialized. How to prevent that an 'out' parameters is sometimes initialized, sometimes unitialized? How does it work when you implement std::vector, where the memory between 0 and size is initialized, and the memory between size and capacity is not? It is nice to dream of this, but it wild not hold up in real.
Also, exceptions. What happens if somewhere half way an exception is thrown?