by hellofunk · 9y ago · 0 comments
I think C is still so pervasive for 2 simple reasons (I might be wrong):
1) It's a small language. Compared to many newer languages (Swift, modern C++, old C++, Objective-C, Java), it's quite tiny. The language itself can be learned in short time. (Which is deceptive, because properly using what you have learned takes longer than a short time).
2) It's fast. It's just direct memory access, direct and explicit hardware manipulation. And whether justified or not, there is a very large portion of the developer community that remains obsessed with speed. I see it all the time, even when speed isn't not going to matter enough to justify C. I often see people going way out of their way, making their work much more time-consuming, because of their everlasting pursuit of writing the fastest damn program they possibly can.
Problem is you have the complete opposite on the other side, folks who don't even think about speed (usually because their development machine is quite powerful and so they don't notice). Thus we end up with programs that are resource hogs and slow that have no good reason to be.
There is a middle ground to be found I think.
I've never felt that way with Python, JS, Ruby, Java, C++ or any of the other languages I've used. They are at least 10X more complex in terms of primitives and non-trivial interactions.
I love C for its warts and all, but you should treat it like a tamed wild animal.
Actually there are a few other languages that are great for debugging runtime code behavior; Lua comes to mind.
I also find C really handy for parsing binary formats (ASN1, Ms EMF...), parsing binary stuff in Python for example feels miserable. However, for manipulation string based formats (xml, json, yaml), C is quite miserable, even with the help of libs like libjson-c or libxml2.
And to be fair, even for parsing binary formats, C can be quite unforgiving. I still have some traumatic souvenirs from the first time I ran American Fuzzy Lop on my EMF to SVG converter... (by the way, I love the afl logo: https://upload.wikimedia.org/wikipedia/commons/f/fa/AFL_Fuzz...)
You can treat C as a small language, if you don't have to work with anyone else.
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
That's up from 95 in C90, a factor of 2 not 3 in 20 years.
http://read.pudn.com/downloads133/doc/565041/ANSI_ISO%2B9899...
You can treat Rust as a useful language as long as you don't need to get work done. I rather like C11. I would have liked Rust, I tried, if they'd have known when to say no or if they valued sparseness for its readability because it reads like C+++:
const USAGE: &'static str = "usage: blah blah";
By contrast, I like what seL4 did with C. They wrote in C and proved in Isabelle. const USAGE = "usage: blah blah";
The RHS has sufficient type information, does it not? After all, if this were a let USAGE = ... inside a function, that would be sufficient.(I don't find this particular bit a deal-breaker though; thus far, I quite like Rust.)
const USAGE: &str = "usage: blah blah";
Compare it to the equivalent in C: const char *USAGE = "usage: blah blah";The C11 standard (ISO/IEC 9899:2011) adds support for threading and atomics, and adds IEC 60559 specifications in its annex.
Yet, the language specification part of ISO/IEC 9899:2011 is less than 180 pages, and the remaining pages are dedicated to libraries and the annex, which on itself takes over 200 pages.
Ah, compared with its early 1980s competition (Pascal, Modula-2, BASIC), C was quite lavishly equipped with library functions.
Now, get off my lawn, kids!
Therefore, technically, C++ has slower compilation time but potential for faster runtime.