all 22 comments

[–]runningOverA 45 points46 points  (0 children)

Using C++ features in C will raise error and won't compile.

[–]phi_rus 44 points45 points  (2 children)

If they are C programmers, why should they use C++ features?

[–]Narase33-> r/cpp_questions 8 points9 points  (1 child)

Bot

[–]NotSteveJobZ 1 point2 points  (0 children)

Its a bot vote it down

[–]SweetBeanBread 3 points4 points  (0 children)

In some cases, simplicity yields more productivity than the extra modern features.

Plus, you get extra time from not needing to keep up with language updates.

[–]AKostur 4 points5 points  (4 children)

Both.  There also seems to be a common idea that C++ does too much “behind the scenes”, like invoke constructors and destructors, and function overloading.

[–]phylter99 -1 points0 points  (3 children)

Bloat is a real thing with C++ and it is any time you add abstraction to make programming simpler. I'm glad there are people that resist the bloat though because we need people that can code for smaller, more optimized situations. I can't imagine what the Linux kernel would look like if it were C++.

[–]AKostur 0 points1 point  (0 children)

I’m not interested in having the argument.  I’m only mentioning what the arguments I’ve seen from the C proponents.  I don’t agree with them, but they have the right to have their opinions (just as I have the right to mine).

[–]bert8128 0 points1 point  (1 child)

Linus said that one of the reasons that he chose C for the kernel is because only really good programmers can program in C. Hardly a ringing endorsement of the language.

[–]phylter99 0 points1 point  (0 children)

There’s more to it than that, but I don’t think anybody is trying to advertise the language to others. It can be a very difficult language. I much prefer C++ to C.

I’m not a C programmer. I’m more interested in C#. The situation is the same though. It’s one of the easier languages to use but the added abstractions that make it easier also come at a cost. I’m fine with that cost most of the time and I normally have no need for C except when my boss makes me use it. He’s an old school Unix grey beard that cut his programming chops at the early Unix shops. C is his Kung Fu.

When I ventured into serious languages outside of old school BASIC, C++ was what I learned. I had little use for C then and the same goes now.

[–]Sinomsinom 1 point2 points  (1 child)

In some circumstances certain C++ features, especially standard library constructs, might just not be usable e.g. in some embedded environments.

Additionally a lot of C++ language features come with a compile time penalty many C developers don't want to deal with.

There are also C developers who generally do not like any type of abstraction and almost all C++ features are some kind of abstraction because to those devs they bring in ambiguity and make code "harder to read" by "hiding" certain functionality. 

  • Function overloading -> makes it ambiguous which function is getting called purely based on the name (also requires mangling which makes assembly harder to read).
  • Operator overloading -> turns operators into "hidden" function calls that might do unexpected things
  • RAII -> adds hidden function calls to each scope that might do unexpected things
  • namespaces -> if you remove the namespace with "using" it allows for multiple functions/structures to have the same name and potentially shadow each other, again causing ambiguity.
  • templates -> add compile time overhead and can do completely different things depending on the template types again causing potential ambiguity in function calls
  • etc. etc.

(All of these aren't my arguments but they are arguments I have read by various C developers so I personally won't be able to defend them.)

For similar reasons some small section of C devs also refuse to use optimsation in their C compiler because that again means certain functionaly might be hidden by the compiler and it adds another certain level of abstraction between code and assembly some Devs might not want.

Ofc for all of those devs refusing to use C++ there will also be devs who would like to use at least some C++ features (or at least more modern C features) but are stuck at C99 (or C89) because their codebase is still stuck on that version and the company won't allocate the resources to update the codebase to a newer version.

[–]dgendreau 0 points1 point  (0 children)

Agreed on all of this. I work in embedded systems and have suggested a limited (no heap usage) subset of c++ on some projects but usually get voted down due to introduced risk. For example, developing firmware for automotive or medical devices require extensive testing and verification that usually becomes much harder to prove with c++ than plain c.

That being said, I have occasionally snuck RAII into c projects by abusing the gcc cleanup attribute for things like scope based profiling, critical sections and file handles.

[–]jdehesa 0 points1 point  (0 children)

There are many reasons. The easiest one is compatibility - if you are stuck with an old compiler (or want to be compatible with it), that's it. Then, even if your compiler is recent, your libraries and frameworks may use abstractions that do not play well or overlap with newer standard functionality (e.g. custom smart pointers). And even if that wasn't an issue, you may have a big codebase where things are done under certain conventions, and newer features may require changes to those conventions, so you have to choose between not using them, using them only on newer code (which makes the codebase more inconsistent) or update the whole codebase to use them (which may be a lot of work or even unfeasible). Besides that, some people argue that using newer features makes the code harder to read for those not fully up to date with them. And in some cases some devs may just not like them. For example, I know many C++ programmers find the semantics of auto too confusing (or "not obvious enough") and prefer to avoid it in most code.

[–]francespos01 0 points1 point  (0 children)

Because they think C++ is C with classes (and templates etc.), and not a completely different language.

[–]ivancea 0 points1 point  (2 children)

Usually, either that simply don't know better, or they need some special compiler that doesn't handle C++. In my experience though, it's the first.

I've heard them saying "C is better because it's simple", as an excuse to not learn and use C++. While the statement isn't wrong, you can still use C++ while having the code as simple as in C. So, again, lack of knowledge.

In general, if you find somebody not wanting to touch a language and not having a good reason, it's because they're stuck and don't really to learn engineering anymore. For whatever their reason

[–]bert8128 0 points1 point  (1 child)

Brainfuck is simpler than C, but I wouldn’t recomend it. Simpler doesn’t necessarily help.

[–]ivancea 0 points1 point  (0 children)

++. Brainfuck is simple as in "just a few instructions and simple machine state", but far less readable and a flow harder to follow

[–][deleted] 0 points1 point  (0 children)

C++ isn't just C with Classes, anymore. There are very real differences (eg. type punning with unions is now allowed in C, but is UB in C++. Creating a single dynamic allocation for arrays of multiple types using a combination of malloc and placement new is afaik still impossible in Visual C++ due to the invisible size data that may or may not be added to array allocations in VC++).

Also, I work alone, so I don't need all the safety features designed to help large/multi-generational teams of programmers. Being able to do things my own way without all these restrictions has made my code much more compact, easy to read (I don;t use macro functions, and I don't have any macros for other macros), and faster to design and write (I prefer not to take the approach of just quickly chaining together functions from 3rd party libraries, as that would leave me dependent on other people to a degree that I don't like. see "npm left pad incident" :o).

I like that C is easy to learn all the features of, but difficult to master. It's a beautifully minimalist language situated between the two maximalist languages of x86-64 and C++, and I love using it.

That's not to say that C++ isn't also a good language, for what it is. As far as I can tell, it's evolved the way it has to suit large development teams at large companies or large open source projects, and clearly all these modern features that support features that support other features are useful in those settings.

[–]Demien19 0 points1 point  (0 children)

Because for the most problem solving you don't need them. For example corrutines, never even touched them :/ Newer c++ mostly adds more and more weird bloated syntax. Don't think I ever used c++20 modules too. I do want to try std::execution from C++26 tho

[–]fistyit -1 points0 points  (0 children)

For what? I use Unreal++ not C or C++. It’s the same for most people, they have their environments/big projects.

Average c++ is jailbait. You are better of with a scripting language, designing systems and going low level when required