Sticking to the script

Douglas Crockford: “Java was a colossal failure…JavaScript is succeeding because it works.”


Tom Wießeckel speaks to JavaScript god Douglas Crockford on Google Dart and why your mom doesn’t care what JavaScript is.

For Java developers, JavaScript used to be a much-maligned territory. They‘ve just never got on with each other, despite similarnames. But as the years have worn on, the shunned language is starting to stand up for itself.

Our colleague from German-language PHP Magazin, Tom Wießeckel, spoke to JavaScript god Douglas Crockford recently and we thought it was well worth hearing the guru’s views on JavaScript, jQuery and CoffeeScript.

Tom Wießeckel: I’m here with Douglas Crockford at JavaScript Days 2012 in Cologne. Mr. Crockford, please introduce yourself!

Douglas Crockford: I’m Douglas Crockford from Yahoo!

Wießeckel: You’re well known as a JavaScript super hero and you just held your keynote at the JavaScript Days. Can you summarize it?

Crockford: JavaScript is becoming an important language, but it’s a misunderstood language. So in order to use it well it’s necessary to have specific information and I am trying to help provide that to people.

Wießeckel: So why is that misunderstood?

Crockford: A lot of it is because of its strange history. You know, the fact that it is called JavaScript. It has nothing to do with Java. It is almost like it was intentional that the name was created to confuse people.

Wießeckel: You said something about the good parts and the bad parts. Which one is the worst part?

Crockford: The worst part is JavaScript’s reliance and global variables. The security problems that we see in the browser are rooted in that mistake.

Wießeckel: After your keynote there was a question about CoffeeScript. Can you repeat?

Crockford: CoffeeScript is a new language which compiles into JavaScript. It uses JavaScript as an execution language. CoffeeScript is beautiful and elegant and minimal – it’s a lovely little language. I wish JavaScript worked a lot more like CoffeeScript. I don’t recommend using CoffeeScript in production because it’s still experimental and you don’t want to be doing experiments in production. But for your own experiments or for hobby projects it’s a good choice.

Wießeckel: So the advantage of CoffeeScript is in the syntax?

Crockford: That is the only advantage. The semantics of CoffeeScript are exactly the same as in JavaScript. There is nothing you can do in CoffeeScript that you can’t do in JavaScript. It’s just that for many things the notations is more convenient.

Wießeckel: What about jQuery? It’s used by a lot of developers because it’s easy to understand. What is your opinion about jQuery?

Crockford: jQuery is great. jQuery is a library that runs on top of the Document Object Model which is the API that the browser provides to JavaScript. The Document Object Model is terrible. It is one of the worst APIs I ever imagined. JavaScript is such a powerful language that a relatively small library can turn the DOM into something that’s useful. jQuery does that. YUI from Yahoo! I think doesn’t even do a better job by doing the same thing. My advice to anybody is: use one of these libraries. Don’t ever try to talk to the Document Object Model yourself because it’s just pain and misery. But using a good library it becomes something that is pleasant and productive.

Wießeckel: And you try to bring JavaScript to the server side. Is this the right approach?

Crockford: Yes, absolutely. There are lots of benefits that come from it. One is that JavaScript is actually a good language once you understand it. And so having JavaScript available on the server means you only have to be fluent in one language. That’s a nice simplification. But there is also the benefit that you can design your code so that it can run on either end of the network. And that can give you a lot of flexibility in dealing with new platforms and old platforms.

Wießeckel: There are some different engines, V8 and JägerMonkey. What is your favourite?

Crockford: It doesn’t matter. JavaScript is a surprisingly portable language. There is not much difference between any the JavaScript engines. So they’re all good. Microsoft surprisingly is very good as well. Any of them work and they all work about the same and they’re all great. That is one of the nice things about JavaScript.

Wießeckel: You mentioned Microsoft. There are some efforts from Microsoft regarding Windows 8 bringing web developers to the desktop. Is this a good approach?

Crockford: Probably (laughs).

Wießeckel: OK. But there are some restrictions like that you can’t use the built-in camera on the iPad. Are these the right restrictions?

Crockford: Yes, so part of the problem we have is that we have never had a proper security model in any of the platforms that we use. And as the platforms get more intimate with people that becomes a bigger and bigger problem. So it’s not just being able to clear out your file directory now. It can now spy on you. You can recall your conversations, you can show your picture and transmit it to anybody on the web without you knowing about it. That’s something to worry about. JavaScript as practiced in the browser comes close you to providing a secure environment for applications and any other application delivery system.

It’s still not right, but it’s better than everything else. That seems to be a better place to start than any of the other things. Something that you see in other platforms is a “blame the victim” security model. We’ll ask the user a question that the user cannot possibly understand or answer correctly. And then when things go wrong it’s the user’s fault for having agreed to this. That’s not a security model, that’s just…stupid! The browser doesn’t do that. Now the price of that is that the browser is limited in some ways and we need to get smarter about how we reduce those limitations. But it seems to be the right way to start.

