Features Podcasts Family Video Comics Music Tech Science Books Film & TV Games ✚

Jill

Javascript-based PC emulator, running GNU/Linux

Cory Doctorow at 12:59 am Wed, May 18, 2011

— FEATURED —

Science

Last chance to enter the Armchair Taxonomist challenge!

Book Review

Black Code: how spies, cops and crims are making cyberspace unfit for human habitation

Book Review

We Can Fix it! - a graphic novel time travel memoir

Science

The technology that links taxonomy and Star Trek

— FOLLOW US —

Boing Boing is on Twitter and Facebook. Subscribe to our RSS feed or daily email.

 

— POLICIES —

Except where indicated, Boing Boing is licensed under a Creative Commons License permitting non-commercial sharing with attribution

 

— FONTS —

Tweet
Kindle

Fabrice Bellard has written a 32 bit x86 emulator in Javascript -- in plain English, he's created a virtual PC that runs inside your browser, using Javascript. And then (of course), he created a GNU/Linux variant that can run inside it -- so you can run a full-featured PC inside your browser. It's a pretty fabulous hack and has far-reaching implications: for example, you could theoretically run any program or OS inside your browser, even if you're using a locked-down platform that won't let you change the OS or install your own programs. And then there's stuff like installing MAME in a virtual browser machine, so that you can play all/any retrogames.
What's the use ?
I did it for fun, just because newer Javascript Engines are fast enough to do complicated things. Real use could be:

* Benchmarking of Javascript engines (how much time takes your Javascript engine to boot Linux ?). For this particular application, efficient handling of 32 bit signed and unsigned integers and of typed arrays is important.
* Client side processing using an x86 library, for example for cryptographic purposes. For such application, the x86 emulator can be modified to provide an API to load x86 dynamic libraries and to provide a js-ctypes like API to call the C/C++ functions from javascript.
* A more advanced version would allow to use old DOS PC software such as games.

JS Linux

Javascript PC Emulator - Technical Notes

(via Command Line)

