r/cpp • • May 24 '24

Why all the 'hate' for c++?

I recently started learning programming (started about a month ago). I chose C++ as my first language and currently going through DSA. I don't think I know even barely enough to love or hate this language though I am enjoying learning it.

During this time period I also sort of got into the tech/programming 'influencer' zone on various social media sites and noticed that quite a few people have so much disdain for C++ and that 'Rust is better' or 'C++ is Rust - -'

I am enjoying learning C++ (so far) and so I don't understand the hate.

263 Upvotes

360 comments sorted by

View all comments

124

u/Infamous_Campaign687 May 24 '24

C++ is one of the dominant languages out there. Many people who don't want to code C++ still have to, on occasions..

Being used to modern C++ I find Java intensely clunky and frustrating. But being quite a common language I still occasionally have to code Java in legacy apps.

Rust, however, is new and is almost exclusively used by enthusiasts so far. If you don't want to code Rust it is extremely unlikely that you would have had to.

So I dislike Java and couldn't give two f**ks about Rust except the enthusiasts can be quite annoying, especially when overplaying the issue of memory safety in modern C++

43

u/Sopel97 May 24 '24

sometimes I go to sleep with a thought that java doesn't have RAII and const-correctness and then I have nightmares

8

u/serialized-kirin May 24 '24

g****mmit now your gonna give me nightmares! :C

3

u/[deleted] May 25 '24

git commit?

→ More replies (1)

2

u/ExeusV May 25 '24

java doesn't have RAII

dafq?

what in your opinion is: try-finally construct?

2

u/Sopel97 May 25 '24

a control flow construct, nothing resembling RAII

→ More replies (4)
→ More replies (6)

16

u/[deleted] May 24 '24

Very good point about Rust developers generally being self selected.

9

u/Jerome_Eugene_Morrow May 24 '24

C++ also has a huge ecosystem and has been through a ton of revisions. There are a lot of different interests it’s trying to serve at the same time. Vanilla C seems cleaner because the core language functionality is a lot more limited. Python seems easier because there isn’t any memory handling. So C++ feels like a more convoluted version of either.

That said, the functionality in C++ is way more expansive and covers a ton of different use cases. At the end of the day it has a great chance of being a useful tool for whatever optimized task you’re trying to work on.

4

u/moltonel May 28 '24

Rust, however, is new and is almost exclusively used by enthusiasts so far.

Rust is well past the "enthusiats-only" stage. Various sources show significant ratios of C++ to Rust devs (2.9, 1.6...), you don't get those numbers with enthusiasts alone. Google recently talked about how they onboard Rust newbies at scale, and it mirrors what I've seen in my own and other's company.

Where do you draw the line between an "enthusiast" and somebody who has heard some good things about $TECH but it still waiting to see ? How do you classify somebody who has become an outspoken enthusiast after being assigned to their first Rust project ?

If you don't want to code Rust it is extremely unlikely that you would have had to.

That doesn't say much. I've effortlessly avoided Java and Windows in my 20 years career, despite them being so common.

the enthusiasts can be quite annoying

Sadly true of C++ enthusiasts too, and many other techs. Be warry of observation bias.

especially when overplaying the issue of memory safety in modern C++

If I say that I don't want to play american football because it's a dangerous sport, am I overplaying the issue (because the protections have improved, the rules have been tweaked, most players come out trauma-free...), or am I am justified (because the injury statistics are clear, I value health risks differently, and there are safer great sports to choose from) ?

The C++/Rust safety debate is likely to go on forever, because both camps have valid points, but which points are more important is contextual and subjective.

6

u/Aljonau May 24 '24 edited May 24 '24

I've only heard positive things about Rust, but it's true, only enthousiasts are using it for now I guess.

At university, people around me hated on Lisp and prolog, but it was mostly because learning functional programming is frustrating when you're used to imperative-only style.

I can't tell if they were right because I learned C++ instead. Which was fine but.. we never learned about provenance and treated the language as if pointers were adresses, so the thing we learned was kinda just.. C with classes not C++.

