Google Tech Talk by Douglas Crockford on ‘JavaScript: The Good Parts’

April 15, 2009

I just watched the most amazing talk on javaScript ever. It was, of course, given by Douglas Crockford, on Google Tech Talks. I got really amazed by this talk, maybe because I already develop dynamic Web Sites for some time now.

Don’t get me wrong, I stil think javascript sucks A WHOLE LOT, but the talk was great. I really, really advise you to watch it to the end.

He begins talking about the bad parts of javascript and blames the browsers for almost all the sucking. Actually, it’s true when he says that “Considering the last years and how the development of web browsers happened, we deserved a language that was far, far worse than javascript”, but that simply does not mean javascript is great.

I mean, if you can do as he says “avoid the bad parts, and the good parts will really be good and worthwhile”, JavaScript is great. It gives you all the freedom a developer could want, and most of the power too. But this is not the reality for most people. Let’s agree on something Ben Collins-Sussman said: Most of the software industry is made up of 80% programmers (I know this is oversimplified, but it is good for my point here). That said, JavaScript sucks as a programming language for anyone that works with this kind of programmer (if you don’t work at Fog Creek, Google or some top hiring company, chances are you do).

It’s unbelievable the kind of crap people can write in JavaScript, and even more unbelievable how creative crap they can write. Douglas Crackford actually surprised me with some piece of cross browser code. Are you ready for it?

return

{

o: false

};

is interpreted as:

  • line 1: return;

Here, javascript just dumbly inserts a semicolon at the end of the statement. (This means the return statement is over)

  • line 2: {

This is, indeed, very natural. You’re opening a block. JavaScript gives you no warning on unreachable code.

  • line 3: o: false;

This is an easy one. “o” is, obviously(eheh), a label. It is labeling the statement “false”. A semicolon is added to this one too. But you already knew it, right?

  • line 4: };

No problem here, of course :). After the end of the block, an empty statement.

So, nothing is returned at all, and you will only know it happened some time later, but will probably never know why.

Well, I have no complaints on the loosely typing, ore equality operations. But I really prefer, when I don’t know whom I’ll be working with, to deal with strict typing and not-so-free languages. Even though, I’m totally gonna read ‘JavaScript: The Good Parts’ on my quest to sucking less every year.

Edit:

The correct code to write on the example would be:

return {

o: false

};

Yes, this is all.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: