3 ms·
C has quite a few features, and the language design is pretty arbitrary. (Yes, it's often based on (old) hardware, but then hardware design is pretty arbitrary.
by tikhonj 13y ago
C has quite a few features, and the language design is pretty arbitrary. (Yes, it's often based on (old) hardware, but then hardware design is pretty arbitrary.)
I haven't used Clojure much, so I'll mostly talk about Scheme. I suspect the two are similar in all important ways.
If you look at the matter critically, you'll find that Scheme (and, I suspect, Clojure) are actually simpler and smaller languages than C. Neither has nearly as much syntax. There is far less undefined behavior. C has way more corner cases than Scheme: there are a ton of C quizzes out there which basically nobody can solve; I couldn't imagine much of that for Scheme. You just have to memorize the relatively obscure rules for what types get automatically coerced to each other.
C has whole classes of hard-to-solve bugs that other languages simply do not. Bus errors, segmentation faults, buffer overflows... All the exposed low-level details obscure the meaning of the code; unless they're important to your application, they just make your code harder to follow.
Moreover, common C idioms (some of which are just workarounds for missing features) make code much harder to follow than it should be. Thanks to the use of out parameters, you never really know where the result from a function is, without reading the documentation. I recently wrote some code that depended on ioctl--that single function sometimes returned the result as the return value and sometimes modified fields inside the struct you passed into it! Hard to follow is an understatement. Errors are signalled as integers instead of some semantically meaningful data type.
Of all the languages I know, C is the one that makes it the hardest to write non-trivial programs that are easily read by others. I suspect you're just making the common mistake of confusing familiarity for some sort of innate quality.
- sramsay 13y agoI don't really mean to defend C (though I rather like it, despite its many flaws). I only meant to point out the wisdom (which I recall reading in the K&R) of this idea that "taking away" features might make it easier to read and debug -- and maybe even write -- programs. In fact, Scheme is a sterling example of that very principle (relative to, say, Common Lisp, and I would argue of Clojure as well). I agree with you about Scheme, which is a very minimalistic, wonderful, eminently readable, "one way to do it" language. But Clojure has something that Scheme doesn't: a massive set of libraries. C has that as well. That, of course, is a different subject entirely . . .
- comex 13y agoAt least it's not C++, where out parameters are often written as references, which appear exactly the same as normal arguments, rather than usually having a telltale &. :)