On 05/01/12 12:09 PM, Liam Proven wrote:
...
Closures: again, I have yet to find a readable, comprehensible
explanation of what they are, what they are good for, why they are
powerful and what strengths they confer onto a programming language.
Another approachable, practical discussion of closures, with
applications, is in Douglas Crockford's "JavaScript - The Good Parts".
In fact it's hard to do anything half interesting in JavaScript
*without* using closures. Many people including Crockford say this is
the #1 thing JavaScript got right (and if Eich had had more time and
leeway, he'd have incorporated more of Scheme's power).
From Coders at Work* (Siebel):
Peter Seibel:
-------------
Let's go back to those ten days when you implemented the original
JavaScript. I know that at some point someone had turned you on to
Abelson and Sussman and your original idea was to put Scheme in the browser.
Brendan Eich:
-------------
The immediate concern at Netscape was that it must look like Java.
People have done Algol-like syntaxes for Lisp but I didn't have time to
take a Scheme core so I ended up doing it all directly and that meant I
could make the same mistakes that others made.
I didn't have total dynamic scope, like Stallman insisted was somehow
important for Emacs and infested Elisp with. JavaScript has mostly
lexical scope [like Scheme and Common Lisp] with some oddness to
it---there are a few loopholes that are pretty much dynamic: the global
object, the with statement, eval. But it's not like dollar variables in
Perl before my or upvar, uplevel in Tcl. The '90s was full of that---it
was trendy.
But I didn't stick to Scheme and it was because of the rushing. ...
Seibel:
-------
So basically now people make a top-level function to get a namespace.
Eich:
-----
Yeah. You see people have a function and they call it right away. It
gives them a safe environment to bind in, private variables. Doug's a
big champion of this. It was not totally unknown to the Schemers and
Lispers but a log of JavaScript people had to learn it and Doug and
others have done a valuable service by teaching them. It's not like
you're getting everybody to be high-quality Scheme programmers,
unfortunately, but to some extent they've succeeded, so people now do
understand more functional idioms at some patterny level, not
necessarily at a deep level.
...
Seibel:
-------
In some of the discussions about ES4, you cited Guy Steele's paper,
"Growing a Language". Speaking as a Lisper, to me the take-away from
that was, step one, put a macro system in your language. Then all of
this special sugar goes away.
Eich:
-----
There are two big problems, obviously. C syntax means you have a much
harder time than with S-expressions, so you have to define your ASTs and
were going to have to standardise them and that's going to be a pain. ...
*
http://www.codersatwork.com/brendan-eich.html