E4X and the DOM

Reading through tonyg’s recent post I came across something i haven’t yet seen in use – inline XML within Javascript code. E4X, it seems, has landed. It is now available by default in Firefox and Rhino – other implementation will surely follow. E4X, shorthand for ECMAScript for XML is a nice language extension to Javascript…

Subclassing in JavaScript, part 1

What's the right way to create a subclass in JavaScript? Wrong question, say the JavaScript advocates. JavaScript isn't one of those fuddy-duddy old class-based languages. It's something much more exciting: a prototype-based language! So remember, when you work with JavaScript, remember never to refer to "classes", because JavaScript doesn't have them, and it only shows you're stuck in the old way of thinking. I'm sure that these sentiments have done enormous harm to the reputations of real prototype-based languages, so let me banish it right here. JavaScript is not a prototype based language; it most closely resembles a class-based language, but all its mechanisms for doing the work of a class-based language are horribly broken, which is why its advocates try to pretend it's something else.

Icing snapshot 20060721

I’ve uploaded a snapshot of Icing, including its dependent xml.pipeline library. We internally use a piece of software called use.jar (David Ireland’s Component Manager) to manage dependencies on external components, but it’s not required for this interim release: you’ll need to have a Tomcat v4.1.30 installation available instead. Newer versions of Tomcat probably work, but…

QuickChecking imperative code

[Haskell](http://www.haskell.org)'s [QuickCheck](http://www.cs.chalmers.se/~rjmh/QuickCheck/) is a very neat tool for automated testing. One specifies *properties* that one would like a program to satisfy, and *generators* for test data, usually involving some form of randomisation. QuickCheck then uses the generators to produce test cases and check the properties against them. The original QuickCheck was designed to test *purely functional* code only. However, the project I am working on contains a fair amount of imperative code, most of it performing operations on a database. Is it possible to employ QuickCheck for testing this code?

Updateable views in PostgreSQL

In one of our projects I needed to do some processing on data stored in a PostgreSQL database. The data contains timestamps but the processing requires time to be represented as seconds since the epoch. What to do? Generally, date&time processing is major headache. There are just way too many opportunities to get things wrong.…

A Rhino at the Seaside?

A couple of weeks ago I picked up Chris Double’s server-side javascript implementation, which uses the Mozilla Project’s Rhino Javascript environment Jetty to provide a Javascript-controlled Java Servlet webserver. The code’s available both for browsing and for darcs download: darcs get https://www.lshift.net/~tonyg/javascript-server/ After adding support for Jetty’s SessionHandler class to Chris’s example.js, I downloaded the…

HTML Email is hard to get right

For a recent project, we developed support for sending automatically-generated HTML emails. Now, most people do this by including a message body with MIME-type text/html. For extra points, sometimes there’s also a text/plain part alongside the HTML in a multipart/alternative container. The problem with doing things this way is that you can’t include any images…

How to provide ‘search this site’ functionality?

We wanted to add a ‘search this site’ function to a client’s website but did not have the time to study the [200+ existing ways of doing this](http://www.searchtools.com/tools/tools.html). Perhaps using the “Microsoft Indexing Service” (or “Index Server”, IS), which fits well with the software running the existing site (IIS), can easily be extended to search…

Why there’s been no news regarding Icing

It’s the usual story: there’ve been other demands on my time (projects here at LShift, among many other things), and so the release of Icing has suffered. The good news is that I’ve been given some time to package it up and make it available, and barring unexpected interruptions, I ought to have something presentable…

Linux VServer: Cheap and Easy Virtualisation

Whilst projects like [Xen](http://www.cl.cam.ac.uk/Research/SRG/netos/xen/) and new hardware extensions to CPUs from Intel and AMD allow multiple OSes to run on the same machine at the same time, for me, there are currently few cases where I need this. I work under Linux and all I need is virtualisation to run multiple Linuxes at the same…