Why do we have to have Browser exceptions to use Javascript?

The irony of Web programming was that it’s concept was to remove all the processing on to the server so the client was thin and only had to worry about the presentational layer (i.e. the browser). However, as web applications have become more complex and feature rich, it has been necessary to push that ideal to the limit.

Today’s Browser

A modern browser will need at the minimum the ability to handle XMLHttpRequests (Ajax), Adobe Flash and Javascript – Shockwave is less important, some sites seem to want to include WMV content (I don’t know why…), SVG is the panacea that never was.

If you look at the majority of modern websites, they are increasingly reliant on javascript to provide richer services – unfortunately each browser may have it’s own flavour of javascript which means those programming for the web have to create exceptions and conditions throughout their code. This in turn creates significant overhead and repetition, increased risk of issues, etc.

A common Javascript Platform?

Doesn’t exist. In the days when Netscape and Microsoft fought it out, NS has it’s ECMA script, whilst MS had JScript – similar implementations but there were clear differences which meant that in the early days Javascript was relegated to the more simpler functions in web pages.

Nowadays the implementations are much closer – it’s far easier to write Javascript x-browser fashion, however the implementations of the browsers means that there are still differences exposed. Add to this that Microsoft has continued to extend JScript to be a .NET compatible language (for scalability), whilst Mozilla (the Firefox people) are now working on an open source high performance engine called “Tamarin” (see http://developer.mozilla.org/en/docs/Tamarin), not to mention the other two versions of Javascript they maintain.

The simple but hard solution

For HTML we have the W3C committee who agree the standards which the browsers then break… THERE IS a similar quasi-independent body that determines the standard for javascript – this is called ECMA (http://www.ecma-international.org), but unfortunately its’ success thus far has been limited. If all parties could just agree that the core javascript implementation was browser neutral then all browsers would (eventually) have to fall in line; all the browser quirks like DOM implementation incompatibilities would diminish as each browser’s interfaces would be standardised… wouldn’t it? Once could argue that the very core JS is pretty much standard and the quirks are at a higher level – then perhaps the issue also lies with the browser implementation and we need standards there…? The problem is, in creating standards development becomes slower as players like Microsoft, Adobe, IBM, BEA, Mozilla et al come to the table, all with their own agendas – understandably.

Light on the Horizon

The good news is that the big players are finally getting it together. IE8 is supposed to be the most pure implementation of browser standards and Firefox 3 also claims they’ll be there. The major players currently support ECMA 3 (well, support in a loose sense maybe…) and are working towards ECMA 4. To quote their overview paper:

ES4 is compatible with ES3 and adds important facilities for programming (classes, interfaces, namespaces, packages, program units, optional type annotations, and optional static type checking and verification), evolutionary programming and scripting (structural types, duck typing, type definitions, and multimethods), data structure construction (parameterized types, getters and setters, and meta-level methods), control abstraction (proper tail calls, iterators, and generators), and introspection (type meta-objects and stack marks).

Ironically this means we’re getting closer to a Java implementation, although the concepts can be mapped to .NET, so by default both sides of programmers will grasp the concepts, even if the syntax is closer to Java. Unfortunately no release date is mentioned, so this could mean we’re some time way off a release proper.

There is a pre-release verision available here -> http://www.ecmascript.org/download.php

Conclusion

I think Javascript has become incredibly important in the delivery of modern websites that the standards and compliance needed are increasingly important. ECMA4 (ES4) seems to be going in the right direction and once released I’m sure will see very clever code patterns being developed – this will create its’ own set of challenges with things like Browser storage capability needed (such as those currently available in Firefox and to a lesser degree IE). Existing frameworks such as MooTools, Scriptalicious, Dojo, et al will become key ingredients in modern designs – It wouldn’t suprise me if one of those frameworks gets snapped up by MS, Google or Adobe…

Advertisements

3 thoughts on “Why do we have to have Browser exceptions to use Javascript?

  1. SVG is just a very useful technology, that’s why it’s used a lot nowadays, see http://svg.startpagina.nl for loads of examples.
    As with many interesting technologies it was overhyped into a panace at a very early stage, which didn’t help its uptake

  2. I agree in part – SVG is a great technology that will never truly gain acceptance until all browsers natively support it – we’re not there yet. I think once people realise the power of SVG the uptake will rapidly increase.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s