Day 2: @media ajax November 2007

@media ajax 2007 A previous post summarized day 1 of @media ajax which looked at general issues of JavaScript on the web.

This post is a summary of day 2, a more technical look at JavaScript and its future.

JavaScript 2 and The Open Web

By Brendan Eich, the inventor of JavaScript.

Good talk on some details about JavaScript 2 which he (and others) have been blogging about recently. He also briefly talked about the “open web” (WHATWG, W3C, etc) versus a “closed one” (Adobe AIR, Microsoft’s Silverlight, etc), which he has also blogged about previously.

He also talked about some of the language features being proposed for JavaScript 2 which would make it look much more object-oriented (namespaces, classes, packages, generics etc). He said the main drivers for JavaScript 2 were better security, better APIs and better programming language support.

Why are these needed? He felt users deserved more support in the language. He lamented that the combination of Microsoft’s domination combined with Netscape’s self-destruction had made the web stagnate. JavaScript hasn’t really changed that much in those years. As web apps were getting more common place, some of these new features could be more important.

A point he and others have made is that while there are better languages out there, most have not really been used as widely as JavaScript, especially from the kind of wide user base that JavaScript has, so the perceived weaknesses of JavaScript can also be its strengths (something Douglas Crockford looked into further — more below!).

Update 1: he has posted slides together with notes and commentary. A useful read.

Update 2: Ajaxian has a decent look at a specific aspect of his talk: JS code bloat and JS2’s improvement, and the performance benefits of JITting.

(Here’s a decent set of slides on the new features being considered in JavaScript 2, actually by John Resig, the next speaker!)

Building Interactive Prototypes with jQuery

By John Resig, inventor of jQuery.

I think this was one of my most favourite sessions, but it should not have been! It should not have been because I have been using the excellent jQuery library for about two or three months now, So I should have found most of this talk familiar and therefore not of that much interest.

Instead, I was really impressed with the quality of the session. John was showing the features of jQuery with code examples, and throughout his talk, people from the audience would ask if it was possible to do various things, and he was always able to answer in a polite, positive way, constantly changing his code on the fly in front of everyone. Many of the seemingly complex things that were being asked were implemented not by one line of code, but one word or two!

The talk wasn’t really about building prototypes, though, more about just using it. (And it isn’t just for prototyping; it is being used in a lot of big places.)

If you haven’t seen it, check out the jQuery site and try it out. It’s really growing on me. While I initially found it weird, it is amazingly powerful, simple, efficient and productive. Its quite different to most of the other popular JavaScript frameworks, especially in how it queries the DOM so efficiently and with hardly any code! I have removed anywhere from 40-60% of some of my JavaScript code when I have used it and I hope to use it more.

Update: Slides for the JQuery presentation are now available.

Metaprogramming JavaScript

By Dan Webb, a JavaScript expert and part of the core Prototype JavaScript framework team

I had bumped into him the day before during a session break, and he was saying he was nervous about his talk with so many experts as speakers!

But he did a great job explaining a decent topic: meta programming; programming JavaScript to augment itself at run time (e.g. to overcome deficiencies such as IE’s limited event handling in an efficient manner). Rather than describe the things he talked about, have a look at his metaprogramming slides.

Dojo 1.0: Great Experiences For Everyone

By Alex Russell, project lead for the Dojo Toolkit

Instead of talking about Dojo, Alex Russell decided to talk about the state of the web in general — which was a great talk!

Interesting points included that the emergence of Adobe’s Flex, Microsoft Silverlight, etc signaled a sign of problems for the web; that it may not be evolving much, that it may be hitting the walls of complexity.

He felt that even JSF/JSP (JavaServer Faces and JavaServer Pages) could be a sign of this pain (these technologies use a component-based approach to develop web apps, similar to ASP.NET, so I’d add that to his concern). His point was that Java developers appear to be afraid of getting their hands dirty with HTML, JavaScript etc, preferring these components to do it instead. Instead, developers do need to care about markup. These same criticisms apply, in my opinion, to ASP.NET. (During the Q & A session just after his talk, a lot of people voiced concerns about Microsoft’s dominance slowing down change.)

JavaScript: The Good Parts

By Douglas Crockford, Architect at Yahoo! Inc, a well known JavaScript guru who also came up with JSON!

Perhaps one of the two foremost people on JavaScript, this talk was interesting, because Crockford, despite his knowledge of JavaScript is known for being against the proposed ECMAScript 4 specification (which would be implemented as JavaScript 2). He feels that while the additions proposed are interesting and good, it makes the language quite different, and so should be called something other than JavaScript (else he seems to be for it, from what I can tell!).

He has written previously that, “JavaScript is a sloppy language, but inside it there is an elegant, better language”, and that was a point he was trying to make again, quite effectively, I thought.

This talk looked at a number of things problematic with the language and also what worked so well (e.g. lambda functions, closures, the functional programming aspects of JavaScript, the dynamic and flexible nature of the language, etc.)

One annoying (even dangerous) mistake with the JavaScript language he pointed out was semi-colon insertion, whereby if you omitted the “;” at the end of a statement, the parser would add it in for you. While this may have been kinda understandable at the time JavaScript came out (to help non-programmers, etc), it had an impact even on code convention:

While in other languages, coding standard/style is typically a matter of preference, here was an example where opening the curly brace on the same line is a MUST for JavaScript:

return
{
    name : value;
}

Is NOT the same as

return {
    name : value;
}

In the first example, because of semi colon insertion, the interpreter will actually do this:

return <strong>;</strong>
{
    name : value;
}

(It will add a semi colon after return!)

Bizarre, but rests the debate on where to open your curly brace for JavaScript!!

He mentioned the tool he wrote a few years ago, JSLint, that checks your JavaScript much like Lint does for C etc (it will catch the above issue, amongst many other things!). Will be worth looking into further and possibly integrating it into our build processes (which they do with Yahoo’s YUI, for example).

He also made the controversial statement in the panel discussion that followed, that CSS was shit, which didn’t go down too well! (Though he also said he is not a designer, or something like that!)

The other concern he raised was that IE 6 in particular was holding back the advancement of JavaScript; that changes were hard to introduce because of the prevalence of this poor quality browser.

Discussion Panel

Moderated by Jeremy Keith (the guy who coined the term — and authored a popular book by the same name — “DOM Scripting”)

Brenden Eich, Stuart Langridge, Alex Russell, and Douglas Crockford were on the panel answering questions raised by the audience. Most were around JavaScript’s future, what frameworks people were using, and concerns about Microsoft’s domination of the web (its negative impact on the web developer community and whether it mattered any more or not), etc. Some good topics and debates!

Conclusion

A really good day; lots of ideas and details. Some of the powerful aspects of JavaScript were shown in simple terms.

The last @media conference got me excited enough to finally start this blog. This one gives me a sense of urgency to replace some of my JavaScript code with jQuery 🙂