Hello.
AFAIKnew, people used to choose C over C++ as a programming language
for their projects because it posses better performance and execution
speed, but after I read this article <a herf="
http://unthought.net/c++/
c_vs_c++.htmle">(C versus C++)</a> I noticed that C++ beats C in
benchmarking so, why does any programmer on earth still use/learn/
teach C instead of C++?
You must not have read the article, or you're here trolling. It was an
RB-tree implemented in C++ vs. a hash table implemented in C. At the
bottom of the article, it clearly states:
"But this benchmark is no good for the purpose of the "C versus C++"
argument - it's two completely different approaches that yield
completely different results, for reasons that have nothing to do with
the languages used."
There's not, actually, a difference in performance between the two.
They're both compiled to native code, frequently by a compiler that
handles both languages at once, using the same logic for compilation.
Check out the code your compiler generates. A performance difference
between the two languages wouldn't actually make any sense. Any byte
code you produce from C++ can be produced almost identically with C,
except it will take you a heck of a lot longer to express it in C. The
only big difference in "performance" is your algorithms, as shown in
the article.
I guess you missed that part?
Shouldn't C++ have replaced C? even when developing an OS kernel or
such sensitive software.
You're welcome to port the existing Linux kernel (for example), to C+
+. While you're working on it, you can reflect on why nobody else has
done it yet.
Most of the time the reasons are that you are maintaining code written
in C or you are on a platform that nobody has bothered to write a C++
compiler for (e.g. PIC). A lot of programmers raised on C will stick
to C because it's what they know, with logic like "well if you're not
going to use the features of C++, you might as well use C". An
experienced C programmer has techniques that he's comfortable with and
simply doesn't see a need to switch. I guess that's reasonable, who
knows (or cares)?
C++ also took a bit of time to become accepted because early (e.g. mid
90's) compilers were strange and quirky. This also probably left a bad
taste in the mouth of those who attempted to learn it at the time.
Most C++ compilers are mature enough now that it's no longer an issue.
HTH, and next time read the article.
Jason