
Why do we use C still? - netbyte
Why do we use C still when there are other languages like Go or C++ or even D? BCPL and B were done away with so quickly, so why do we still use C in our modern society with languages that can do things a lot more efficiently?
======
angersock
Some reasons:

1\. Everyone has a C compiler, or can write a decent-enough one to support
their preferred environment.

2\. C is well tested and specified. Reading the standard isn't an exercise is
face melting (compare with, say, C++).

3\. As a systems language, C doesn't require a runtime library if not needed,
and this can be left out very easily (not the case with Go, D, or C++, as I'm
aware).

4\. C exposes easy trapdoors to the underlying machine (inline assembly,
pointers, etc.) that are very handy.

5\. C is usable by other languages, as its calling conventions are well
documented. This is why C is a preferred base language for things like OpenGL
bindings--it's easy to write Ruby, Pyhton, Java, etc. wrappers. This is in
sharp contrast to C++, which is brainfucked for things like symbol exports.

6\. A line of C is pretty obvious in what it does, when written correctly. You
can usually estimate what code it'll generate, barring #define hackery. C++
especially is bad at this.

~

C is still used because it doesn't do a lot, and it nails what it does do.

------
drallison
C is an adequate language (actually, more than adequate) with a large base of
skilled programmers. There is a long history of successful development. And
the developer base is aware of the warts that still remain in the language.

~~~
netbyte
But why use C when there are other Systems programming languages like Go, C++,
D, etc..

~~~
tonteldoos
One reason would be the massive existing codebases written in C (Linux kernel,
anyone?)...

~~~
paolopatron
We should all switch to Java/C#. It makes programming much much faster and
easier. <http://techiest.blogspot.com/>.

~~~
joezydeco
I work on embedded microcontrollers that have, at the _most_ , 16K of code
space and 512 bytes of RAM. I have a nice efficient optimizing C compiler that
creates object code nearly as tight as the local assembly language.

Do you think I would benefit from Java? Because I don't.

------
nnoitra
The only way to do elegant programming is with C. C is as perfect as
programming languages can get. The other languages that you named are just
more flawed than C. That's why.

~~~
frou_dh
Ah yes, I'm sure the Go designers in particular are ignorant about the pros
and cons of C </s>

------
khyryk
Generally, the good reasons you'll see for using C are lack of C++ compiler
availability and embedded programming.

The bad reasons tend to be variations of developer inertia and the inability
to decide which features of C++ ought to be used -- arguing against the STL
isn't a good argument against C++ as a whole.

~~~
netbyte
On Linux/Mac you have g++ and on Windows you have MinGW/Visual Studio

~~~
khyryk
There are many more operating systems out there.

------
lsiebert
C is currently the language I know best. I may therefore be biased. There are
multiple reasons why C is useful for system programming. Legacy code as others
have said. A huge community for support and maturity in tools. The fact that C
is very close to the bare metal of the system, which means that problems with
your code like memory leaks are most likely the programmer's fault , and can
thus be fixed by the programmer. It also isn't proprietary in any way. There
is no for profit company that controls the language.

C has disadvantages. But many of them are the result of its advantages.
Automated garbage collection is great, but garbage collection by hand tuning
code gets stuff that AGC may miss.

That said, I'm interested in picking up some of the other languages mentioned.

------
dubya
I use C as a language of last resort, as a sort of universal assembly
language. If I get a problem to the point that I know exactly what I want the
machine to do, but can't convince Haskell or Python or Java to do it and don't
have the time to research a proper solution, I can knock something out in C
that will be as fast as the machine can reasonably be expected to go. It
erases all of the questions about whether the compiler is doing something
mysterious to sabotage you.

------
melling
Because the Go compiler doesn't optimize good enough yet?

It seems like the one language that might replace C/C++ in many instances. My
favorite feature is the incredible compile times.

<http://golang.org/>

~~~
chc
Ironically, your favorite feature is also your least favorite feature: The
compiler is relatively simple and unambitious, resulting in fantastic compile
times. Once you start doing advanced analysis and multiple passes, you
suddenly aren't so speedy anymore.

------
Glowbox
Just search for 'C++ for kernel' on google. There are plenty of reasons. A
good answer can be found here: <http://stackoverflow.com/a/520355>

------
eli_gottlieb
We have discussed this: <http://news.ycombinator.com/item?id=3721142>

------
remixhacker
because C is perfection

~~~
checkers
Nope, Java/C# is PERFECTION. <http://techiest.blogspot.com/>.

