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?
Some reasons:<p>1. Everyone has a C compiler, or can write a decent-enough one to support their preferred environment.<p>2. C is well tested and specified. Reading the standard isn't an exercise is face melting (compare with, say, C++).<p>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).<p>4. C exposes easy trapdoors to the underlying machine (inline assembly, pointers, etc.) that are very handy.<p>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.<p>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.<p>~<p>C is still used because it doesn't do a lot, and it nails what it does do.
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.
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.
Generally, the good reasons you'll see for using C are lack of C++ compiler availability and embedded programming.<p>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.
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.<p>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.<p>That said, I'm interested in picking up some of the other languages mentioned.
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.
Because the Go compiler doesn't optimize good enough yet?<p>It seems like the one language that might replace C/C++ in many instances. My favorite feature is the incredible compile times.<p><a href="http://golang.org/" rel="nofollow">http://golang.org/</a>
Just search for 'C++ for kernel' on google. There are plenty of reasons. A good answer can be found here: <a href="http://stackoverflow.com/a/520355" rel="nofollow">http://stackoverflow.com/a/520355</a>