Sunday 31 October 2010

Ostensibly Here

ALERT: this post is about programming and stuff, so if you're not interested, best skip it! That said, I'd love it if you had a look at the new forum I'm working on and had a play. If it breaks, please let me know :D

Hello!

Gosh it's been a while, hasn't it? There's a good reason for that, however, and it does sort of involve WoW. Or rather, it involves a distinct lack of WoW: I haven't played since I broke my Windows 7 install by messing up the installation process of Ubuntu, about two months ago (I told it to put the bootloader on my external drive. Don't ask). Anyway, in lieu of WoW-playing, I have been doing something to break out of the rut of career mediocrity I've been in for years: I have been learning how to make web-based programs. That is, how to write in Javascript, Python and Ruby, how to run servers, and all (well, some) about the stuff that holds it all together.

Said the client to the server

Javascript, as it happens, is a really nice language. Apparently it gets a lot of stick for being a toy, but I feel it's more like a surprisingly versatile yet lightweight tool. The best part is, pretty much every desktop and laptop computer comes with the tools necessary to begin with Javascript: a text editor and a web browser. Of course, the real power comes when you can communicate with and store data on a server, as then you can split an application into two parts: the server-side which does all the data-retrieval, and the client-side which does all the presentation and interaction.

A common framework for developing the server-side web applications is MVCModel, View, Controller. This is all well and good for presenting mostly static pages that the user doesn't interact with much, but when you involve Javascript on the client side more than for a few nice effects, you can start offloading a lot more of the page rendering to the client. Rather than sending fully-formed HTML from the server, you can just send the relevant data (in JSON format, ideally) and have the client set up the HTML on the fly. Until fairly recently this wasn't a practical way to do things, as browser incompatibilities and slow Javascript performance meant the DOM manipulation required just wasn't practical. However, efforts by Google, Mozilla and Opera to vastly improve their Javascript engines, combined with the emergence of Javascript frameworks like jQuery and Prototype, has resulted in a new style of developing large, complex web applications.

Enter Andy, stage left

It was into this environment that I entered more or less in ignorance. Ten years ago I'd done some programming for a while in Delphi, writing some handy little utilities like a font browser (sadly no longer available since the host it was on closed down). However, writing Windows desktop software is really quite different to writing for the web. For one thing, the applications tend to be more monolithic and closed – all compiled up into one neat .exe file. Web apps on the other hand are invariably run directly from source code, albeit often minified, and can easily pull their various parts from different servers around the web; they feel looser and more open to write.

On Javascript

Speaking of 'loose and open', that's generally how I see Javascript. It's a very easygoing language, due in large part to its loose typing. It's that and the fact that functions are first-class object that really make Javascript so nice to use. You almost never have to declare the type of a variable, and a function definition (which itself can be a variable) has a list of parameters that doesn't specify their type:

var add = function(a, b) {
    return a + b;
}

The thing about that function is that its parameters don't even have to be numbers:

var foobar = add("foo", "bar"), // foobar = "foobar"
    forty_two = add(40, 2);     // forty_two = 42

Or how about:

var arbitrary = function(a, b, func) {
    a *= 2;
    b *= 1.5;
    return func(a, b);
};

var number1 = 64,
    number2 = 99,
    number3 = arbitrary(number1, number2, add);

alert(number3);

There's just so much I could write here, about objects, closures, AJAX, jQuery and so on, but it'd get kinda boring I reckon, so I'll move one.

The future's bright

But it's Ruby-coloured, at least for me. It took a lot of prompting and hinting and suggesting, but my brother finally persuaded me to dive into all this stuff, and after a nice chat with his boss I've begun to focus my attention on Rails, pretty much just because it apparently has better (i.e. more) job prospects than the language and framework I initially chose, Python and Pylons.

Job prospects is what I need, as I'm currently working fixing computers, which, while not boring, is hardly challenging. One of the things I love about programming is solving problems, and there is an endless supply of those. There's always something new to learn, to try and understand, and maybe even eventually to teach others about.

I feel with programming I can do something more directly useful to people than just being a cog in a black box machine that takes in broken computers and spits out working ones. That's a large part of the motivation for writing my forum – I want to do something that people will use and appreciate. The idea was born of dissatisfaction with the way most existing forum software works: too many page loads, cumbersome to navigate and slow to use. Another part of the motivation, of course, is so that I have something to show to prospective employers, as it's not like I have x years of commercial programming experience. From what I've heard and read, though, I stand a good chance of getting hired based on what I know and can do, rather than how long I've been doing it.

So, here's to hoping for an improvement in my general state of affairs! Who knows, maybe one day I'll even come back and have a pop at ol' Deathwing.