The interpreter or compiler could also introduce memory issues into the code. Much less likely to happen, but it is not unknown.
Programming
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities [email protected]
C++ can have excellent performance without ever using a single pointer and avoiding unsafe functions like gets()
- this isn't necessarily a judgment on language - it's a judgement on bad programming habits.
Pointers fucking suck, in a modern C++ codebase everything should be pass by value or const/mutable ref. To my preference I'd rather drop mutable refs to force everything to be more functional but whatever.
just avoid all the bad stuff bro
If I was giving a tour of my kitchen and it included phrases such as "avoid using the leftmost cabinet of any set of two", "the freezer doesn't work but the fridge can be set to the same temperature", or "the oven has been deprecated, just use the microwave", you'd rightfully gtfo. Why is this acceptable of a programming language??
Even references aren’t safe in C++ though, since there’s no borrow checker. Unless you copy everything or use reference counting types everywhere, you’ll still hit plenty of memory-violating footguns. But at that point, why use C++ at all?
I'm learning c++ via exercism because I'd like to use it for game development and other high performance use cases, and because it's a good pip for the resume.
In fact, I mostly did this because so many job listings mention it, haven't even come up with a high-scale game dev problem to solve.
I'll probably continue because I find it interesting and no amount of practice is bad, but my question is how is everyone letting this affect their outlook on c++ in their career vs side projects, etc. Really, I'm having a hard time imagining why it was important for this to be said in this way instead of just changing internal policies and job listings.
I’m learning c++ via exercism because I’d like to use it for game development and other high performance use cases, and because it’s a good pip for the resume.
I think for game development you don't need to worry about a shortage of C++ opportunities any time soon. Both Unreal and Godot are built in C++ as well as many in-house engines. Similarly, there are other niches where C++ is king and it would decades for that to change.
That said, there are certainly areas where C++ is already being replaced by Rust. Areas where both performance and security are important are the first movers, such as webbrowsers, operating system components, but also things like high-frequency traders (crypto ones almost exclusively use Rust, while traditional ones will move slower).
Personally, I also used to be heavily invested in C++, but I'm happy to have moved to Rust myself. I recently became an independent contractor, and while I would be happy to take contracts involving C++ to migrate them to Rust, I would certainly not start new projects in C++ anymore. But for you, I wouldn't worry about that yet. The experience you gain working with C++ will help you appreciate Rust more down the line. Just keep in mind that at some point you will be likely to be exposed to Rust too.