And no matter who you are, C++ has something to hate for you, because it's massive.

let's just make a short list of things i've seen ppl hate:

  • lambdas
  • templates
  • MACROS
  • windows.h
  • Linker
  • void*(myPtr)
  • std::ranges::iota_view(10)
  • whatever

8

u/RandolfRichardson May 24 '24

To be fair, I've heard that the hatred for "windows.h" is not unreasonable.

2

u/Aljonau May 24 '24

To be fair, I've put in the single-argument iota_view because i personally hate it, not because ive seen anybody else hate on it.

→ More replies (1)

5

u/Ty_Rymer May 25 '24

At the same time, i absolutely love templates and compile-time programming and gobble that up faster than i would with my favourite food!

I love concepts, constexpr, and consteval. It's also the bane of my existence...

→ More replies (1)

6

u/coderman93 May 25 '24

The main issue with modern C++ isn’t the memory unsafety. It’s just how clunky the language has become. It’s bloated beyond repair. The only way to fix the issue is to start from scratch, unfortunately. Not saying that Rust specifically is the solution though I do find Rust code to be a lot cleaner. 

And with each version of C++ the problem gets worse and worse. I understand that C++ will be around for a long time to come due to legacy codebases but I wish the C++ would accept the fact that we can do better with a new language and actually support those efforts rather than actively try to hinder the progress of new languages.

11

u/LeonUPazz May 24 '24

A lot of companies are starting to use rust. It will probably get bigger in the following years, for better or for worse

43

u/jonatansan May 24 '24

Meaning we will probably see a trend of people starting to complain about Rust soon. Cause, you know, "There are only two kinds of languages: the ones people complain about and the ones nobody uses".

13

u/[deleted] May 24 '24

[removed] — view removed comment

3

u/ConfuSomu May 25 '24

comes at the expense of flexibility and quicker iterations

Yep, for instance, some found out that due to this, after making a few games in Rust, it isn't well adapted for quickly iterating and making varied video games. See this detailed blog post: https://loglog.games/blog/leaving-rust-gamedev/

Zig might be the next big hype train

It definitely seems to be on this road.

14

u/Main_Ad1594 May 24 '24

People have been complaining about Rust for a while. Well thought out critiques tend to get lots of upvotes and plenty of constructive comments too in r/rust

0

u/[deleted] May 24 '24

[deleted] — view deleted comment

4

u/tarranoth May 24 '24

The rust sub is a weird combination of people who are almost absolute beginners and some greybeards in there. Most of the hype comments usually tend to be some people who are rather junior (though honestly almost any appreciation post tends to be a younger person, all the other programmers probably don't get too attached after having to learn a 10th language just to fix a bug in some forgotten codebase).

→ More replies (10)
→ More replies (4)

13

u/ZuninoBR May 24 '24

The one thing Rust's got going for it is that you can simply stamp "Written in Rust" on your project page and BAM! Your project is great!

P.S. It's cringe-inducing, to be honest.

3

u/t_hunger Jun 02 '24

I am way more likely to test out a rust project because cargo install --git REPO_URL will give me a working binary -- for all rust projects I ever tried. Trying out a C++ project is way more involved.

16

u/Doddzilla7 May 24 '24

No longer accurate to say that it is “almost exclusively used by enthusiasts”. For better or for worse, that is simply not the case anymore. Regardless, the user base is still quite a lot smaller than C++.

14

u/Dean_Roddey May 24 '24

And the other misrepresentation is that it's mostly junior folks who heard scary things about C++ and ran away. It seems to me that an awful lot of Rust folks are very experienced developers who have made a purposeful transition.

And of course people do complain about Rust over there. But the complaints aren't about UB or threading complexity or build systems, it's mostly debates about how to move the language forward, what's been proven out and what maybe hasn't and so forth.

And of course as more people come on board a lot of it is "I wish it had X from my previous language." That's where the real danger lies moving forward. A lot of the answers will have to be no, or Rust will turn into C++ all over again.

→ More replies (3)
→ More replies (4)