Javascript


14
Feb 07

Implementing threads in Javascript 1.7

Neil Mix has implemented support for threads in Javascript 1.7. To do this he used Python style generators, that were introduced in Javascript 1.7, and the trampolining technique.

If you are interested check out his post, the example and the implementation. The code only runs on Firefox 2 since it is the only browser that supports Javascript 1.7.


8
Mar 06

ReCSS bookmarklet

ReCSS is a very useful bookmarklet for people who develop dynamic web applications. When you click at ReCSS it reloads the CSS of the page you are currently viewing without reloading the page.


6
Dec 05

Prototype based object models

The Mozilla Developer Center has a great guide for Javascript. This guide provides one of the best explanations I’ve read on the Javascript object model and on prototype based object models in general.

Although I have only programed with languages that provide class based object models I believe that that prototype based object models are very easy to understand if you know the primitives of object oriented programming.

Prototype based object models are an interesting idea that suits very well with dynamic languages like Javascript. The only thing that I don’t really like is the syntax. For example creating a new “class” that inherits from an Employee “class” looks like this in Javascript:

function Manager () {
	this.reports = [];
}
Manager.prototype = new Employee;

And in Java:

public class Manager extends Employee {
   public Employee[] reports;
   public Manager () {
      this.reports = new Employee[0];
   }
}

I prefer the Java version because the whole definition is included in one syntactic unit (a class definition), instead two in Javascript (a function definition and an assignment).

If I am correct, Ruby (BTW I don’t know Ruby and Javascript) has a class based object model but also has most of the features of languages that are prototype based. For example in Ruby, you can add or modify, at runtime, methods of classes and instances.


2
Mar 05

Sarissa to the Rescue

Manos Batsis, one of my colleagues, has written an article at xml.com. The article’s title is Sarissa to the Rescue and it’s about Sarissa an OSS Javascript library, developed by Manos. Sarissa is a cross-browser library that wraps XMLHTTP (XMLHttpRequest on Mozilla) and various other XML APIs.

Now that Javascript and asynchronous web user interfaces are beginning to be more and more important in web application development I think that Sarissa might be a good solution for more portable Javascript code.

BTW did you know that Javascript has a unit testing framework (ECMAUnit) and a lint program (jslint).