Topic: The "C is Efficient" Language Fallacy

http://scienceblogs.com/goodmath/2006/1 … age_fa.php

So C isn't the next fastest lang after asm ? sad

Keep Smiling

Re: The "C is Efficient" Language Fallacy

No, but that's not new, is it? There's this website out there that has benchmarks for like 50 different languages and 50 different problems. While C is usually in the top group, it is not the fastest. Iirc, ocaml was?

Oh, btw: I contest your assumption that asm is faster than C. I'm pretty sure that for any non-trivial program, even a compiler as bad as gcc will be able to produce a faster program from C code than what you get when writing the program in assembler (well, say, for 99.9% of programmers).

Re: The "C is Efficient" Language Fallacy

Yeah, I agree. It all depends on the programmer. But almost all langs get converted to asm, isn't it ? So it must be faster ? Yeah, we need to optimize the code, which most of the programmers don't bother to do. And the compiler/interpreter generates a better optimized code. But I hope that best asm programmers can beat any level of optimization with so called HLLs.

Keep Smiling

Re: The "C is Efficient" Language Fallacy

No. ASM programmers can beat the compiler in specific cases, like when they make use of new commands (SSE3, etc). In the general purpose case, I don't think the compiler can be beat. This is mostly because (x86) CPUs these days are very complex: they're superscalar, different commands have different runtimes, some commands hog certain parts of the CPU and stall other commands. There are also caching effects that can be optimized for. The compiler can deal with this complexity relatively easily; it comes down to a large set of processor-specific rules that it can apply, consistently, throughout the code.

Now, I'm not saying that it's not humanly possible to beat the compiler, after all, compilers are (still wink ) written by humans too. I'm saying that the fraction of programmers that can actually do it is so small that it can be ignored (still considering the general purpose case here). And those that can do it, will probably never actually do it, since it's just too much work.

I have a feeling that you've never actually written assembler code yourself. Why don't you try it, and write some medium complexity program that does some calculation in assembler, and C, and see how the two versions compare.

Re: The "C is Efficient" Language Fallacy

No, I have. But without understanding a single line of it. neutral Its was on dos (MASM i think) for my CS. But they were fast although it required more work.

Keep Smiling

Re: The "C is Efficient" Language Fallacy

A long time back I was writting code to run on early generation smart cards and n the end gave up with the C and wrote the 8048 assembler myself for 2 reasons, firstly it was far more compact and I only had 1K to play with (yes I mean 1K) and secondly the assembler was always faster

"My spelling is Wobbly.  It's good spelling but it Wobbles, and the letters  get in the wrong places." A. A. Milne (1882-1958)