Atlas · Details
Language Trickery and EJB
Author’s note
A detailed article on macros and lexical closures, trying to make them comprehensible to Java programmers, and probably mostly failing.
AI Notes
Written in October 2004 as a long reply to an Amazon colleague who'd
dismissed closures as "language specific trickery," the piece opens
with the friendliest thought experiment in the Drunken canon: imagine
Java without a for keyword, where printing even numbers
from 2 to 100 requires a LoopObject — setStartingValue(2),
setCounterIncrement(2), a callback. Everyone agrees the
imaginary code is awful. From that baseline Steve turns it around:
the for-loop is a service rendered to the programmer,
the same kind of service an EJB renders to its callers, except the
syntax forces the API to be used correctly. Compilers can check that
you initialized the counter; they can't check that you ever called
setStartingValue at all. So you want some syntax — but
not syntax for everything, because that way lies Perl. The slope from
that question runs through Java's clumsy closures (every anonymous
inner class with a final capture is a closure in
disguise), on to macros, then to Erlang's syntax for distributed computing (a
million lines of Erlang doing what would be 20 million lines of buggy
C++), then to the broader puzzle: Java programmers will stay up all
night reading Hibernate manuals but recoil from the word
map, even when the new syntax is worth a 10× or 100×
productivity gain.
One of the cleanest first statements of what becomes the Drunken-era's central preoccupation — that syntax is not cosmetic, and the industry's allergy to it is what's holding it back. Two years later the same argument is sharpened into Execution in the Kingdom of Nouns; here it's still patient, still talking to the EJB people on their own terms.
Related listings
-
2005
Scheming Is Believing
The same argument, four months later, having walked all the way down the slope. Language Trickery says 'a little syntax is good'; Scheming says 'and the syntax that lets you build more syntax is the only kind that scales.'
-
2004
Tour de Babel
Same season — Steve's pan-language tour at Amazon. Tour de Babel is the survey; Language Trickery is one of its arguments isolated and pressed into a working example.
-
2006
Execution in the Kingdom of Nouns
Two years on, the same complaint sharpened to a knife. Language Trickery is patient with EJB; Kingdom of Nouns has lost patience entirely.