Language Trickery and EJB — cover art: a fox stage-magician in a frock coat at a small velvet-draped table, pulling a tidy clockwork loop on a brass ribbon out of a top hat, while behind him an absurdly over-engineered wooden cabinet labelled by its many handles and levers stands neglected in the wings. 🤓

2004 · Drunken Blog Rants · Rant

“Syntax is automation! It's code generation, in a very literal sense. Everyone loves automation and code generation, since they can save you reams and reams of potentially long and buggy code. So you'd think folks wouldn't mind a little syntax, peppered with some semantics, added into their language.”
— From Language Trickery and EJB, October 2004
Read the essay

© 2004 Steve Yegge. Originally published at Drunken Blog Rants.

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