Are you sure the case-label-fall-through has been its most controversial feature? It's so obscure (most people haven't heard of it) and rarely-used -- I'm guessing there are other aspects of C that are more controversial, or at the very least, more widely debated.
It's a cute hack and I'm sure it used to matter. I saw it used in djb's qmail. Is it worth even thinking about it? I don't know. I tend to not be a fan of these micro-optimizations on modern hardware.
When numerous instances of Duff's device were removed from the XFree86 Server in version 4.0, there was a notable improvement in performance.[3] Therefore, when considering using this code, it may be worth running a few benchmarks to verify that it actually is the fastest code on the target architecture, at the target optimization level, with the target compiler.
Optimization without testing is worse then pointless. It's premature and we know that's evil.
Or perhaps in this case it's more subtle: code becomes optimized for the wrong thing over time. For example the difference in optimization strategies between netburst pentium 4s and core 2 duos is staggering.
Great point: not only does optimization cost in understanding and system fragility but it can become stale over time and invisibly so.
If you're working on the application level, testing and segregating optimizations like this seems important. Systems level people would operate differently though ...
This is no longer useful as an optimization technique (loop unrolling makes things slower these days), but I believe the device get use in state machines, and libraries for making multithreading apps in a single process.
11 comments
[ 4.9 ms ] story [ 37.6 ms ] thread"This code forms some sort of argument in that debate, but I'm not sure whether it's for or against."
hack^2 - it's so brilliant and so ugly, even his author doesn't know which is more.
By the by, we've used this "feature" a fair bit in C and C++ for protothreads in small embedded systems: see http://blog.brush.co.nz/2008/07/protothreads/ and http://www.sics.se/~adam/pt/
Also, with the optimizations on modern chipsets it might not be immediately obvious which implementation will actually run faster.
When numerous instances of Duff's device were removed from the XFree86 Server in version 4.0, there was a notable improvement in performance.[3] Therefore, when considering using this code, it may be worth running a few benchmarks to verify that it actually is the fastest code on the target architecture, at the target optimization level, with the target compiler.
Optimization without testing is worse then pointless. It's premature and we know that's evil.
Great point: not only does optimization cost in understanding and system fragility but it can become stale over time and invisibly so.
If you're working on the application level, testing and segregating optimizations like this seems important. Systems level people would operate differently though ...
http://blog.fogus.me/2006/07/10/duff’s-device-walkthrough/
Including the shell still in use today http://doc.cat-v.org/plan_9/4th_edition/papers/rc best shell ever
And my favourite web browser : Mothra
http://en.wikipedia.org/wiki/Mothra_(web_browser)
while you argue over css / tables - try writing for a browser that has neither !