Andy McKay

Mar 17, 2010

Learning Javascript


The other day in the hot tub and bar at DjangoSki there was a conversation about Javascript with Jereme and Brian. We all talked about this a bit and there were two salient points that came out of the discussion for me.

There's a whole generation of web developers who haven't really learned JavaScript. Generation being about the 5 years between "use a bit of javascript to validate a form" and Ajax. For those developers (myself included) there's rarely been a formal stage where people go off and learn JavaScript as a language.

If you were going to start building an app in Django, presumably the first thing you'd do is go and learn Python. When I started messing around with Rails, the first thing I did was spend a day or two at least figuring out how Ruby works. But I never really spent a similar amount of time with JavaScript. Instead it sort of went:

Me (circa 2000): "oh we could do that in JavaScript, it won't work for some people, but that would be cool, let's use Altavista to find a bit of code to do that".

That piece of code would then be mangled and repeated without necessarily understanding it all. You get to grips with the syntax and then something like prototyping comes along you learn a bit more. But all the language subtleties? I doubt they were commonly learnt.

Similarly, a big problem for me with JavaScript is the documentation. Let's say you want to do something simple, a string split. Compare these three searches for Ruby, Python and JavaScript. The Python and Perl searches land you directly on the official Python and Ruby docs. Those docs are of excellent quality and explain the point simply and clearly.

The JavaScript docs point to non-official sources of questionable quality. They all focus on what you can do in a browser and don't give you all the details. I normally keep a bookmark pointing to the Mozilla docs, which are excellent. There's nothing inherently wrong with those previous sources, but they aren't as good as they can be. Searching for closure's, prototyping and you'll get varying results.

These days with server side JavaScript frameworks, people are learning JavaScript so much earlier and actually learning the language, and that's a good thing. Of course, you can go read great books like this: JavaScript: The Good Parts and I hope people do.

Perhaps this is because there's a lack of a clear owner of JavaScript. Perhaps because for so long people have been linking to sites like w3schools, that their Page Rank is now unassailable. But it would really help JavaScript if there was one definitive documentation reference and source that we could use and learn from. That would make a huge difference to how the language is used.