Martin Fowler on Closures
Martin Fowler’s talking about closures on his blog. I was rather disappointed that he didn’t bring up JavaScript when he was talking about it.
Why do I mention it, besides the fact that I like JS as a language? It’s because it’s given far less credit than it deserves: JavaScript more than any language is the one that has done the most to popularise and spread closures as a concept. As Eric Lippert noted, “Waldemar Horwat—who was at one time the lead Javascript developer at AOL-Time-Warner-Netscape—once told me that he considered Javascript to be just another syntax for Common Lisp. I’m pretty sure he was being serious; Waldemar’s a hard core language guy and a heck of a square dancer to boot.”
Closures are what allow OOP in JS, and prototype-based OO like that of Dylan and JS is without a doubt far more powerful and flexible than class-based OO. Ah, the terrible lightness of being misunderstood.
- JavaScript: The World’s Most Misunderstood Programming Language
- Echewing prototypes in favour of classes seems wrong, even counterproductive, to me, but this guy thinks it’s a good idea. What’s even worse is that he seems to think uninferred types are a good thing, though maybe I’m misreading him.
- JavaScript on Wikipaedia