All posts filed under

parties

 

Javascript

Now there's a headline to conjure with. Just dropping the word casually into conversation at parties has young ladies flocking from all corners of the room, hanging breathlessly on my every word.

Back in the real world, javascript is the 'other' language that you are allowed to use on the web. HTML handles all the content, javascript does all fancy effects. It makes Google maps slide smoothly around the screen, Facebook posts appear without the whole page reloading, it underpins the auto-completing search on eBay and helps remember who you are when you come back to a page. In short: tremendously useful.

Unfortunately, it's awful. Total rubbish. Complete crap. Honestly, of all the languages you could have chosen to run the internet, this is the worst one, bar none.

Why?
It's as slow and unreliable as a 1975 Morris Marina, as unpredictable as an MP on acid and deliberately hamstrung by design so that it can't do anything harmful (although that hasn't stopped hacker types from finding ways to use it for evil).

This weekend, tired of being relentlessly pestered girls at parties, I decided to stay home and muck about with jQuery instead. jQuery is a code collection, written in javascript, that automates a lot basic tasks for you. We've been using it at We Love The Web for ages now as it does a lot of helpful stuff. It's useful because lots of people have spent lots of time overcoming the bugs in all the different browsers' javascript implementation.

Now: stop a second and think about that last sentence. That's right: the language that runs most of the internet works differently in every browser. So unless you use a Library like jQuery, you'll probably have to write at least four different versions of your code, each tuned to the peculiarities of a different browser. Does my ranting about how rubbish it is start to make more sense now? Imagine if you had to write every sentence on your website in Geordie, Mancunian, Received Pronunciation and Scots, just to make yourself understood. That would get annoying really fast.

So, back to my supersexy weekend. I set out to mock-up a glitchy text-based animation thingy in a few lines of code. I wanted to experiment with using jQuery and see if we could reduce our reliance on flash for motion graphics. Keep it simple, keep it fast, I thought.

The result isn't going to set the design world on fire, nor is it intended to - it's just a scrap of test code. You can see it here: www.welovetheweb.com/black3.html, neatly highlighting many of the problems with javascript in one simple page.

I'm not asking the computer to do anything hard: change the colour and size of some text. It's only about 20 lines of code. That's less than 1Kb. So why should it behave so unpredictably? It:

  • Stops arbitrarily for a second or two in Firefox from time to time.
  • Barely even runs in Internet Explorer 6.
  • Strobes eye-bleedingly fast in Safari on a Mac.
  • Looks rubbish in Internet Explorer 7, but quite cool in Chrome.
  • Runs at completely different speeds in each browser you test it on, even on the same computer.
  • Runs at achingly slowly on anything other than a fast, up-to-date computer.
Bear in mind that I was using a code library specifically designed to iron out the differences between browsers. It's just mental. If you were running Office on javascript, it would take about 10 minutes to load and a simple spell-check would take about half an hour.

How on earth could we possibly rely on something that flaky to try and get stuff done?
Why on earth do we put up with it?

I dunno. I sometimes think us Geeks *like* coding to be difficult, it's how we define ourselves: by being able to do things with computers that mere mortals can't. We'll put up with having to type 100 pages of gibberish without so much as a comma out of place (or it all goes wrong). And we do it willingly, in fact we even enjoy it.

That's the bit I really don't get - why we Geeks are drawn to computers so inexorably. I guess it's the same fascination that people had in days gone by for clockwork or steam engines - an overriding desire, when confronted with a machine, to know how it works and why. An itch to understand that just won't go away. That urge can overcome everything: even our equally natural desire to smash the thing to bits with a big brick when it just won't bloody well work, even after we've poured hours and hours into it!

So yeah, I've got a couple of party invites to look over now or, alternatively, I could read up about the document-object-model differences between Firefox and IE's javascript implementation.

Ooh, the agony of choice.

Filed under  //   code   javascript   parties   web development   young ladies and fun