It’s time for Haskell in the Web browser.

JavaScript has been around for over a decade now. During that time, we’ve seen it implemented by every major browser vendor, and thus we’ve seen it become widely used by many Web sites. We’ve even seen JavaScript used in non-Web applications and uses.

But JavaScript has some pretty serious drawbacks. The performance of the various JavaScript interpreters embedded in the popular Web browsers has always been less than ideal. And being interpreted, it often becomes more difficult to detect syntax errors and other common mistakes. Worse yet, being weakly typed opens JavaScript scripts up to a whole host of type-related problems.

There are programs available to help with the development of JavaScript scripts. JSLint analyzes JavaScript code, looking for a variety of problems. A JavaScript debugger, such as Venkman, is also essential. But even these tools do not catch many serious problems.

As more complex Web applications are developed using JavaScript, we’ve started to see certain limitations being hit. One such limitation is the maintenance of a sufficiently high level of quality. This is not only in terms of correctness, but also in performance and portability. The very nature of JavaScript makes quality control a tedious task.

It may be time for us to look beyond JavaScript, to technologies that offer the capabilities needed for larger-scale software development. One essential feature is strong typing. Ideally, this typechecking can be done statically (ie. before the code is executed). Type-related errors caught before an application is executed leads to the developer addressing them, rather than a bewildered user encountering a confusing error message at runtime, typically interrupting (if not losing outright) what they were working on.

Strong, static typing has additional benefits, especially when it comes to optimizations. The more restrictive semantics allow the optimizers within compilers and interpreters to make assumptions and decisions that could not otherwise be made. This in turn often allows for greater optimization techniques to be applied to the code, improving runtime performance and decreasing code size.

So instead of looking at a language like JavaScript, we should probably be looking more towards a language like Standard ML or Haskell. I think Haskell would be an optimal choice. It offers many of the high level constructs of JavaScript, but it also addresses many of the aforementioned problems. What we lose relative to JavaScript is the ability to use techniques that lead to poor-quality, buggy code. But furthermore, we gain a language that promotes quality software through strong, static typing. Beyond that, Haskell has many advanced features, including pattern matching and lazy evaluation, that we really don’t find offered by JavaScript.

Haskell has even more going for it. Another major benefit is the availability of several interactive environments and interpreters. GHCi, for instance, is actively maintained, and is of a very high quality. There is also Hugs 98, which is a rather complete implementation of Haskell 98.

The purely functional nature of Haskell will become more and more important as consumer PCs begin to offer four to eight (or more) cores per CPU. Haskell can allow for the safe, automatic parallelization of code to a far greater extent than JavaScript ever could. We will need to take advantage of such features if we will want our Web applications, or even our applications in general, to effectively use the PCs of the near future.

So what we need to see is a Haskell implementation embedded within a major browser, and extended to offer DOM integration. This would allow for developers to use it instead of using JavaScript. The very nature of Haskell would allow for the development of complex, high-quality Web applications. With such Web applications becoming larger and more essential each day, we need a much more significant focus on quality and performance. Haskell will allow us to achieve this, while JavaScript will not.

You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply

To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word