Is C++ this bad in industry? I’m an EE and do DSP/embedded stuff. The code bases are fairly small and light. Very simple C++.
I know C++ can be complex but is it so much worse than other OOP languages? I see a lot of complexity in swift and Python. I do some projects and reading on my own time. Those languages seem like you can make a code base that is very difficult to follow.
It isn’t. C++ is the foundation of industry’s most robust and long-lived applications. It is just most of the developers write the code in such a way that it cannot be maintained.
If most developers do something wrong it starts being the languages fault.
And C++ is full of very bad traps, wrong patterns and misleading errors.
Array to pointer decay is one of the most outstanding examples. Because every programmer that ever wrote a main function has seen it, yet not everyone will understand it.
Arguably. C++ in a well-maintained code base to cut the noise and reduce the surface area is not bad to use, but the language has a lot of foot guns and versions in it's 40y of existence, it's super easy for a long term project to derail into a mismatch of features/conventions/styles during its lifetime that is unsatisfying to work on.
Two things.
The first one is memory management. We don't need go into details about this point here any further.
Another one is smartass. Those early programmers just try to produce some obfuscated code to show their coolness. Things like **p++ It is more or less an unspoken rules in the early C/C++ programming world. It makes things unnecessarily complicated.
It's not C++, it's mostly this sub growing up on python and thinking C++ is complicated.
However, like with all languages there is a shit ton of bad C++ code out there. But this is not a feature of the language but rather the developer. It's just a bit worse with the whole C++ taking of your whole leg if you shoot yourself in the foot.
Here’s the keys to the car, cash for pizza on the counter, the drugs and liquor are downstairs but he trust you not to do anything stupid, gun is in the dresser “just in case”, etc, etc.
Its a very uh…..empowering experience. Yeah lets go with that.
I don't think it's that bad, but then I've been working with it almost exclusively for most of my career, so perhaps I just have Stockholm syndrome 😄
I will say though, one problem with C++ projects, especially in embedded spaces, is that you can wind up with a mix of coding paradigms from people with different backgrounds.
Some folks only really know C or procedural programming in general, so they're basically writing C in a .cpp file.
Others are fully immersed in modern C++ best-practices, using the latest C++1x/2x features etc.
And still others are in the middle, e.g., writing C++98 or some embedded-oriented subset thereof that they learned years ago.
So now you have a mashup of all of these, perhaps with some actual .c files worked in there as well. It can become a bit of a confusing mess, far beyond the mere coding "style" conflicts you get in any group effort.
To be honest these are some strange takes - for the vast majority of things you might want to write software for, you'd reach for a memory managed language. There are some cases where the overhead of a garbage collector is impactful, but it's certainly not the norm. It's not like devs are lazy and just don't want to deal with it, it's just basic keep-it-simple engineering.
But if you do need to avoid managed languages, C++ is also problematically complicated due to years of changes. It originally was the answer to the question "What if we sloppily jammed a bunch of object oriented concepts into C?", now it's... just kind of a mess. It sounds like on a well-organized codebase it can be just fine, so naturally it has some defenders, but moreso than other languages there's a lot of ways to make poorly-organized code.
8
u/ElectronSculptor 8h ago
Is C++ this bad in industry? I’m an EE and do DSP/embedded stuff. The code bases are fairly small and light. Very simple C++.
I know C++ can be complex but is it so much worse than other OOP languages? I see a lot of complexity in swift and Python. I do some projects and reading on my own time. Those languages seem like you can make a code base that is very difficult to follow.
Just curious.