Monday, November 14, 2011

Javascript: The language everyone wishes it wasn't

Having just gotten to watching the Crockford videos (well, 2 of 5 so far) due to the video's intimidating length (~7.5 hours in total), I'll say its definitely interesting and worth viewing. If you haven't yet seen them, they are easy to find on youtube (yahoo theater versions seem to have been moved or taken down).

The first part about the history of programing was quite interesting, but fairly inconsequential and can be skipped if you want to save yourself an hour and a half of time. It can be found here.

The second part really starts getting into the workings of javascript and its relationship to the browser. Crockford outlines many advantages and disadvantages to javascript, almost all of which I already knew, but he also outlined the ES5 standard, which had many awesome things that I think javascript sorely needed. The video can be found here.

Of the pros he discussed, the only thing that particularly sticks out is the sheer dynamism of the language, mostly given to it through its use of prototypical inheritance. This dynamism allows for a program to undergo a drastic change in structure or scope with less tedious refactoring involved when compared to other languages.

Of the cons he discussed, they all seem to stem from a simple lack of forethought on the part of the language's developers. Many of the issues came from the developers trying to make the language accessible to beginners, while they did manage to succeed in this, it resulted in many pitfalls that still plague the language today. One that stuck out to me was the NaN variable, as I didn't know that NaN does not equal NaN and that NaN is subsequently toxic to all numeric operations there after that use the NaN. Seems like a fairly useless implementation; I recall Objective C (terrible language btw...) having a similar situation with NaN, but I am unsure if NaN didn't equal NaN in that language.

The part I found most interesting was the new things that were being introduced in the ES5 standard. I was unaware of this functionality, but much of it seems very useful and would address many of the problems I have with javascript. A short document on the ES5 changes can be found here. These changes seem to primarily introduce ways to give greater control over the objects you create and use in javascript, giving you the ability to more rigidly and accurately structure your objects which in turn allows you to more accurately structure your scripts. I am not sure as of right now how widely supported these are across all the browsers out there, but I would hope that it is a fully supported standard by now, as I would like make use of these features in my future scripts.

I'm gonna finish this out by expressing an opinion I've had about javascript for sometime now... What holds javascript back is its attempt to be accessible and easy to learn. This is great for beginners but will seriously hold back the development of a more complex and intricate system that requires a large complicated infrastructure and mass resources to work. I think it may be in the interest of developers to create a new language, keep javascript around for compatibility and for beginners to code on, but give us the option of a cleaner, more robust language that we can work on for larger, more complicated systems that run in the browser. If the browser really is the future platform, the thing we are heading towards for all of our entertainment and media like some suggest, then a better implemented language is a must, because it will take far too long to improve and restructure javascript as to where it is the language we all need it to be.

No comments:

Post a Comment