Thursday, April 13, 2006

Javascript glorified

Ever since Google brought back Javascript into fashion with Gmail, Google Suggest, Google Earth and My Google, everyone is swearing by AJAX. Even Microsoft has followed suit with Windows Live and MSN Virtual Earth. Someone at google saw beyond all the bad publicity of Javascript, although gurus like Douglas Crockford have known its power for long.

Inspite of its design flaws, Javascript is a very innovative programming language with the syntax of C and Java and the power of Scheme and Python.

1. Javascript treats functions as first class objects, they may be passed to a function, be a member of an object, put inside a hashtable. They can even have arbitrary number of arguments and can also contain other functions.

2. Javscript objects are dynamic. Its possible to add members and functions at runtime because the objects are essentially a collection of name value pairs.

3. Javascript can be used for inheritance and private members. Inheritance is implemented through the inherits function and private members through closures. Closure means that an inner function has access to variables and parameters of the outer function.

4. Functional programming in javascript is possible through currying, the technique of passing one function to another as argument. It also supports recursion.

Javscript had been long renegated to the level of a toy language only suitable for showing annoying popups. With the modern browsers increasingly supporting the ECMAScript standard, and the support for XmlHttp object, it has emerged as a great way to build cross browser interactive applications.

There are a large number of AJAX frameworks in almost every language used for web applications. These frameworks provide server side controls and Javascript libraries for easing the task of building AJAX based applications. There are also some great Javascript toolkits like Dojo, MochiKit, Prototype/Scriptaculous and the Yahoo! UI Library. Google Web Toolkit is another toolkit which takes the novel approach of generating Javascript code from Java source written using the libraries provided.

Open source AJAX Frameworks in .NET
  • MagicAJAX.NET - Handles AJAX calls like postbacks and needs very little code.
  • ATLAS - The official framework developed by Microsoft. Contains javascript libraries for UI components, AJAX calls and cross browser support.
  • AJAX.Net

Here is a nice comparison of many frameworks.

Open source AJAX Frameworks in Java

Of course there are many more.

AJAX Frameworks in PHP

Ruby on Rails also has an AJAX extension.

As pointed out by Kinshuk, Javascript needs to be treated with respect as far as debugging is concerned because of its dynamic nature and loose typing. There are some tools available for this like JSLint (you can think of it as checkstyle for Javscript), apart from Microsoft Script Debugger for IE and Venkman for Mozilla. Frameworks for logging and unit testing are already there. Maybe its time for an exclusive IDE for javascript.

0 Comments:

Post a Comment

<< Home