r/cpp • • Dec 07 '22

C++ overtakes Java in language popularity index

https://www.infoworld.com/article/3682141/c-plus-plus-overtakes-java-in-language-popularity-index.html
382 Upvotes

137 comments sorted by

View all comments

Show parent comments

18

u/[deleted] Dec 07 '22

I should clarify what I mean by "simple".

I meant that it's easier to follow and lacks implicit function calls (e.g constructors, function overloading) and data (e.g the extra pointer for virtual functions). It's not simpler to write, but it's simpler to read.

Contrast it to assembly which is all just instructions that not only vary between architectures, but require extra work to understand what happens due to the lack of names and proper types.

From my absolutely subjective experience, I always found it easier to do work on C code bases compared to C++ (you could also claim it's just much easier to make a mess in C++).

35

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 07 '22

it's simpler to read.

It very much is not once you get into remotely complicated projects. Just the lack of templates and classes alone makes many things much harder to follow since the code becomes a mess of macros and function pointers.

A C++ virtual method has a limited set of functions it can call: The similarly named methods in derived classes. A C function pointer can call any function that matches the parameters and return type. Good luck finding all the functions that could be pointed to by some specific function pointer in a codebase that you're not intimately familiar with.

0

u/TheTrueXenose Dec 08 '22

Currently working in C++ the project is a complete mess, me and the other guy both agree that the code should be rewritten in C so this doesn't happen again.

If you are abusing templates and namespaces the code becomes a mess very fast.

2

u/NoPersimmon9400 Dec 08 '22

Templates, I agree, you have to be careful. But how can you abuse using namespaces? They are a great tool in shorting function names. It is terrible to write filename_print to avoid name clashes between files. In C++ you just put the code into separate namespaces

1

u/TheTrueXenose Dec 08 '22

yea, if you use one namespace it would be fine, but they used 5 to 6 for every function, class and enum.

2

u/serviscope_minor Dec 09 '22

The fix isn't to use C, it's to not write awful C++. There's an entire contest inspired by awful C code seen in the wild, so it is not like C is immune to the abuses of imaginative programmers.

→ More replies (0)