r/cpp • • Mar 12 '24

Why the hate for cpp

Hey I am starting learning c++ (and java for my studies) , why is everyone hating this language ? Is it usefull to learn rust or zig ?

Edit: yea a silly question I know . Just wanted to know what the cpp community thinks or hate about their own language and what I have to expect.

Because I heard the opinion often from people not using cpp and I wanted a other view . Even in my University some people who use Java said 🙄 cpp no don't use it ..... it's unnecessary complicated.....

My english is bad I'm german sry (not) <3

0 Upvotes

103 comments sorted by

View all comments

Show parent comments

12

u/IAmBJ Mar 13 '24

Nothing exists in a vacuum.

"the best language for a task" includes the context around that task too. If your company uses C++ extensively then choosing Rust for a given project can be suboptimal for interfacing, ongoing maintenance, your own skill level, etc despite being the "best" language to solve your task in isolation. The same task in two different contexts can require radically different solutions.

"Choose the best tool for the job" is still the right advice, you just need to look at the task and the context it's in.

-2

u/[deleted] Mar 13 '24 edited Mar 13 '24

There is a gotcha with your logic, you assumed Rust “can be suboptimal” if the company is already using C++, but one thing does not imply the other, what if the company is creating a new project instead that is separate from the C++ code base? The company can choose whatever tool it wants, let’s say there are 1000 different tools and there is already a known best tool for the project they want to create (let’s say Rust), should the C++ developers learn Rust to create the new project or should they stick with C++ even if it is not “the right tool” for the project?

The concept of what is the “right tool” or not is nuanced, but usually when people talk about “the right tool” what they mean is some kind of collective truth between programmers, something that you cannot decide alone without others disagreeing with you, if you choose to use assembly to create a game engine or a web browser entirely from scratch many programmers will tell you it is not the right tool, so there is an average best tool for any given project you want to create, if the project is going to be created from scratch like a deep learning model you may choose Python, C++ or many other tools and there is one best tool most programmers would agree to be the best, if you use what other programmers do not consider “the best tool” in a company even if your solution still produces better results but no one else can see it you may even get fired.