The “C Is Efficient” Language Fallacy (2006)
scienceblogs.com
The “C Is Efficient” Language Fallacy (2006)
1–10 of 106 posts
Re: The “C Is Efficient” Language Fallacy (2006)
#2Re: The “C Is Efficient” Language Fallacy (2006)
#3What am I missing?
Re: The “C Is Efficient” Language Fallacy (2006)
#4The author wrote a naive loop in a bunch of languages, and, got a faster result in OCaml (0.3 sec) than in C(0.8 sec). Right, but the code was a totally naive loop:
for (int i=0; i The fact that C has a bunch of libraries for vectorization of such code, or that there are million compiler directives that can speed that code a lot is somehow missing from the article.
So, the conclusion is that a compiled OCaml code is twice as fast as a naively written unoptimized loop in C.
Re: The “C Is Efficient” Language Fallacy (2006)
#5What I appreciate about C in particular is that it seems harder to "program by accident" than it is in most languages. C was my first language. After I learned C, I programmed in a higher level language for a while later before discovering that its runtime threw exceptions on 'array subscript out of bounds.' I discovered it by looking over someone else's shoulder in a lab. I realized then that I had just learned not to do that because C was so unforgiving.
We can argue whether the kind of discipline of thought that you gain from that experience is good or even useful today, but I suspect it is. It's different from learning how to do mental math in a world full of calculators - that's just raw mental exercise.
Re: The “C Is Efficient” Language Fallacy (2006)
#6Re: The “C Is Efficient” Language Fallacy (2006)
#7The claim that Fortran arrays are easier for the compiler to optimise than raw pointers in C/C++ may well be true. But I imagine that there has been progress on compiler technologies to address auto-vectorisation in C/C++ since the post was written (and since C99, C has the restrict keyword too). Can anyone comment?
Re: The “C Is Efficient” Language Fallacy (2006)
#8While I agree with the author about the main topic, the actual content does not illustrate the point well. The author wrote a naive loop in a bunch of languages, and, got a faster result in OCaml (0.3 sec) than in C(0.8 sec). Right, but the code was a totally naive loop: for (int i=0; i The fact that C has a bunch of libraries for vectorization of such code, or that there are million compiler directives that can spee…
I recently learned that Knuth created a virtual instruction set (MMIX) specifically because he found that comparing algorithms with high level languages was too prone to problems. Using a direct instruction set that executes on a virtual machine means that algorithm analysis can focus on the algorithm.
Now, there is something to be said for languages which produce code that is nearly as efficient as the most efficient code you can produce with C, especially if it's easier to write it. But that's not the author's point.
Re: The “C Is Efficient” Language Fallacy (2006)
#9While I agree with the author about the main topic, the actual content does not illustrate the point well. The author wrote a naive loop in a bunch of languages, and, got a faster result in OCaml (0.3 sec) than in C(0.8 sec). Right, but the code was a totally naive loop: for (int i=0; i The fact that C has a bunch of libraries for vectorization of such code, or that there are million compiler directives that can spee…
Re: The “C Is Efficient” Language Fallacy (2006)
#10Noting that the semantics of array access semi-equate to pointer dereference is well beside the point.
This fellow's "for" loop: for (int i=0; i shows that you don't even have to have unrestricted pointer access to have bounds violations - what's "y[i-2]" when i==0?
'C' is not for everybody. It's a systems programming language. As the space of activities related to computers grows, there's no good reason to continue to erect a strawman about the language and set fire to it.