341 karma · joined January 18, 2011
;; excuse my possibly hybrid notation
(defun cons (car cdr)
(lambda (m)
(if (eq? m 'car) car
(if (eq? m 'cdr) cdr
nil))))
(defun car (obj) (obj 'car))
(defun cdr (obj) (obj 'cdr))Even sadder because the same effect can be achieved cleanly (and "optimizably")by using as "switch" followed by a "while".
But generally it's hard to publish code. Mostly you have to write a paper, and the paper usually has to have an element of novelty. Can't just be "I built this compiler!"
Lot of LLVM talks seem to be tutorials, which is another approach, and of course very useful.
Or you can do like Adrian Sampson and many others, and publish it via a blog. You won't get tenure that way, but most people don't care.
I first heard this idea, in a slightly different form, from Vickie Markstein (part of IBM's 801 team) in early '88. She suggested using this idea as an acid test for optimizations. For example, if the compiler with value numbering compiled itself faster than the compiler without value numbering, then she'd say value numbering was worthwhile.
Given the organization of the 801 team, it's possible the idea was due to John Cocke or one of the other members. Doesn't matter much, I think.
I've never had the opportunity to test optimizations using this approach, but I think it would be a fun way to approach the question of adding optimizations to something fast & simple like the Oberon compiler, the Plan 9 compiler, or the Go compiler.
Indeed, for a _system_, like Oberon or Plan 9, where everything is compiled with the same compiler, we could go a step further and try adding the optimization, rebuilding everything, then timing the new compiler. That way any benefits the optimization brought to handling I/O and such would be properly credited and we'd (hopefully) see a steady improvement in the programmer's experience.
Preston
An alternative I've seen used on campus is a big Maglight. I'll agree that it represents a step that's usually less violent that reach for a gun, but when I read of police striking a woman "21 times with a baton", I have a hard time.
"Baton" is just a euphemism that papers over extreme violence.
TRAC is lots of fun. I read about it in Nelson's book, Computer Lib/Dreams, when I was a freshman at Illinois. That spring, my Dad bought an Altair and I wrote a version of Trac for it, in assembly. Had support for bignum arithmetic, in ASCII :-)
Later, when I learned about tail recursion, I was happy to figure out that my implementation was indeed properly tail recursive.