Adblock Plus and (a little) more

Running Linux in the browser · 2011-05-17 18:50 by Wladimir Palant

I haven’t seen it mentioned on Planet yet, could it be that nobody heard? I’ve seen lots of cool browser demos lately but this one really blows me away: jslinux by Fabrice Bellard. This is a real x86 emulator written in JavaScript and running Linux, not a fake Linux terminal. The emulated hardware is somewhat limited (e.g. no FPU) but this doesn’t make packing an emulator into less than 20 kB of JavaScript code less impressive. The emulator loads a bunch of binary Linux images and — voilà, Linux boots up.

It is also really fast, booting up takes 7 seconds in Firefox 4 for me, and all the other operations don’t take much longer than they would on a real system. Supposedly, Chrome 11 is also supported but for me it hangs up near the end of the boot process. Also, Chrome 11 is noticeably slower (Fabrice Bellard himself made this observation as well). There are plenty of command line tools available, including a compiler. I first had my doubts — but they all work as you expect them to. I can even ping 127.0.0.1 (pinging other addresses or using wget fails because the emulated hardware lacks a network interface). Update: Even better: run telnetd, change root password with passwd, then telnet to 127.0.0.1 and log in as root — it actually works.

Talk about desktop applications moving to the web…

Tags:

Comment [14]

  1. dspace · 2011-05-17 20:00 · #

    Interesting. Gnome 3 applications can run in the browser as well. And I think the Document Foundation is trying to make LibreOffice web friendly. Linux is well positioned for the inevitable transition to the “cloud”, although I shutter to use that word. :)

  2. Charles · 2011-05-17 21:17 · #

    ERROR: your browser is too old to run JS/Linux.

    You should use a recent browser such as Firefox 4.x or Google Chrome.”

    LOL…I’m running the latest version of Opera, I’m not using an outdated version…

    Reply from Wladimir Palant:

    It is using typed arrays, Opera doesn’t support them yet.

  3. Fredrik · 2011-05-17 21:28 · #

    @Charles, you need a browser that supports typed arrays. Otherwise it’s “too old”.

  4. David · 2011-05-18 00:17 · #

    :-( On Nightly I get:

    Error: invalid arguments
    Source File: http://bellard.org/jslinux/cpux86.js
    Line: 9

    Reply from Wladimir Palant:

    Yes, I’ve seen that as well. I checked with JavaScript Deobfuscator, apparently it is having trouble using XMLHttpRequest to get binary data. It is currently trying to use mozResponseArrayBuffer (Firefox 4, older version of the standard?) or response (WebKit and V8, per standard) XMLHttpRequest property. Nightly builds no longer have mozResponseArrayBuffer but they have mozResponse rather than response (also mozResponseType rather than responseType), this is the usual approach for experimental implementations. A trivial change to the script should do.

    Reply from Wladimir Palant:

    Fabrice Bellard fixed this issue now, it works correctly in Firefox nightlies.

  5. LOL · 2011-05-18 00:19 · #

    @Charles: Opera has some catching up to do with gradients also

  6. skierpage · 2011-05-18 00:57 · #

    It’s fascinating! It’s immediately the fastest and easiest environment for learning the Linux command-line. If it ever gets networking support it’s a killer network utility. I wonder if it can run Google Native Client binaries, or the planned Pinnacle portable native client format (really portable portable clients!).

    If M. Bellard open-sources it I’m sure a port of DOSBox to JavaScript will come quickly, then other 386 runtimes. Wow, just wow.

  7. Simon · 2011-05-18 01:43 · #

    @dspace: “Interesting. Gnome 3 applications can run in the browser as well.”

    Not quite true. Gtk 3 has a backend that allows applications to render to a buffer that gets sent to a browser for display. But that’s just a remote desktop like VNC – the application isn’t actually running in the browser…

  8. Jay Satiro · 2011-05-18 01:59 · #

    Impressive! The most interesting thing I’ve seen in a while.

  9. njn · 2011-05-18 05:15 · #

    Fabrice Belland is a freaking genius at this kind of thing.

  10. pfg · 2011-05-22 20:48 · #

    Fabrice has added support for Opera and ie9, and an easy way to upload “C” source programs.
    ==> We can easily compare the performance of each browser :
    1- paste some C program in the clipboard aera (just use #include <tcclib.h> instead of usual ones)
    2- type “cat /dev/clipboard >toto.c;tcc -run toto.c”
    3- measure start time – end time

    On a mandelbrot test :
    -ie9 is 10% slower than firefox,
    -both are very slow (probably due to the lack of “fpu”).

  11. EriC · 2011-05-23 09:35 · #

    It loaded in 3 secs but don’t know what to do now… :p

    1 week ago for first time in my life I installed Ubuntu 11.04 through “Wubi” in pararell with Win7 but after 2-3 times, bored entirely. Now I’ve it as secondary OS but propably I’ll delete it.

  12. Numero surtaxé · 2011-05-25 16:58 · #

    What a great article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot .

  13. Bateau occasion · 2011-05-25 16:59 · #

    Great Blog, I like how you are thinking…It is brilliant and I will recommend this great website for the great articles .

  14. montre armani pas cher · 2011-06-01 07:32 · #

    La société a été fondée en 1853 et persiste à être à sa place actuelle du Locle dans le Jura depuis plus de 150 ans.

Commenting is closed for this article.