views:

225

answers:

2

Possible Duplicate:
What’s the advantage of using C over C++ or is there one?

Hello all.

I was wondering why so many people continue to code in C when C++ has now been out for such a long time. What advantages/disadvantages are there??

I heard that there are differences (ie. advantages to C) in the way that linking is done, but I didn't hear anything more than that.

Can anyone enlighten me?

Thanks!

R.

+2  A: 

For some small embedded chips, there is a C compiler but no C++ compiler. Also, some people are afraid of progress. And some people maintain huge codebases that aren't typesafe and won't compile with the C++ compiler.

Ben Voigt
'Some people are afraid of progress' -really? C++ is a great language but I don't think choosing C indicates an inflexible mindset. Pick the tool to suit the job IMO.
zebrabox
+1 "some people are afraid of progress" - not that i agree, just that im sitting here smiling and waiting to see the comments :)
Aran Mulholland
I didn't say that "afraid of progress" is the only reason for anyone to stick with C. But it sure is the primary reason for some.
Ben Voigt
There are plenty of people who look negatively at C++ for various features that many people would consider progress and desirable - exceptions would be a good example. So, from the perspective of many non-C users, you could say that C programmers appear to be afraid of change and progress. Of course, you could say much the same about C++ and programmers of other languages such as Java or C#. So, some of it is simply a matter of what you're used to using. Many people don't like change, regardless of whether it's better or worse.
Jonathan M Davis
@Ben Voigt - Ten years ago, I'd have agreed 100%. Not so sure now, though I'm sure there are still some. Of course, there are a few developers going back to C from C++
zebrabox
Man! Sometimes i hate this...uhm..progress so much!
kudor gyozo
+1  A: 

This one is sure to get a lot of opinionated responses. :-)

C:

  1. does only and exactly what you want, without side-effects
  2. is even closer to the CPU
  3. is often available on systems where c++ is not
  4. is very close to other languages used for low-level interactions, like ORCAD and other chip-burning systems
  5. is often the basis for a lot of legacy code that won't compile under c++

C++:

  1. has powerful object orientation
  2. has templates
  3. has more recent optimizations in the compiler, put together by the world smartest programmers
  4. has more high-level libraries already available, i.e. the std libs and even higher-level things

If I missed something really obvious, I'm sure there will be no end to the people who will correct me. :-)

eruciform
"without side-effects"? Nope. C most definitely does exactly what you want - side-effects included. And C is no closer to the CPU than C++ is.
greyfade
@greyfade: i don't want to get into the holy war here, i'm only pointing out that it has far less side effects than almost any other modern language. everything has a side effect, even setting a variable, depending on if it's `volatile` or even `register` or not.
eruciform