There’s a contrary school which is more pedantic: “We should have just afew primitives we can de-sugar our spec to; we can lambda code everything.That’s how people should write anyway because that’s how I think ofthings” or, “That’s the best way to think of things.” It’s very reductionisticand it’s not for everybody. Obviously one way to do your own mental proofsystem is to reduce things, to subset languages. Subsetting is powerful. Butto say everyone has to program in this sort of minuscule subset, that’s notusable.

Seibel: In some of the discussion about ES4, you cited Guy Steele’s paper,“Growing a Language.” Speaking as a Lisper, to me the take-away from thatpaper was, step one, put a macro system in your language. Then all of thisspecial sugar goes away.

Eich: There are two big problems, obviously. C syntax means that you havea much harder time than with s-expression, so you have to define yourASTs and we’re going to have to standardize them and that’s going to be apain. Then there’s the other problem, which is hygiene is still not quiteunderstood. Dave Herman, who’s working with us is doing his thesis—orwas last I checked—on a kind of logic for proving soundness for hygiene,which is, I hope, beneficial. Because we will get to macros.

I said this to Doug Crockford a couple years ago when he had me speak atYahoo! I started talking about the sugar that I was enthusiastic about. Hesaid, “Gee, maybe we should do a macro system first,” and I said, “No,because then we’ll take nine years.” At the time there was a real riskpolitically that Microsoft was just not going to cooperate. They came backinto ECMA after being asleep and coasting. The new guy, who was fromHyderabad, was very enthusiastic and said, “Yes, we will put the CLR intoIE8 and JScript.net will be our new implementation of web JavaScript.” But Ithink his enthusiasm went upstairs and then he got told, “No, that’s notwhat we’re doing.” So it led to the great revolt and splitting the committee.

So we were concerned that if we went off to do macros we were doingresearch, and if we were doing research we were not going to haveMicrosoft engaged and we were not going to be putting competitivepressure on them. So macros have had to wait. I’m fine with that so long aswe do the right automated grammar checks and we do make sure we canrecast all of the sugar as macros when we have macros. But in the meantimethere’s no reason to starve the users for sugar. It doesn’t rot their teethand it helps them avoid mistakes.

Seibel: Back in 1995, what other languages influenced your original designof JavaScript?

Eich: Self was big, mainly because of the papers that Dave Ungar had justwritten. I never played with any Self code, but I was just inspired by them. Ilike Smalltalk and here was somebody taking one idea applied to Smalltalk,which was prototype-based delegation—multiple prototypes unlikeJavaScript—and just running with it as hard as they could. That was inspiringto me because there was both good compiler, VM-level engineering and, Ithought, good language design.

Because, like Crock and others, I think you do want to simplify and I do likethe languages designers who take fewer primitives and see how far they cango. I think there’s been kind of a Stockholm syndrome with JavaScript: “Oh,it only does what it does because Microsoft stopped letting it improve, sowhy should we want better syntax; it’s actually a virtue to go lambda-codeeverything.” But that Stockholm syndrome aside, and Microsoft stagnatingthe Web aside, language design can do well to take a kernel idea or two andpush them hard.

Seibel: Were you aware of NewtonScript at all?

Eich: Only after the fact did someone point it out to me and I realized,“Hey, they’ve got something like our scope chain in their parent link andour single prototype.” I think it was convergent evolution based on Self.And the DOM event handlers—part of the influence there was HyperTalkand Atkinson’s HyperCard. So I was looking not only at Self and Scheme,but there were these onFoo event handlers in HyperTalk, and that is what Idid for the DOM onClick and so on.

One more positive influence, and this is kind of embarrassing, was awk. Imean, I was an old Unix hacker and Perl was out, but I was still using awkfor various chores. And I could’ve called these first-class functions anything,but I called them “function” mainly because of awk. An eight-letterkeyword—it’s kind of heavy, but there it is.

Seibel: At least it wasn’t “lambda”—JavaScript would’ve been doomedfrom the start. Were there any languages that negatively influencedJavaScript, in the sense of, “I don’t want to do that”?

Eich: It was such a rush job that I wasn’t, like, worried about, “Oh, I can’tmake it into Ada or Common Lisp.” Java was in some ways a negativeinfluence. I both had to make it look like Java and not let in those crazythings like having a distinction between primitive types and objects. Also, Ididn’t want to have anything classy. So I swerved from that and it caused meto look at Self and do prototypes.

Seibel: Did you ever consider making a language more closely related toJava—take Java and make some kind of simple subset; get rid of theprimitive types and other needless complexities?

Eich: There was some pressure from management to make the syntax looklike Java. There was also some pressure to make it not too big, becauseafter all, people should use Java if they’re doing any real programming; this isjust Java’s dumb little brother.

Seibel: So you wanted to be like Java, but not too much.

Eich: Not too much. If I put classes in, I’d be in big trouble. Not that I reallyhad time to, but that would’ve been a no-no.

Seibel: Coming back to the present, ES4 has been officially abandoned andeveryone is now working toward ES-Harmony, which will somehowcombine ES3.1 with ideas from ES4? Do you think that’s ultimately a gooddecision?

Eich: Doug was a little triumphalist in first blog post: “We’ve won. Thedevil has been vanquished.” I had a joke slide I gave in London a year agoabout Doug being Gandalf on the bridge, at Khazad-dûm facing down theES4rog. He liked that a lot. It was the first time I poked fun at him becausehe’s a little serious sometimes when he gets on this topic and he liked it alot. He can be the hero; ES4 wasn’t quite the monster.

ES4 looks, in retrospect, too big. But we need to be practical aboutstandards. We can’t just say all you need are lambdas—Alonzo Churchproved it, so we’re not going to add any more to the language. That’s thesort of impoverished approach that tries to make everybody into an expertand it will not work on the large number of programmers out there whohave been mistrained in these Java schools. JavaScript will fall someday butwe can keep evolving it and keep it competitive in both the theoretical andthe practical sense if we don’t try to hold back the sugar for purity’s sake.

It needs to evolve to solve the problems that programmers face.Programmers can solve some of them by writing their own libraryabstractions. But the ability to write abstractions in the language is limitedwithout the extensions—you can’t write getters and setters. You can’tmake objects look native, have properties turn into code; things like that.And you can’t solve some of these security problems in an implicit orautomated way.

Seibel: In general do you feel like languages are getting better over time?

Eich: I think so, yeah. Maybe we’re entering the second golden age; there’smore interest in languages and more language creation. We talk aboutprogramming: we need to keep practicing the craft—it’s like writing ormusic. But the language that you use—the tonal system—matters too.Language matters. So we should be evolving programming languages; weshouldn’t be sitting still. Because the Web demands compatibility, JavaScriptmay have to sit still too much. But we shouldn’t get stuck by that; we shouldeither make a better JavaScript, even if it doesn’t replace the one on theWeb, or we should move beyond that.


Перейти на страницу:
Изменить размер шрифта: