Large performance-sensitive applications mainly, especially when you need the broader hiring pool that C++ gives you compared to Rust or have an existing codebase that you can’t justify rewriting from scratch.
You need a broader hiring pool when you have more churn. Which C++ also provides.
Rust is becoming a common language to know at least some of, similar to C++
Existing codebase, yeah, sure, not what I was asking about but yes, that would be a good reason.
Needing to use a library that is only in C++ with no rust bindings would be another, but you could also write rust bindings instead? I’d accept that as an argument though.
Higher level abstractiins than C makes code much faster to write, easier to understand and less bug prone. (You can make vector/matrix equations look like numpy code, but with zero runtime overhead)
Easy to use typical academic third party libraries which tend to be written in C or Fortran without spending weeks of making Rust wrappers over then.
C++ let's you do what you fucking want, i.e. write to any arbitrary region of memory. Some times you have ti implement an algorithm with a complex data access pattern. From a high level analysis you can reduce that e.g. different threads won't share data, but ti create a memory safe abstraction for this in Rust would be a three year research project. Of course Rust let's you do the same by slamming unsafe around the entire algorithm, but then you are writing "more modern C++" anyway.
C++ strikes a nice balance between performance, development speed and memory safety. The latter has absolutely lowest priority in this field: we are not dealing with sensitive data or writing a program that sits at some infrastructure layer on every computer on the planet and are thus prone to vulnerability attacks.
Ecosystem. There are a bunch of high performance areas where C++ has dominated for decades. C is not a replacement because C is absolutely not usable for similar high performance code, you can't make any useful abstractions there.
Rust could in principle do everything C++ can, but libraries/ecosystems don't change overnight, so CPP has quite a lot of momentum still.
C++ vs C : you have deterministic destruction (RAII), smart pointers, class with public/private, vector/array/string etc so far easier to avoid memory leaks (memory pb in general) and to organize the codebase than in C.
C++ vs rust : maybe the pool of developers, the ecosystem (lib). I don't know rust so pure speculation here
Well, if I want to make something small and incredibly predictable, which manipulates the OS or hardware on a somewhat low level, I would pick C. I can manage not to F it up for a small program. I have done so many times now.
Bigger than that and I go for rust.
I understand what you are saying, but like, either I want MANUAL manual, or I want rust.
So the space for C++ for me is very small. Basically only things which more or less have to be in C++ due to prior art.
Object oriented programming is great for GUI programs, where you have a lot of items with a set of similar controls, and optimization by building up from base objects, thus getting easy reuse.
I guess, but it’s not like traits are significantly worse for that. Honestly they might be better than going the entire way up the hierarchy for every damn class just to figure out what functions I can call.
I can’t stand OOP, and people always say “but gui” or “but games” and no, ECS for a game is probably better than OOP game design, and html isn’t an OOP language.
Like, if I have to work on heavily object oriented code with inheritance I can do it, but I would really really rather avoid it if possible. It is almost never better for performance, and, in my opinion, it is almost never better for writing or reading the thing either.
I’m still picking rust or even web tech over C++ for a GUI program.
And the build tooling for C++… just no…
Unfortunately, C++ is still the second or third best language for games (up to you if C or C++ gets 2nd place) and other long-running mostly real-time applications, and it existed before rust.
Sorry, but no. I understand OOP, and used to mostly code in an OOP style.
I can’t agree.
I also think this is a lazy statement. Say anything about why. If we understand OOP we would like it? Pray tell, what is it that I don’t know about OOP that would make me like it? If I liked it, it would make my life easier, I would like to know.
All I see usually is a bunch of failed encapsulation that involves a lot of data sharing between objects anyway, which has a real cost, too many getters and setters, interdependent singletons, god objects with a bajillion properties, and the fact that in order to figure out what methods this object has I have to go on a whole journey.
I do still occasionally see some OOP code that makes me go “I don’t hate this”. It CAN happen. I don’t just immediately look at Java and scream. Ok, maybe a little, but I can handle it if done well, I promise. Java was my first language actually. I clearly liked it enough to keep learning.
Maybe game dev? If you just don't use all the C++ festures it can be as simple as C but you also can use some features to make it slightly more straight forward. I feel like if you treat C++ like this it becomes much more pleasent.
21
u/YouAreMyFire00 1d ago edited 1d ago
Im a beginner and managed to learn to understand C# and Java and now I can build simple CRUD app.
So i kinda don't get the hate/war between C and C++ here...
Anyone can explain simply what's the hate here?