I write books. My latest is a YA science fiction novel called Homeland (it's the sequel to Little Brother). More books: Rapture of the Nerds (a novel, with Charlie Stross); With a Little Help (short stories); and The Great Big Beautiful Tomorrow (novella and nonfic). I speak all over the place and I tweet and tumble, too.

MORE:  javascript

More at Boing Boing

The technology that links taxonomy and Star Trek

Hackers prepare for first "national holiday" in their honor

  • Anonymous

    I’m more worried about the security risks concerned with this. Running a complete OS while transmitting TCP communications would mean unlimited access to what you are doing. This program could expand the world of cloud computing (cloud Virtual PCs – think about it), but think of what could be stolen as you are working. All it would take is one redirection malware, and everything you have been working on is now someone else’s.

  • OrcOnTheEndOfMyFork

    Also, if you’re on a restricted network, the perfect gag to make your company’s System Administrator freak out.

  • Anonymous

    Given that Java has butt-fucked the IT industry and their duped customers, this is a welcome return to thin/smart client software.

    • Anonymous

      Java and Javascript are two different technologies. They both come with bad developers, and bad habbits. But Javascript is a bit less bad than Java.

  • Jamie

    Umm, there’s a similar Java-based technology that’s been developed at Oxford that does exactly the same thing. Only, they already have demos running Linux in a browser. And, importantly, Doom.

    http://jpc.sourceforge.net/home_home.html

  • Anonymous

    I haven’t read too far into it, but what’s to stop you from running a browser-based PC inside of your browser-based PC?

  • Anonymous

    Its like a dream within a dream within a dream. But who’s dream?

  • Bryan3000000

    This is very cool, but also has strict limitations. It runs only in very recent browsers, and is only acceptably fast because the emulated hardware is very, very limited. Networking has not been implemented at all. It’s potential uses are really restricted to the narrow lines Fabrice drew.

    Of course, if it implemented networking and some related tools, it could have some additional uses. But really, there are other tools to accomplish those ends anyway.

    • Joe

      A more complete processor implementation (for example, adding the rest of the 486 instruction set, so that DOS games can be played) wouldn’t slow it down significantly. This is the guy who wrote QEMU, he knows how to write high-performance emulators. For networking, there’s the problem that the browser’s ability to make network connections is severely limited.

  • Anonymous

    Well the obvious thing to do now is to have interchangeable images, so you could load up your home or office computer anywhere, instantly. The great thing is that they wouldn’t have to be turned on and online all the time, only when you are using it. It could simply update an online image when you logoff. Now give me a million dollars for the idea.

  • victorvodka

    how you know dude is the real deal:
    pre-emptively answering the question: “BDIRL?”

  • LightningRose

    Fabrice Bellard is also the creator of ffmpeg and QEMU, two tools I use frequently.

  • Anonymous

    After doing “ls /” “cat /etc/passwd” “tcc -o hello hello.c”, I did the obvious:

    rm -rf /

  • geophile

    Fabrice Bellard is one of the outstanding developers in the world: http://en.wikipedia.org/wiki/Fabrice_Bellard.

    What is really amazing is that he is so productive in so many different area: numerical methods, machine emulation, and even compiler technology. (Although TinyCC is known primarily for being compact.) Finding someone so knowledgeable in one of these areas is difficult. The fact that he is so accomplished in three is just mind-boggling.

  • Anonymous

    oh please type on that line: firefox &

    Bellard is really one amazing chap.

  • jacob_ewing

    All I have to say is that this just screams of awesomeness. And here I thought I was doing well just writing games in Javascript.

  • petsounds

    While it’s crazy to be running emacs in Javascript, and this is an amazing piece of work, I can’t help but feel that Flash would’ve been a better target platform for this. It has better networking support (including sockets), faster execution time, can live outside a browser, and the SWF format is open source. Of course, open source advocates don’t like to admit that it is, and would rather shoehorn everything into “HTML5″ solutions, even though it’s not really mature yet. Flash 11 is going to have support for true threads, so it could pretty much fully implement a Linux system.

    But hey, what Bellard did is quite impressive, and if he wants to make something for the hell of it, props to him.

    • mistersquid

      What I like best about Flash is how predictably it crashes the tabs it runs in, a much better solution than browser standards like JavaScript.

    • toyg

      SWF might be “open” (for some degrees of “openness”), but to play it you’ll always need a plugin, and the only decent plugin you’ll ever have is the one produced by Adobe; which means Flash is, in practice, a proprietary technology.

      Btw, Bellard didn’t do this “for the hell of it”, but rather to explore the full potential (and limitations) of recent Javascript engines. Some people code crappy, flickering “interactive films”, Fabrice writes OS emulators.

      To people talking of running X and firefox etc: the terminal window you see is rendered with HTML, which is why its performance is acceptable. To emulate a full video driver you’d need to draw every single pixel in javascript (which is doable but probably too slow), or start dishing out browser-specific hacks to reach the physical hardware (which is probably not doable and certainly insane). So no, you’ll probably never see that. God knows we have enough problems running X with real hardware…

      Networking is another matter; with the right bridging it could be done, at least in very recent browsers.

  • Cocomaan

    Yo dawg, I heard you like open source operating systems, so I created a javascript emulator that will run GNU in ur Windows so you can GNU in your virtual window while you run Windows.

  • Harrkev

    Hmmm. Next step, get X working. Then, you can install a browser. From this browser, you go to a Javascript-based PC emulator. Infinite recursion now becomes possible.

    • bcsizemo

      Why not take that one step further:

      Install VirtualBox in your Java/Browser OS VM, then load a different OS, load your browser and repeat…

      Or something like that…

      (If we ever have the ability to “plug in” to a virtual world it’s all going to turn into the Matrix. How do you REALLY know you aren’t in a virtual world.)

  • Jorpho

    Word is that DOSBox is now available for the Google Native Client. Hardly the same thing, but there it is.
    http://www.naclbox.com/

  • Anonymous

    In point of fact, this isn’t GNU/Linux. It’s just Linux.

  • Anonymous

    Where’s the GNU? no gcc, no glibc, and he used busybox. This isn’t really GNU/Linux

  • Gregory Bloom

    The amazing thing about a dancing bear isn’t how well he dances, but that he can dance at all.

    Given the restrictions of the JavaScript sandbox, this emulator cannot be of much use, but damn, it sure is cool!

  • Dewi Morgan

    Seems like a REALLY roundabout way to get your iphone to run flash…

  • Anonymous

    First you run an OS. Then you run a browser and, inside this browser, you run another PC emulator. Inception’d.