Fun with javascript

Well, after much reading of the huge O'Reilly book on the matter, I am now somewhat better versed in javascript.

I have, like many people, tinkered with it before. It is the sort of language you can tinker with, much to the detriment of the users of web sites eveywhere...

I would however recommend reading up on the language properly. It is not quite as bad as it looks. I have used a lot of languages in the past and they all have quirks

As a C programmer you find the way the data types are handled a surprise. There are a few distinct types, and they are interchanged automatically. Numbers are all floating point (which is fun). There are objects which allow mapping of names to data, and also arrays which work in a similar way. The fact you can create literal functions which have a lexical scope are also rather run but typical of object oriented programming which fits well with an event drive UI model used by browsers.

What has been fun is writing code that works with a range of browsers. It does not seem to be that hard - there are a few well known areas of differences and a good book highlights them. The core javascript is pretty consistent. I found a couple of quirks the hard way, but I am quite chuffed that I have the web config for the FireBrick working on IE6 even!

Does this mean a lot more javascript on the A&A pages? Maybe... Maybe better javascript too. But to be honest, it is time consuming, and if it aint (too) broke, don't fix it. I am not a huge fan of the jquery type animations that get used a lot (and have been on some of our control pages). Done in subtle ways they are not too bad, but they get in the way and can be more of a nusiance than a help.

I suppose I better fix my photo site though as that never worked on chrome. Far too much else to do.


  1. Please make sure A&A stays working in nearly everything, it's one of the positive points of the site.

    I've found portability can be harder than you'd think, especially the evils of IE6!

  2. It's funny how javascript for a long time was hated by most developers and written off as a toy language, but it's actually turned out to be a pretty powerful and sophisticated language that's getting a lot of respect these days.

    Have you seen node.js (http://nodejs.org/) for writing web and network servers in javascript. it's one of those things where once it clicks in your mind you just thing "of course it should work like this, why didn't anyone do this years ago!"

  3. I was keen not to have someone else's libraries in the FireBrick, hence not using jquery ot the like. But learning it from scratch it is not that hard to be honest. The fact we did not want the flashy animations helps too.

    It seems for basic data manipulation javascript is a perfectly good language. And basic construction of web objects and handling forms is pretty simple and consistent over multiple browsers.

    I can see this being something we do more with.

    One thing that it has allowed us to do with FireBrick is make the back end talk a single XML config and the editing is all in the web page. This has advantages as it allows people to handle the XML directly as well with no inconsistency. That sort of approach would be ideal for things like the A&A config pages too, and may be a way we go in the future, which I know some people will like..

  4. "Does this mean a lot more javascript on the A&A pages? Maybe..." please dont, or at least if you do jump off that cliff use your own code instead of some of the horrid stuff in use at present. You tend to dtrt most of the time, so it would be nice if you took that approach with any js stuff as well.

    "I was keen not to have someone else's libraries in the FireBrick", any chance of extending that sentiment to clueless as well ?

    Ultimately though, the XML interface to clueless would be most welcome. The Ordering systems too please :)

  5. I like jQuery, but I don't use it for animating anything. I can't see any particular reason why one wouldn't want to use a cross-platform helper library in an embedded product. Obviously you'd serve it locally and not from a CDN, but it deals with a whole slew of minor browser differences which you'd otherwise have to deal with yourself (probably after your customers had drawn them to your attention). It's not like using it stops you talking directly to the DOM in any situation where that's more convenient. Because some truly awful websites use it is no more reason to dislike jQuery than to dislike HTML.


Comments are moderated purely to filter out obvious spam, but it means they may not show immediately.