Wießeckel: There are some new competitors like Google Dart. Why?

Crockford: I don’t know. You have to ask someone from Google. It doesn’t make any sense to me. There are lots of problems with JavaScript and JavaScript should not be the last programming language. I would like to encourage lots of experimentation in new languages. Programming languages are the most important tool available to programmers. We still haven’t gotten it right and clearly JavaScript didn’t get it right.

So we need to keep doing those experiments, we need to keep practicing. It takes us about 20 years to make an advance in programming languages, so we need to get going faster than that. So I’m very happy to see the experiment. The thing that is problematic with Google is they seem to already claiming victory and they haven’t finished the design yet. Dart doesn’t make sense to me, I don’t know what Google is trying to do there. Dart is worth the experiment and Google should be applauded. It may be a plot to replace JavaScript but it seems unlikely.

Wießeckel: A few years ago JavaScript was considered as bad…

Crockford: Still considered that.

Wießeckel: …by the consumer side.

Crockford: Not by consumers. Consumers have no knowledge of the programming systems and the devices. Your mom doesn’t know what JavaScript is or care.

Wießeckel: Well, that’s right. The papers wrote that JavaScript is bad and you have to deactivate it to disable it. What happened in the last few years that JavaScript is now the big thing?

Crockford: It was Ajax. In 2001, Gartner predicted that the web was about to die the same way that WAIS and Gopher had died. It was going to be replaced by the Ex-Internet and a lot of people believed them, including Microsoft. So Microsoft expanded the IE team and started working on the next internet, whatever this was going to be.

So they were really surprised in 2005 when Jesse James Garrett published the paper about Ajax. Suddenly Microsoft was blindsided by the web – the second time. And it has taken off since then. Probably it’s because of the security things that the browser got right. There is no scary dialog that faces the user when they get a web application. Nothing saying “do you trust these guys who you don’t know, who they are or will you get them these capabilities that you don’t know what they are?”

The web doesn’t do that, it just works. And that made it much easier to deliver applications than any other platform can do. I think that’s what caused it to take off. The other thing was that everything else failed. There were lots of attempts to try to capture the web or to replace the web. Adobe has made several attempts at that, as has Microsoft. Google is trying to do it now. And so far all those have failed. Java was supposed to rule the web. Java was a colossal failure. Java then tried to take over in consumer electronics and other places and it hasn’t worked very well either. In the phone platform, they have tried literally everything. They have tried proprietary things, they have tried to do open things, they have done the Java and it all failed.

And so now they’re doing the last thing that worked which is the web, JavaScript. They are trying that on the phone and that looks like it’s going to work. That’s not what anybody wanted or predicted, but that’s sort of the way it’s turning out. JavaScript is succeeding because it works. And getting stuff that just works turns out to be surprisingly hard and uncommon.

Wießeckel: So the future from mobile is the web?

Crockford: Seems so. It’s not settled out yet, there is competition. The app stores are trying to capture the web, so there is a point of monopoly that all applications have to go through. Which is sort of counter to the web philosophy which is “everybody has an equal standing”.

Will that form win? Ultimately I think the open form wins just because people benefit from the freedom of having an application delivery system that can deliver applications from everybody. But there are forces who were trying to close it, including the DRM forces, so we will see how it plays out and will hope that it stays open.

Wießeckel: So Mozilla’s Boot To Gecko project [since renamed FirefoxOS] is the right attempt towards the mobile world/universe? Is this the next big thing?

Crockford: The thing that seems to be winning in the mobile space is WebKit. I don’t know why but it seems to be the thing that has been most adopted. Mozilla has done some very good stuff, WebKit has done some very good stuff. I‘m hoping that stays a competitive environment. I think it’s better that there not be one winner. So I hope that Mozilla can stay strong.

Wießeckel: So is there a chance that WebKit is the next EE6? Or EE5? Because everyone writes now developing for WebKit.

Crockford: One of the dilemmas of the Web is that it doesn’t come from a single company: it doesn’t come from Adobe, it doesn’t come from Microsoft, it doesn’t come from Sun or Oracle. Developers have to work with all the different variations of the platform, and the number of those seems to be growing rather than shrinking.

That is a hardship on developers, to the extent to that the W3C standards are inadequate. Seriously inadequate. That makes life more difficult for the developers. But I don’t want to go the other way and say “OK there’s just going to be one platform from now on” because having the diversity of platforms I think has been a healthy thing and it would be bad to lose that.

Wießeckel: Just one more question: You mentioned the good things about JavaScript JSLint. How can JSLint help me be a better developer?

Crockford: JSLint is smarter than I am at JavaScript and it is probably smarter than you, too. So as painful as it is: Follow its advice. It is trying to help you.

Wießeckel: Mr. Crockford, thank you very much.

Inline Feedbacks
View all comments