Wow… just wow

If you’re remotely into software development, you’ll have probably already have heard of this already. If you have not, you need to check it out right bloody now and bask in something that’s going to blow your socks off even if they’re glued to your feet:

My God, it RUNS

My, my, little Javascript. You have come a long way, eh?

You’re looking at Linux booting on an almost-486 CPU, that’s old hat, but this 486 is an emulation written in Javascript running in your browser1. Don’t stop with one, run many!

The mere fact that this is possible indicates that we’re heading towards another threshold moment with software development. The first one for me was when I switched – out of choice – from assembly language to C for the vast majority of my software development. Up until, oh, ’92/’93, the memory and performance hit from developing most games in C was utterly prohibitive. Indeed, for the Amiga 500 type machines, the baggage associated with using C was so vast that entire genres were utterly impossible without hand-coded, hand-optimised 68000 assembly language. 512K didn’t go far. Then, something amazing happened: the compilers got good. Whilst this was going on, target machines got faster and gained more memory. To top it off, though, processors started to get so darn complex with their fetch-execute pipeline, out-of-order execution and cache management that, well, frankly, the compilers generally did a better job than I could.

Whilst I didn’t celebrate kissing goodbye to an assembler as my primary development tool, I probably should have. Life became much, much easier when I stepped up to a higher level language. When I moved up to C++ in the naughties, things became easier once again. Now, I could manage programs of a size that I’d never before imagined with ease. Recently, playing around with Objective C and the Cocoa Apple stuff I’ve seen another step change that had managed to completely pass me by until now. Creating applications with beautiful user interfaces and rich functionality is so much easier than it was on the PC that I kept thinking “hey, it can’t be this easy, surely.” The best bit, though, was that the development tools were a sheer pleasure to use! I was up and running in no time and even when moving from major version to major version the transition has been straightforward. It’s refreshing to see that a user-interface can be completely revised and updated without using fucking Ribbons and other such witchcraft that ensures that you’ll never find anything ever again. Microsoft Word is dead to me now, dead.

Now someone has managed to emulate a complete 32 bit 386 class CPU along with the I/O hardware required to build a virtual computer. In Javascript. Yes, you heard me, Javascript. And, as all good programmers do with something cool, he turned it up to eleven and built a Linux kernel for it. So, because, like me, you’re probably thinking “not a pint of beer’s chance in my hand”, I’ll confirm what’s gone down here:

  • The latest generation of Javascript engines are incredibly fast
  • It is possible to emulate a CPU in Javascript and get half-decent performance
  • That emulated virtual CPU can run an operating system
  • He built the drivers necessary to build Linux on it, which he then did

The first BASIC program I've written in yonks. Awesome! It's like riding a bike, you never forget, no matter how hard you may try to

So check it out. It’s incredible. And because there’s nothing like infinity, I of course, grabbed the Obfuscated C contest’s DDS 1000 byte BASIC interpreter, downloaded it, fed it into Javascript Linux, compiled it and ran it. Oh yes, oh yes indeed. It works!

So let’s recap: that’s a program written in BASIC, running in an interpreter written in C in just 1000 bytes, running under Linux which is running on an almost-486 processor emulated in Javascript running in Firefox which is written in C++ running under Unix on a Mac. I think, in the most exquisite and delicious way, my braiiiiin just went “pop”. I raise my glass to Fabrice Bellard who wrote this Javascript work of art: You, sir, are a hero!

-~-

Javascript is getting faster from both ends: computers get nippier and Javascript engines get optimised. In a precious few year’s time, the list of things that you can’t do in a browser will be shrinking faster than the low-quality burgers I gave up a while back. So long as we’re able to bring up a generation of people who are smart enough to do incredible new things with this power then it’s almost time to get out the shades.

In the meanwhile, the “good riddance” department is fluffing up the cushions of despair and opening the consolation brandy of endless toil ready for Flash to turn up – and not a moment too soon.


1 This doesn’t work in Safari at the moment: Firefox and Chrome 11 are good, though. Fabrice says this is because some Javascript implementations do not yet support W3C typed arrays

This entry was posted in Cool stuff and tagged , , , . Bookmark the permalink.

Comments are closed.