Общо показвания

май 18, 2011

The evolution of Javascript

During the weekend I ended up cleaning up a mess at my parents' house and I dug in a pile of old books. One of those books was 'Programming with JavaScript' I have bought in 2001. Out of curiosity I sat for a little while and turned the pages to see what was the level of language description in such a book circa 2001.

The author is left unnamed (actually the authorship is signed as 'collective work by SoftPress team).

The rudimentary level of the language description is not surprising, nor the fact that constructor function methods as defined as global functions and then assigned to the object (which is at least a bad practice). What surprises me is the development suggested for javascript. Pretty much all of the examples lead to one exclusive usage for the language and it is form validation. Even today, ten years later no one relies on javascript for form validation just because anyone can skip it, even 10 years old. Why then it was so accented in this small book and why it was suggested that this is the only practical usage of the language?

I can only guess that the engines in IE5/Netscape3/4 were so slow it really was the only practical usage of the language.

Today it took me only 5 minutes to convert a slider application from jQuery to Mootools. Complete with animation and all. It is working in Firefox 3, 3.5, 3.6, 4, Chrome 7-12, Internet Explorer 7,8 and 9. I wonder, how much time will it take to write the same thing, working across browsers, 10 years ago?

I also remembered that I saw my first javascript driven animation in the browser around that time, it was working only in IE and it was timeout driven style altering algorithm (basically the same thing we do today) and it was written very expressively with one main function in global scope and several function inside the main function scope, it was using closures and it was using native type augmentation, which I think was very advances for that age.

Anyways, don't buy this book, it is worthless these days. One advantage it has over the modern books is that is explains in details the CGI metaphor very clearly and provides details on the internal working of a program using this interface, something you can learn today but not in a javascript book!

Talking of books I took a brief (but complete) look at Pro JavaScript with MooTools. Unfortunately there is nothing 'Pro' in the book itself. It starts with too in depth introduction of the types in javascript, somewhat deep look at the functions and objects and then complex code is thrown at the reader without even explaining it all, just 'the interesting and important' parts of it, which I find rude and unprofessional, a code example should ALWAYS be explained in details and the whole of it, otherwise it is waste of book space to use examples if just a single row in it will be important and explained. Other than that the book only covers the class system and briefly mentions the different mixin types in mootools, something you can read and understand from the docs and it takes only 5 rows, not a whole chapter. After that it gets boring until the end of the book, Element, Style and other parts of the toolkit are depicted in unnecessary details, details that one can easily fond in the documentation. Also there is nothing advanced in the book itself and I don;t see how any advanced technique can be learned from it, providing there is not a single example demonstrating such technique. All in all the book is not worth reading if you do not know javascript, it is not meant to be a learning tool for javascript. However if you know javascript and can read English you should not read it either as it does not provide any new information regarding neither javascript nor mootools. Actually the only interesting part in the whole book is the mention and explanation of the 'parent' property of the extended 'classes'. However this can be read on so many places online, so the book is rendered completely useless. Oh and by the way the last chapter is also completely insane, birds eyes look at the server side javascript programing without any real life examples nor advices. Really annoying.

So, how did the language evolved? Well, the language did not, the browser evolved. And today it is a really great tool as well as really really great development platform, I encourage you to learn javascript and use a solid framework ( regardless of what you read online (that the micro frameworks are the future) they are not - most of those (like 90%) are not working correctly across browsers, the top class libraries are tested and do work! ) like jQuery or MooTools (I am not sure which to recommend because I do not speak jquery, I only speak pure JavaScript and MooTools) and just explore the possibilities of a modern browser. Yes, it is true that your application might not work in IE or Opera or some old Safari browser. But hey! I wrote a music player in 20 minutes in chrome!! So can you! And endless other applications! And it is really easy! For fun and for profit, javascript is your friend and is here to stay! So take the time and learn a bit about it.
Публикуване на коментар