Talking with the inventor of C++ [video]
youtube.com
youtube.com
C++ is a big, complex language and learning all of its intricacies like many C++ classes nowadays teach is daunting. And that’s where I believe the problems lie. You don’t need to know everything about C++ to start working with it day to day, just the fundamentals. Remember, it was the first language taught to older millennials for a reason.
Comparing language tooling to Rust is surely controversial when compiles in Rust take an order of magnitude longer than any other language. Sure, Rust's tooling has some nice features but let's not ignore this very important elephant in the room.
Do you have any source for that other than a hello world? I always read that both C++ and Rust take about the same amount of time.
Updating crates.io index
Fetch [> ] 0.12%[1] https://doc.rust-lang.org/nightly/cargo/reference/registry-i...
That said I was moderately upset by this Friday after carefully assembling a development container for a project at work. Guess I'll have to make something persistent somewhere if I don't want to twiddle my thumbs before each build.
The great benefits brought by having a standard tooling that actually has useful diagnostic and packaging makes any kind of slowdown tolerable.
Unless you code holding your piss.
And therein lies the actual problem. C++ killed the one saving grace of C, it's relative simplicity, and created a language that is a dumping ground of ideas.
The notion that you just "learn what you need" is an anathema. Not knowing a language, and all it's subtleties, is just a form of hacking. You end up encountering things which you don't understand and have to hope you don't cause unknown problems and muddle through.
That C++ is widely used by professionals who don't understand their tools is just another reason why software is so crappy these days.
I worked in a project that had 6 different string classes: std::string, opencv, vtk, qt … plus a wrapper around all of the above that converted this mess to a plain C string so you could actually use it. A real nightmare, with no good way out.
I’m sure some C++ person will say “it’s not the fault of the language, it’s simply that those libraries are not proper C++23”, missing the fact that those are some of the most prolific, well-maintained and widely used projects in the C++ world. If even those can’t get it right, then the problem must surely lie with the underlying language itself, and with the committee who is defining how it’s supposed to work.
Most likely they do get it right for their problem domain. If the people who made opencv, vtk and qt had to make it in another language with the design constraints they had (which can sometimes be as simple as insisting on using CamelCase instead of snake_case for historical reasons) they would likely make their own string / array / matrix / ... type in that language too tailored to their exact problem domain.
I think the average C++ programmer is pretty aware of the language's downsides. It's still a language with important practical upsides though: there are plenty of C++ programmers out there for hire, there are many existing C++ projects that need to be worked on, and it has a strong ecosystem of compilers and libraries.
There seems to be little prospect of C++ losing its near-monopoly in core game-engine code, for instance.
(I say all this as someone who usually gives C++ a hard time for its poor safety, and associated security issues.)
> That C++ is widely used by professionals who don't understand their tools is just another reason why software is so crappy these days.
No doubt there are many security issues with those roots, and many instances of code that's needlessly non-portable. Those are due to specific issues with C++ though, not its general complexity.
I imagine the practical consequence of the language's complexity is to drag out development times, rather than to undermine software quality. I haven't given this too much thought though, and this is essentially a guess.
> The notion that you just "learn what you need" is an anathema.
I agree this idea makes little sense. If you work in a team, you may be asked to debug someone else's code. If you're going to work with C++, there's no denying the value in having a deep knowledge of the language.
For a long time, the complaint was that it was being used as nothing more than a "better C", though in my experience, the worst abuses came from among those who were determined to use every feature.
In the beginning, the fact that early C++ was a superset of C is probably what led to its widespread adoption, but the legacy of that decision, particularly with regard to pointers and pointer arithmetic, has been a multiplier of complexity.
Raw pointer arithmetic is not allowed in code marked @safe.
I've proposed it for C and C++:
https://www.digitalmars.com/articles/C-biggest-mistake.html
It would be simple to add it, and would be legacy compatible.
Lack of a good way to build third party libraries, build times that are astronomical and a true productivity killer, error messages that are entirely unhelpful and can produce giant walls of text for the most trivial of reasons, rampant undefined behavior that is incredibly hard to identify.
Several things changed my view on C++ and now I see it mostly as a sort of zombie language.
1. As I mentioned once I started my own business and needed to train new engineers on how to use C++, I started to look at the language from a fresh point of view and realized it really is a complex mess just to get basic things working.
2. Scott Meyers "retiring" from C++, and in particular this video:
https://www.youtube.com/watch?v=KAWA1DuvCnQ
3. I attended an ISO C++ meeting in Toronto and while I absolutely found that the people were very intelligent and knowledgeable, as well as well intentioned, I realized just how political C++ is and that much of its development and complexity is not due to technical constraints or driven based on what is in the best interest of the C++ community or research, but really based on name recognition and a lot of politics.
Unfortunately Bjarne himself has been responsible for a lot of political issues with C++ that could have easily been avoided such as the obvious warts with brace initialization and the paper he wrote that basically pushed out two of the most prominent members of the C++ community, Walter Bright and Andrei Alexandrescu over what seems like a bitter pissing contest he had with them:
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n36...
C++ has had some improvements in the past decade for sure, but its future doesn't look too bright at this point. Features like modules are a convoluted mess that still don't work even 4 years after standardization. Coroutines are a lifetime and performance nightmare that was originally designed in particular to accommodate embedded platforms with no runtime, but are all but useless for that use case due to how they allocate memory, and concepts are really just a substitution of one hacky way of doing overload resolution with another hacky way of doing it.
Coroutines were originally pushed by Microsoft, based on .NET's async/await model, and C++/CX concurrency on WinRT (COM evolution) runtime.
Hence why you will find several talks and papers from Gor Nishanov, during C++'s coroutines early days, or that .NET has a similar way of adding magic methods to a class to transform it into a coroutine aware type.
For the reason that it was the only reasonably available language for a while, I'm afraid. I too have written enough C++ in my professional works; nowadays I work with Rust and Python though, my last professional C++ was C++14. And C++ only kinda works when someone with enough mistakes and thus enough knowledges organize the code base in the way that others won't easily make such mistakes. The language doesn't really help you---which is often a pro, but much more frequently a con. That's not a good place for beginners to start at the very least.
Weren't there other popular, cross-platform programming languages in the 1990s and late 1980s? Like Pascal, and Basic? Those both seem like simpler languages, and easier to teach as first programming languages than C++.
I wonder how Pascal ever became so popular given that it was regarded as a teaching language. It was clearly a contender in industry for a while; for example, Apple originally used Pascal for the Macintosh, and Turbo Pascal was extremely popular.
Nowadays, we don't even have "teaching languages". Students are taught something like Python, JavaScript, or Java.
The main advantage of something like C++20 is that for some types of software there is no other language that comes close in both performance and economy. The alternatives either require much more code or giving up a lot of performance, neither of which is particularly palatable for many use cases. I am always keeping an eye out for smaller languages with similar economy and performance.
Um, there are plenty of Crab People[0] around here who would quibble with that statement.
[0] https://en.wikipedia.org/wiki/Crab_people of course.
My biggest issue for giving up was the ever growing list of "don't"-s, its not fun to write in language where the design is so "loose" that to get reasonably correct/predictable code you always have to reference the list of "don't"-s.
And then having been a build maintainer on various projects the build and package management was a nightmare. Still vividly remember the first time I looked at Rust's cargo - mind blown :-)
IMHO C++11 changes (and many of the later ones too) make the language substantially better than it was prior.
I do personally hate the package management story which is why I try to only use single header libraries (I only use C++ for personal projects so I have control over what I use). I absolutely despise cmake, but Rust’s cargo is fantastic.
False, Python is much more flexible and expressive than C++
I think the problem is that it's "easy" to learn it well enough that you think you know it pretty much all.
But you're still far off and you get frustrated!
When I started working in C# the loss of expressiveness was one of the most painful things about it (and I started back in the 1.1 days).
Even something as simple as aliasing typenames, C# FINALLY got it in the most recent version.
The ecosystem, the no-FFI-needed reuse of so many libraries, books and tutorials, are just too valuable, yes c/c++ are not perfect but I failed to find things better.
MISRA's new c++ and c books are great to help me to write safe code as well.
For satellites and rockets in particular, similar to other embedded systems, most of them have the software written in C, which makes sense. C++ doesn't have much to do with it.
I used C++ for many years, as a primary development language for MacOS apps (MPW and CodeWarrior -mostly CodeWarrior).
I happily switched to Cocoa and ObjC, and it’s been Swift, for many years.
But I also write GUI end-user interface apps.
At the company I worked for, we used C++ to write image processing pipeline engines, and would install the engine in apps for Windows and Mac, which were written in C# or ObjC (my company had not switched to Swift, by the time we left).
Our team consisted of a number of highly experienced (like 30 years of coding, experienced) engineers, and they did a great job with C++.
It can present difficult-to-fix bugs, but that’s because of the type of tool it is.
I think of C++ as an “engine” tool. It’s best used to create “faceless” libraries and SDKs (IMO). In that context, it basically has no peer.
Bjarne Stroustrup: Why I Created C++ | Big Think
Anyways, I deployed this software, and someone had a misstep, and the error message crashed the mainframe. I relayed this story to Bjarne around 2006, and he didn't find it funny — just frustrating.
I remember how horrible templating error messages were in the early days of C++. They still aren't great.
That screenshot was a wild ride. WS_FTP!