DEV Community

loading...

Why C programmers hate C++

yujiri8 profile image Ryan Westlund ・1 min read

So I recently started learning C++, as part of a job qualification. I thought this would never happen because so many experienced C programmers - many whose opinions I value, including Linus Torvalds and Drew DeVault - think C++ is the worst thing ever, and I didn't think I would need it. But now it's happening.

After following a few chapters of the tutorial at cplusplus.com, I'm starting to see what C programmers hate so much, and I want to disuss them.

Redundant variable syntax

int a = 0;
int b (0);
int c {0};
Enter fullscreen mode Exit fullscreen mode

Three syntaxes available that, at least for many cases, are all interchangeable.

class and typename are interchangeable in template definitions

A bizarre case of redundancy.

Pass by reference

I think this is a big one. My guess is that pass by reference is offensive to experienced C programmers because it allows the syntax on the calling side that normally means "pass the VALUE of this variable, not a pointer" to pass a pointer!


Am I in the ballpark? Are these some of the reasons C programmers hate C++?

Discussion (9)

pic
Editor guide
Collapse
siy profile image
Sergiy Yevtushenko • Edited

I think that main reason is the fear. Most pure C programmers I'm familiar with, just afraid of C++ because it is much more complicated. Despite syntax similarities and common history, languages are very different and C++ requires completely different mindset. Not everyone is ready to change his mindset.

Collapse
rokstar profile image
Roman Kirsanov • Edited

Yeah, C++ is huge and bloated, but it introduces many cool things, BTW, pass by ref is a great thing, you just need to understand the reasoning behind it (learn about move semantic).

You don't have to go full OOP to be kinda true C++ dev, but sometimes simple classes are really killer. I personally don't like to smear OOP all over the code, just slightly.

Templates are great thing, it's just it!

Anyway, there are still many things I hate in C++ !!!

Collapse
jamesyoung_au profile image
James Young

Most good programmers that dislike C++ are whiny little bitches that get stuck in their ways. Almost all of these good programmers are systems programmers who write admirable code.

I can understand the verbosity of badly written C++, and the tendency to overly hide implementation details costing some readability being irritating to those stuck in procedural style at a fairly low level. The case of string_view's existence and much eye rolling at the rather fat string class, many copies of objects in code and things like that give me enough to sympathize with complaining C programmers.

On the other hand, C programmers not appreciating anything about a potentially better C when used well just sound like luddites. What's not to love about automagic vector, map, list, thread, standard algorithms, overloading, clear namespaces, nice code organization and lots more? Good, high level APIs and the ability to forget implementation details and memory management on occasion?

Good C++ is great. You can program in a C style using C++ and take enough advantage of its facilities to be quite happy.

Collapse
mitchelllng profile image
Mitchell Long

I've never written any C but might another reason be that C++ is a OOL and C is a functional language?

Collapse
yujiri8 profile image
Ryan Westlund Author

You mean procedural? There's not really anything functional about C

Collapse
rokstar profile image
Roman Kirsanov

-fblocks and here you go :)

Thread Thread
yujiri8 profile image
Collapse
mitchelllng profile image
Mitchell Long

Yeah, my bad.