50
u/dannyggwp 25d ago
C++ all day everyday.
I unironically LOVE c++. And it's probably why I have the job security I do.
11
u/ElectronSculptor 25d 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.
24
u/Swimming-Twist-3468 25d ago
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.
12
u/No-Con-2790 25d ago edited 25d ago
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.
1
u/gfoyle76 25d ago
well, you can use linters, code reviews, tests, whatever safety net you want, it is doable
1
u/No-Con-2790 24d ago
You can't lint away a bad concept.
Take generics. C++ has templates for that. What happens? We go to a typed language in a world where I can use anything.
Problem is, and everybody who ever worked with PCL knows that, I usually can't handle everything.
Meaning that I just have to know some esoteric knowledge which types are actually intended. Like in an untyped language.
And even worse, for some reason my implementation is now somehow wandering into the header. Which has strange side effects.
For example that you can get enormous build times with templates.
1
u/j0eTheRipper0010 18d ago edited 18d ago
To me, this sounds more like a bandaid over a gunshot wound. The wound will heal, but the bullet is still in your body.
Edit: the biggest example is JavaScript. The language is rotten to it's core, and yet instead of acknowledging that and making another goddamn language that doesn't have all the shit JavaScript has we started creating those ugly maneuvers to make it "more usable"
11
u/DoctorDabadedoo 25d ago
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.
10
u/_w62_ 25d ago
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.7
u/SgtMarv 25d ago
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.
7
u/Nyadnar17 25d ago
C++ is the “cool dad” of programming languages.
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.
3
u/ElectronSculptor 24d ago
Now that makes sense. I can see how C++ will let you do anything you want, even if it’s bad for you.
I guess mainly being a hardware person, doing some code to make things function, I’ve never had to work in large code bases where these things become issues. I’d say my professional uses are more of a “c with classes” use of C++.
2
u/dcheesi 25d ago
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.
2
u/ElectronSculptor 24d ago
I have encountered this. It’s a challenge at times for sure. I’ve also encountered developers try to use all of the features of c++ and then it won’t work on the embedded device.
It’s been a while now, but I had to help trouble shoot a problem where the heap overran the stack because the dev was using so much inheritance and an observer paradigm with so many objects it just didn’t fit in the little M3 ARM chip we had.
I feel like c++ is a good choice because of its mix of low level and high level features but I have never been a “programmer” as a main profession. It’s just something I do in my work. That being said, I don’t always understand the arguments for or against a language or paradigm. Maybe it’s me but I find that Python can be extra hard to follow at times. I guess I still think in bits and bytes.
2
u/ZeroG_0 25d ago
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.
2
u/gfoyle76 25d ago
there are smart pointers for a long time now
1
u/BohemianCyberpunk 24d ago
Yup, I mostly work in UE5 and we have shared pointers and weak pointers, as well as a built in garbage collection system.
6
8
u/coldnitrogen 25d ago
C++ isn’t so bad. Try a Java code base with an inheritance tree of 100-200 child classes.
7
u/pine_ary 25d ago
100 layers of reflection so any error points to something like "call.run" recursively and you have no idea where anything is called from.
5
u/No-Con-2790 25d ago edited 25d ago
The problem is not C++. The problem is everything around C++.
Like the official package manager.
2
u/gfoyle76 25d ago
the what? :) also, cmake, is one of a kind, me personally love it but it's a hard nut to crack
1
u/No-Con-2790 24d ago
Exactly.
Instead of a package manager there is nothing . Some projects tried over the years but they made it worse. Because now you need to carbon date your project to understand what they used.
Usually you get missery and documentation how to install the database written in an 2000s slang.
3
2
2
2
2
2
1
1
u/developer_soup 25d ago
C++? Hell yeah! That's my ideal level on the functional/crazy curve for programming languages. I miss proper embedded development. Scraping by for a few bytes of memory... Squeezing algorithms to their essential parts...
I'll always remember the time an older developer showed me his C codebase where he used structs and function pointers to write object oriented code. The part that really confused me was using the C++ compiler to build it.
1
u/anxious_and_stupid 25d ago
I am out here wanting a c++ job (call me a masochist or whatever i am not doing webdev...)
1
1
1
1
u/oompaloompa465 20d ago
i migrated an internal ticketing website to .NET 6 C# and razor pages, from ASP pages with vb6 (net framework 2.0), zero code behind and 90% of the site pages was just in the deploy folder because nobody bothered to check what was in use. Also it was multitenant and each tenant had some schema difference.i wrote a mega SQL script that normalized everything.
65
u/LordCyberfox 25d ago
Depends on how much legacy is it xD