[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Why is C so popular?



On Wed, Aug 27, 2003 at 01:11:08AM -0500, Alex Malinovich wrote:

> The recent COBOL discussion has gotten me to thinking. Some languages
> seem to be very popular in some situations. C is easily the dominant
> language for most things Linux. So therein lies the question. Why,
> exactly, is C so popular? Especially in comparison to C++. I can't think
> of a single reason to use C instead of C++ for most of the coding that I
> would do. I generally only write user applications. I don't get anywhere
> near the kernel which is where I'd imagine most of the reason for using
> C comes in. Yet I see people writing 'modern' GUI applications and using
> C when I would think C++ would be a much better choice. Is there
> something that I'm missing? Something that C actually does better than
> C++ in regards to higher-level functions?

1) Most programmers know C already. C++ is a late-comer. It's easier to 
code in what you know than learn a new language and then code something.

2) C allows you to get down to "bare metal". This is important in a lot 
of applications, particularly in kernel work.

3) C++ is slower. Don't argue-- it is, particularly if you're using 
templates and such. It may not make much difference in user apps, but 
for kernel work, that's critical. And it take three times longer to 
compile anything of reasonable complexity in C++.

<rant>

4) C++ is unbelievably complex compared to C. Here's why I know this. I 
originally learned Dartmouth (mainframe) BASIC back in 1975. Later, I 
got a PC and learned Turbo Pascal. Then, I decided to learn a "real" 
programming language. (Pascal was designed to _teach_ programming.) So I 
learned C. This was after a survey of Fortran, COBOL, PL/1, APL, Algol 
and others. In the last few years, I switched over to C++. I have never 
taken so long to write programs in my entire life as when I was coding 
in C++. I spent far more time in design, and far more time debugging 
than I ever had in C. So I went back to C. Now my C code looks like 
a C++ programmer wrote it. But it's quicker to write.

Plus, I don't and never have liked the iostreams. They're clunky 
compared to printf() for most things. And exceptions are a pain in the 
butt, and no one seems to have a definitive answer on when to and when 
not to use them.

Classes I love and inheritance I liked. But the public/private/protected 
distinction in inherited classes is a pain to design and maintain. Plus 
vtables and virtual classes and functions. And friend classes/functions. 
C++ was supposed to allow a lot of code reuse. I haven't seen it, and I 
don't think any language will ever practically deliver it.

</rant>

Paul



Reply to: