Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isn't saying "C/C++" wrong? [closed]

Tags:

c++

c

I've seen a lot of questions around that use improperly the expression "C/C++". The reasons in my opinion are:

  • Newbie C and C++ programmers probably don't understand the difference between the two languages.
  • People don't really care about it since they want a generic, quick and "dirty" answer

While C/C++ could sometimes be interpreted as "either C or C++", I think it's a big error. C and C++ offer different approaches to programming, and even if C code can be easily implemented into C++ programs I think that referring to two separate languages with that single expression ( C/C++ ) is wrong.

It's true that some questions can be considered either as C or C++ ones, anyway. What do you think about it?


2 Answers

C/C++ is a holdout from the early days of C++, where they were much more similar than they were today. It's something that wasn't really wrong at first, but is getting more-so all the time.

The basic structure is similar enough that most simple questions do still work between the two, though. There is an entire Wikipedia article on this topic: http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B

The biggest fallacy that comes from this is that because someone is well-versed in C, they will be equally good at C++.

like image 65
Steve Klabnik Avatar answered Sep 15 '25 03:09

Steve Klabnik


Please remember that the original implementations of C++ were simply as a pre-compiler that output C code for the 'real' compiler. All C++ concepts can be manually coded (but not compiler-enforced) in plain C.

"C/C++" is also valid when referring to compilers and other language/programming tools. Virtually every C++ compiler available will compile either - and are thus referred to as "C/C++" compilers. Most have options on whether to treat .C and .CPP files based on the extension, or compile all of them as C or all of them as C++.

Also note that mixing C and C++ source in a single compiler project was possible from the very first C/C++ compiler. This is probably the key factor in blurring the line between the languages.

Many language/programming tools that are created for C++ also work on C because the language syntax is virtually identical. Many language tools have separate Java, C#, Python versions - but they have a single "C/C++" version that works for C and C++ due to the strong similarities.

like image 31
2 revs, 2 users 92%Jeff B Avatar answered Sep 15 '25 05:09

2 revs, 2 users 92%Jeff B