News for hackers. Stuff that matters.
Re:The "C is Efficient" Language Fallacy by stcredzero on Monday May 04, 2009 @05:41PM (#593134)
Right. C is a power tool. You can use it to create something blindingly fast. You can also use it to create something dog slow. I've seen Smalltalk programs outperform C programs. I know of an instance where a coworker benchmarked a C implementation of a block cipher vs. a Smalltalk implementation, and the Smalltalk ran 3% faster. Why? Naive manual memory management in the C implementation.
Re:The "C is Efficient" Language Fallacy by tptacek on Monday May 04, 2009 @05:43PM (#593139)
Another classic HLL vs. C argument: the anecdotal slow C program. Clearly, of these, there are many great examples. Unfortunately, it's a crappy argument, because there are also a zillion incredibly slow HLL programs.
Re:The "C is Efficient" Language Fallacy by noaharc on Monday May 04, 2009 @06:14PM (#593190)
I don't think stcredzero meant that as an argument that C is worse than HLL -- it was just a warning that, as with any tool, it can be improperly used.
Re:The "C is Efficient" Language Fallacy by stcredzero on Monday May 04, 2009 @06:33PM (#593222)
I'm certainly not against C. I've just used C to write an embedded controller for doing real-time mixing of PWM control signals and laser gyroscope data for a model tilt-wing aircraft. (Which should be able to convert between horizontal and vertical modes in-flight.) I wouldn't use Smalltalk for that. (Yet. If I had 10X more CPU to burn, maybe.) Likewise, I'm not going to write my next Commodities Trading app in C.
Re:The "C is Efficient" Language Fallacy by gaius on Tuesday May 05, 2009 @02:37AM (#593757)
That is a false dilemma tho'. No-one in the Python world has anything invested in a 100% Python solution to anything. Doing the compute-intensive bits in C is in fact expected and encouraged! The same is true in the Tcl camp. Maybe some HLL communities (Java?) like to be "pure" but I've not ever encountered that.
Re:The "C is Efficient" Language Fallacy by robin_reala on Tuesday May 05, 2009 @07:55AM (#593950)
No-one in the Python world has anything invested in a 100% Python solution to anything

PyPy? http://codespeak.net/pypy/dist/pypy/doc/

Re:The "C is Efficient" Language Fallacy by gaius on Wednesday May 06, 2009 @05:30AM (#595473)
That's not for production use, tho'.
Re:The "C is Efficient" Language Fallacy by wlievens on Tuesday May 05, 2009 @05:35AM (#593868)
Java communities typically favor portability (and easy deployment) over what you can gain in terms of speed. A lot of libraries/frameworks actually even advertise themselves as "100% pure java", whereas one might expect "expensive bits optimized in C" as attractive as well (but you rarely see it).
Re:The "C is Efficient" Language Fallacy by brl on Tuesday May 05, 2009 @02:33PM (#594495)
> whereas one might expect "expensive bits optimized in C"

There is no important difference in performance between C and Java according to http://shootout.alioth.debian.org/

Re:The "C is Efficient" Language Fallacy by wlievens on Wednesday May 06, 2009 @03:48AM (#595398)
That all depends on the kind of code, of course.
Re:The "C is Efficient" Language Fallacy by tptacek on Tuesday May 05, 2009 @03:01AM (#593772)
I agree. I like writing my goop in Ruby. But that's not what the article is about.
Re:The "C is Efficient" Language Fallacy by sfphotoarts on Monday May 04, 2009 @11:42PM (#593569)
I'd like to see the c code to support this, it's very hard to imagine anything you could do this wrong in something like a block cipher that would ever make it as slow as smalltalk. I'm sorry, I just don't buy this...
Re:The "C is Efficient" Language Fallacy by stcredzero on Tuesday May 05, 2009 @08:36AM (#593980)
The C DLL was one of RSA Data Securities reference implementations from about a decade back. The Smalltalk guy could ask the VM implementor for goodies -- like 32 bit and 64 bit bit-arrays and various primitive operations on them.

So long as you keep an entire algorithm in one method, and restrict yourself to certain optimized operations, the resulting JIT-ed code will look like it was produced by an unoptimized C compiler. There will be no Smalltalk message sends. (This approach is a bit fragile, though, since you have to have esoteric knowledge to maintain code like that and keep the same level of optimization. Most of the time, you'd just implement a speed-critical operation like this as a DLL in C to be called from Smalltalk. Smalltalk/X has a different approach -- you just inline C code in your Smalltalk method.)

Combine that with naive memory management in the C code, and you have C code that loses a benchmark. Mind you, that was bad C code -- reference code only has to be correct, not fast.

"Smalltalk is Slow" usually a sign of ignorance or trolling. For lots of problem domains, the advanced commercial Smalltalk VMs are pretty darn fast.

Re:The "C is Efficient" Language Fallacy by tptacek on Tuesday May 05, 2009 @11:25AM (#594229)
I'm not saying Smalltalk is slow, but I've worked with rsaref since the mid-90s, and I don't remember a block cipher routine in it that was horribly slow due to allocation.
Re:The "C is Efficient" Language Fallacy by stcredzero on Tuesday May 05, 2009 @05:25PM (#594773)
So instead of Highly Optimized Smalltalk (with VM implementor help) = Horrible C, we have Highly Optimized Smalltalk (with VM implementor help) = Average C.

I can live with that.

Re:The "C is Efficient" Language Fallacy by tptacek on Tuesday May 05, 2009 @11:31PM (#595141)
It is easy to sell me on Smalltalk vs. C. Just not on performance. =)