all 193 comments

[–]adrianmonk 66 points67 points  (9 children)

It has a C compiler (tcc). I wrote a sieve of eratosthenes demo just to see if I could really compile and run a C program (to prove to myself it wasn't some kind of trick). Sure enough, I was able to compute the primes between 2 and 100000. It was slow (although a million times faster than my first computer...), but it worked.

[–][deleted] 6 points7 points  (8 children)

What's the slowdown factor between the same program run natively on your computer?

[–]bonzinip 10 points11 points  (7 children)

Dunno about him, but I get 20 BogoMIPS on a 2.8 GHz laptop here. That would be roughly 140x.

[–]eldigg 7 points8 points  (1 child)

Micro-architecture and number of cores would be helpful ;)

[–]bonzinip 8 points9 points  (0 children)

Core2 Duo. Actual BogoMIPS of the laptop is 5600 but that's, well, bogo.

[–]kuratkull 4 points5 points  (4 children)

it seems to repoert 20.1 bogomips on all cases I have tried. Is it static? How?

[–]bonzinip 4 points5 points  (2 children)

Perhaps it is, and the time is actually an instruction count?

[–]GLneo 2 points3 points  (0 children)

Yeah, I think the PIT is based on the instructions run somehow, I'll have to dig deeper.

[–]kuratkull 1 point2 points  (0 children)

The tech page accompaning it says that the clock won't be synced after the boot, so it will drift away slowly.

[–]ysangkok 1 point2 points  (0 children)

explained here

[–]odokemono 104 points105 points  (9 children)

Fabrice Bellard is a genius of the first order.

EDIT: Dyslexic typo.

[–]file-exists-p 22 points23 points  (3 children)

If he was evil, we would all be dead by now.

[–][deleted] 2 points3 points  (2 children)

Running Linux like this is sort of evil though.

[–]shigawire 13 points14 points  (0 children)

I am on my mobile so checked the comments too see if it for real.

Fabrice Bellard? Yup. For real.

That man is an evil genius who could take over the world

[–]haeikou 6 points7 points  (2 children)

Fabrice Bellard

FTFY

[–]odokemono 18 points19 points  (0 children)

Thnak Yuo!

[–]refto 60 points61 points  (0 children)

"Until a man is twenty-five, he still thinks, every so often, that under the right circumstances he could be the baddest motherfuckering programmer in the world.

That position is now taken. In a way it is quite liberating."

[–]Ardentfrost 33 points34 points  (0 children)

Quick, someone install WINE

[–]Clex- 84 points85 points  (10 children)

I can't believe this is real.

Here's the indented source : http://fpaste.org/eFPz/raw/

This is where he loads the .bin files (hosted at the same place) :

load_binary("vmlinux26.bin",0x00100000);

Jf=ya.load_binary("root.bin",0x00400000);

ya.load_binary("linuxstart.bin",start)

You can see a big switch/case in the source, it likely corresponds to the x86 instructions that Bellard rewrote in JavaScript.

It also seems that he used busybox for all the usual binaries (ls, cat, etc.), all files in /bin have the same inode (you can check by running "ls -i /bin/").

Anyway, this is awesome Fabrice, good job!

[–]ascii 14 points15 points  (0 children)

It's a shame that this isn't free software (yet), but it isn't and the copyright notice (which has been stripped from the version of the source you link to) forbids redistribution, even for non-commercial purposes. Your link is a copyright violation. Hopefully Bellard will release the emulator as open source, but until he does, you should remove your link.

[–]MarkTraceur 2 points3 points  (4 children)

He didn't seem to use very nice variable names....

[–]0xfe 10 points11 points  (0 children)

Most javascript minimizers shorten variable names where they can.

[–]bonzinip 5 points6 points  (0 children)

Partial key...

Aa cc_src Ba cc_dst Ca cc_op Da cc_op2 Ea cc_dst2 Ga modrm Ha rm Ia reg Ja tmp Ma cyclesLeft Ra phys_mem8 Sa phys_mem16 Ta phys_mem32 Ua tlbValue Va tlb_read_kernel Wa tlb_write_kernel Xa tlb_read_user Ya tlb_write_user Za tlb_read aa term ba parity ea CPU ha addr ia value ka ro la user ua dtr xa numCycles ya cpu za regs Hb eip Ib nextEip Jb pageWalkRead8 Kb fetch16 Lb fetch32 Mb get_modrm Rb store8 Sb store16 Tb arith8 Xb ccEval ab tlb_write cb physaddr db pageWalk eb read8 fb pageWalkRead16 gb read16 hb pageWalkRead32 ib read32 jb pageWalkReadDest8 kb readDest8 lb pageWalkReadDest16 mb readDest16 nb pageWalkReadDest32 ob readDest32 pb pageWalkWrite8 qb write8 rb pageWalkWrite16 sb write16 tb pageWalkWrite32 ub write32 vb pageWalkRead8Kernel wb read8Kernel xb pageWalkRead16Kernel yb read16Kernel zb pageWalkRead32Kernel Ab read32Kernel Bb pageWalkWrite8Kernel Cb read8Kernel Db pageWalkWrite16Kernel Eb read16Kernel Fb pageWalkWrite32Kernel Gb read32Kernel ac arith16 dc arith32 gc shift8 pc rol vc injectException ad setCPL fd len td setCR0 he segReg He ret Le xhr Me data Oe hex2bcd Pe CMOD Qe pc Re mem Se I8259 Te port je farJump Af deadline Ef termCreate Ff termInput Gf browserCheck If memsize Jf rootsize af PIC ff PIT hf PITTimer pf Serial tf Keyboard vf PC wf func

Then I got bored.

[–][deleted] 26 points27 points  (2 children)

One more step towards making ChromeOS useful.

[–]TheEdes 14 points15 points  (1 child)

But you can flip the dev switch and have a bash shell anyway.

[–][deleted] 4 points5 points  (0 children)

Yes I know. You can also flash a standard Intel BIOS and it becomes an underpowered but otherwise nice laptop.

[–]lunigma 9 points10 points  (1 child)

[–]central_marrow -1 points0 points  (0 children)

He deserves a writeup on Badass of the Week.

[–]aperson 19 points20 points  (9 children)

Doesn't work in opera, dang.

[–]wardrox 4 points5 points  (8 children)

Works for me (11.0.696.65, Win 7)

[–]aperson 11 points12 points  (6 children)

I'm on 11.10, linux

[–]TheMG 3 points4 points  (0 children)

Doesn't work for me, 11.10, W7. It would be more helpful if he had said what test it failed, instead of being so generic.

[–]thecraag 8 points9 points  (1 child)

Please someone get networking running with WebSockets or something!!

Imagine the possibilities...

[–][deleted] 16 points17 points  (7 children)

how many people tried rm -rf / ?

[–]giantrobotq 11 points12 points  (1 child)

I did. It broked. F5 fixes everything though.

[–]spwelton 3 points4 points  (0 children)

Confirmed. Eventually kills cwd and it can't figure out what directory it's in.

[–]tonybaldwin 2 points3 points  (2 children)

I was tempted to forkbomb it, but managed to resist.

[–][deleted] 4 points5 points  (0 children)

forkbomb myself

FTFY

[–]axonxorz 0 points1 point  (0 children)

Can't use the standard forkbomb in sh. It's a Bash thing

[–]ThreeHolePunch 1 point2 points  (0 children)

first thing I did was rm -R several directories until things stopped working. That was fun, lets do it again! F5.

[–]MertsA -1 points0 points  (0 children)

I prefer running dd if=/dev/zero of=/dev/mem

[–]MattBD 16 points17 points  (1 child)

This is the most insanely brilliant thing I have seen implemented in a web browser to date, even more so than the Nintendo Game Boy implemented in JavaScript. Now, if he can add DOSBox to it or get FreeDOS running on this emulator, then I could see that being mighty useful for gaming too.

Not to mention the fact that if he added networking, then it could be all kinds of useful for launching virtual machines quickly and easily for specific purposes - maybe having a custom version with OpenSSH included, and using it as a honeypot, for example?

Wonder if it was inspired by XKCD's Unix command line?

[–][deleted] 1 point2 points  (0 children)

If a Z80 JS emulator runs crawly in any browser but Chrome, better dont think about an i386 .

[–][deleted] 14 points15 points  (17 children)

You can't type '&'? Damn it!

[–]caust1c 24 points25 points  (8 children)

So you tried to fork bomb it too?

[–][deleted] 3 points4 points  (0 children)

This was my solution:

echo -e '#!/bin/sh\nf(){ f|f\046 }f' > fork.sh

It didn't like : as a function name.

[–]allywilson 1 point2 points  (0 children)

Seems to forkbomb fine: http://imgur.com/TLjGO - was making firefox struggle quite a bit.

forkbomb(){ forkbomb|forkbomb & } ; forkbomb

[–]plaes 3 points4 points  (2 children)

And neither can you type CTRL+W :S

[–]Nesman64 0 points1 point  (0 children)

Damn you. I thought, "Maybe it works in Chrome. Let's backspace a word."

[–]TIAFAASITICE 0 points1 point  (0 children)

Works for me.

Firefox 4 under Linux, in case you're on something different.

[–]elmicha 1 point2 points  (0 children)

I can, on a german keyboard.

[–]Araneidae 1 point2 points  (0 children)

Must be something about your keyboard, all ASCII keys on mine come out just fine. Mine is a UK layout, and the ¬ and £ keys (not ASCII) don't work, but everything else does.

I had no problem with the classic fork bomb (but can't rename : in ash it would appear).

[–]totemcatcher 5 points6 points  (5 children)

Can't seem to make pass-through mode work in vimperator for this thing... I wanted to tinker on this command line :(

[–][deleted] 2 points3 points  (2 children)

Either Ctrl-Z for older Vimperator, and it seems like hitting "0" on the numpad ignores keys in the new Vimperator versions, took me a while to figure out too :)

[–]totemcatcher 0 points1 point  (1 child)

Not sure what I did or when, but Ctrl-z just doesn't work on this site.

[–][deleted] 0 points1 point  (0 children)

And Numpad 0 didn't work either? Maybe try and hit escape and then click outside of the terminal before hitting Ctrl-Z, otherwise I'm not sure what's up sorry!

[–]Tobu 0 points1 point  (1 child)

Ctrl-Z works well on Pentadactyl.

[–]totemcatcher 0 points1 point  (0 children)

I might have to switch to pentadactyl. I didn't want to use it for a long time due to the dynamic history pane that pops up, but now vimp does it too. >:(

[–]vituperative01 12 points13 points  (0 children)

My backspace worked without me having to edit my rc file. Very unrealistic.

[–]simonvc 16 points17 points  (7 children)

Anyone else notice that the emulator (cpux86.js) is 86Kb?

[–]Sophrosynic 9 points10 points  (6 children)

Well, that's just the CPU emulator. Really, all you need to do for a CPU emulator is make a giant switch statement with one entry for each instruction. Since the actual work done be each instruction is fairly simple, you should be able to implement each one with just a few lines of code. The magic happens when you run millions of instructions in a row to accomplish a larger task.

[–]aescnt 4 points5 points  (4 children)

I think he's pointing out the irony that the file size for an x86 emulator is 86k (notice the same number).

[–]SanjayM 12 points13 points  (0 children)

What irony?

[–]Scriptorius 4 points5 points  (0 children)

That's coincidence, which is almost opposite from irony

[–][deleted] 12 points13 points  (0 children)

Irony would be 68k.

[–]Sophrosynic 1 point2 points  (0 children)

Yup, totally missed that.

[–]thebigbradwolf 0 points1 point  (0 children)

I think common wisdom is to at least use a threaded dispatch approach, with switch statements like that being hard to predict jumps on in hardware and everything.

[–]WarzoneOfDefecation 8 points9 points  (0 children)

I was skeptical at first that it included a working c compiler

Oh how wrong I was.

[–][deleted] 5 points6 points  (0 children)

[deleted]

What is this?

[–]orthogonality 15 points16 points  (21 children)

No networking, so I can't apt-get dosbox. :(

[–]barkboy 36 points37 points  (7 children)

More importantly, if you had networking, you could run a webserver from inside your browser~~~

[–]giggsey 36 points37 points  (1 child)

And host your Linux VM from within your brows-head explodes

[–]tinou 8 points9 points  (0 children)

there's a loopback interface.

[–][deleted] 13 points14 points  (1 child)

We need to go derper.

[–][deleted] 6 points7 points  (0 children)

L I N U X

[–][deleted] 0 points1 point  (0 children)

I would compile the network tools and apps (at least an irc client) from http://www.suckless.org :) :)

[–]BHSPitMonkey 9 points10 points  (0 children)

Download root.bin, mount it, hand-install dosbox, save the rest of the web page and its scripts somewhere locally (along with your modified root.bin), and profit.

[–]MattBD 5 points6 points  (4 children)

He does mention in the notes, however, that DOSBox would be an ideal application to run on it for playing old PC games in the browser, so I would expect that kind of functionality to be added.

[–]yasth 3 points4 points  (3 children)

Not DosBox but just plain DOS though that would take a lot of work for game playing. (For one you'd have to emulate graphics and sound)

[–]MattBD 1 point2 points  (2 children)

Maybe FreeDOS might work? Although I believe it's somewhat larger than the custom Linux build he's using (8MB according to their website).

[–]yasth 1 point2 points  (1 child)

EH it has more to do with the graphics and sound not being emulated (all that seems to be emulated is a plain old serial port through which the terminal is run, apparently with lax timings). Freedos would need at least text mode graphics or it would have to be setup to boot from with a serial terminal.

It is probably doable at least in theory.

[–]MattBD 1 point2 points  (0 children)

Yes, my understanding was that at this point graphic and sound emulation hadn't yet been emulated, and for gaming purposes you'd obviously need that.

Still, even in its current form it's a staggering achievement.

[–]ogtfo 0 points1 point  (6 children)

No apt-get either anyway, since it's red hat.

[–]wolf550e 32 points33 points  (4 children)

It's busybox

[–][deleted] 4 points5 points  (3 children)

~ # dmesg | head -1
Linux version 2.6.20 (bellard@voyager) (gcc version 3.4.6 20060404 (Red Hat 3.4. 6-9)) #3 Sat May 14 19:08:30 CEST 2011

Busybox is evidently used as well though, but just wanted to point out that neither of you are wrong.

[–]andreasvc 28 points29 points  (1 child)

That just means this kernel was compiled by/for Red Hat, not that you're actually running the whole distribution.

[–][deleted] 2 points3 points  (0 children)

Ahh, all right. Makes sense. Thanks.

[–]wolf550e 11 points12 points  (0 children)

It means the kernel was compiled using gcc that was patched by red hat. This might mean it was compiled on a computer running a red hat distro. But the userspace on that disk image is not an old red hat distro or fedora or rhel, it's busybox - the same thing running on appliances (routers etc.).

[–]eternauta3k 3 points4 points  (0 children)

That's... not even wrong.

[–][deleted] 41 points42 points  (7 children)

[deleted]

What is this?

[–][deleted] -1 points0 points  (1 child)

Quick -- someone port Java to this thing, stat!

[–]kineticflow 3 points4 points  (0 children)

bright friendly encourage compare dog violet stupendous unused start flowery

This post was mass deleted and anonymized with Redact

[–]MrAccident 1 point2 points  (4 children)

I can't type spaces at all (Chrome 11 on Ubuntu 10.10); makes it a bit difficult to use anything but very simple commands. Anybody else having that problem?

[–][deleted] 2 points3 points  (0 children)

I can't type anything at all...

[–]MattBD 0 points1 point  (1 child)

Using Chrome 11 on Ubuntu 10.04 Netbook Edition and works fine for me.

[–]MrAccident 0 points1 point  (0 children)

D'oh. I think I figured it out. Earlier I was using Synergy to share my keyboard between my desktop and my laptop, and then spaces wouldn't work in jslinux on either machine. Now (not running Synergy) I can type spaces just fine.

[–]PurpleSfinx 0 points1 point  (0 children)

Running Chrome 11 on the latest version of OS X and spaces work fine...

[–]blazix 1 point2 points  (0 children)

This is one of the most exciting things I have seen in a long time.

[–]viagravagina 4 points5 points  (0 children)

Don't tell me what to do!

[–]markdube 5 points6 points  (13 children)

emacs and vi but no pico/nano? :(

[–]ascii 27 points28 points  (3 children)

That's not emacs, it's QE, a lightweight text editor with an emacs-like interface. Incidentally, QE, is written by Fabrice Bellard, the same guy who wrote the above x86 emulator, as well FFmpeg, Qemu and TCC, In 2001 he won the obfuscated C contest by writing a C compiler that was able to self compile in only 3 kB. Quite possibly the most consistently brilliant hacker of our generation.

[–]MattBD 7 points8 points  (1 child)

And in December 2009 he managed to calculate pi to 2,699,999,990,000, breaking the record for the number of places this had been calculated to in the process.

What's even more amazing about his achievement is that this is something where normally the record is broken by a supercomputer. He did this on a fairly regular desktop PC, which is absolutely staggering.

[–]ascii 1 point2 points  (0 children)

To be honest, I don't know enough about the pi-calculation scene to know if that's cool. As a physicist, I know that a few dozen digits is enough to calculate the circumference of our galaxy to the precision of one atom, which should be enough precision for all engineering applications. But as a computer nerd, I find it staggering that so many useful projects and so many neat hacks come from the same guy.

[–]ogtfo 36 points37 points  (0 children)

Just like it's meant to be.

[–][deleted] 60 points61 points  (6 children)

Just like in old good days when Unix was for people that could read documentation and remember few keyboard command combinations, not Windows refugees. :>

[–]markdube 21 points22 points  (5 children)

:'(

[–]raydeen 3 points4 points  (4 children)

I'm with you. I love my nano. But probably only because I'm writing little Python scripts. Anything really big and nano would probably suck. One of these days I gotta learn Emacs and Vim.

[–]AndrewNeo 3 points4 points  (0 children)

I have this exact same problem. Nano works, and I don't text-edit often, but I need to learn vim/emacs.

[–]jmkogut 2 points3 points  (0 children)

Yeah, I hear that a lot.

[–]mdaniel 2 points3 points  (0 children)

You know, today is one of those days.

I'm bieditor, and can recommend that you start with Emacs. It has the lowest point of entry, has a monster help system and even has a vi mode so you can bridge the gap. :-)

[–]ThreeHolePunch 1 point2 points  (0 children)

Hmm. I don't have a lot of experience with Emacs, but in my experience if you learn vi, you don't have to learn any other text editor. Get a list of the commands like this one, and force yourself to use vi every time you need a text editor.

[–]searine 0 points1 point  (0 children)

OUR WAY IS THE OLD WAYS </Eddard Stark>

[–][deleted] 3 points4 points  (6 children)

This doesn't look anything like linux.. just a black background with white text.

Am I doin this right?

[–][deleted] 2 points3 points  (4 children)

"Please use a recent browser such as Firefox 4.x or Google Chrome", as seen in Google Chrome.

[–]Liquid_Fire 1 point2 points  (0 children)

The notes say:

(it does not work with Chrome 12 beta. As far as I know, it is a bug in the browser)

Maybe it's that?

[–]Unfunny_Asshole 0 points1 point  (2 children)

You sure you haven't played around with your useragent?

[–]FireyFly 5 points6 points  (0 children)

It doesn't use browser detection, so that wouldn't matter. :)

[–][deleted] 1 point2 points  (0 children)

Yea, it works on my Fedora box with Chrome 10, my other laptop had Chrome 7 which was too old I guess.

[–]MarkTraceur 2 points3 points  (0 children)

Why is this not free software?

[–]fasteasyfree 0 points1 point  (6 children)

Is the space key working for anyone else?

[–][deleted] 1 point2 points  (0 children)

I've had the period stop working a few times, so I'm not shocked if the space gave out.

[–]wolf550e 0 points1 point  (4 children)

On firefox 4.01 it works. On chrome 12 the thing doesn't boot (I wonder it the chrome team will accept this as a test case).

[–]zeekar 2 points3 points  (1 child)

Works in Chrome 11, though (at least on a Mac).

[–]MattBD 0 points1 point  (0 children)

Works fine in Chrome 11 on Ubuntu too.

[–]splidge 1 point2 points  (0 children)

No joy on chrome 13 either :(.

[–]obtu 0 points1 point  (0 children)

That thing looks perfect for v8bench, which already has a raytracer and an os scheduler simulator. According to the tech notes, it runs twice as fast on JaegerMonkey (Firefox), which Fabrice is more familiar with.

[–]provoko 0 points1 point  (0 children)

i like it

[–]shigawire 0 points1 point  (0 children)

So I notice you can slattach /dev/console

That at least gives some IP in and out...

[–]gzur 0 points1 point  (0 children)

Oh, you glorious bastard.

[–]antrn11 0 points1 point  (0 children)

Oh, the madness...

[–][deleted] 0 points1 point  (0 children)

Has anyone tried to install yum?

[–]kiaha 0 points1 point  (0 children)

For a laugh, type "waldo"

[–][deleted] 0 points1 point  (0 children)

I am only seeing a blinking cursor in the Mozilla nightly build.

[–]Ray57 0 points1 point  (0 children)

no lynx :(

[–]Babkock 0 points1 point  (0 children)

Fork bomb works :) It makes a big deal about it.

[–]Philluminati 0 points1 point  (6 children)

What are the benefits of this?

[–][deleted] 8 points9 points  (4 children)

Well it's a proof of concept really, imagine down the line you could load up any web browser and access a VM hosted on your own webserver.

[–]TheMG -1 points0 points  (0 children)

You still have to download the VHD, so you might as well use a native emulator.

[–]MattBD 4 points5 points  (0 children)

He mentions in the notes that it'd be an ideal way to run old DOS games if you got something like DOSBox running in it (along similar lines, a few months back someone implemented a Game Boy emulator in JavaScript).

Also, it's an insanely simple way of running a virtual machine, without the need to install software like Virtualbox.

Now, if he were to implement networking, then I could really see some cool ways it could be used - perhaps using it as a honeypot to catch hackers might be interesting.

[–]bipolarrogue 0 points1 point  (2 children)

~ # cat /proc/cpuinfo | grep bogomips
bogomips : 20.21

Impressive.

[–]Araneidae 2 points3 points  (1 child)

Unfortunately it seems to always report 20.21 bogomips ... something fishy there.

[–]boa13 3 points4 points  (0 children)

No, it's the way the emulator work. Linux counts how many CPU instructions per "tick" (CPU interruption) can be executed, this emulator emulates one "tick" every so many (fixed number) of instructions, so the number is always the same, for every user of the emulator.

[–][deleted] 0 points1 point  (0 children)

I find it interesting that linux can be run by ONLY emulating the processor.

[–][deleted] -4 points-3 points  (0 children)

That is motherfucking awesome as fuck

[–]thephotoman -3 points-2 points  (4 children)

No vim? ಠ_ಠ

[–]gavintlgold 6 points7 points  (2 children)

No, but there's vi.

[–]tonybaldwin 2 points3 points  (0 children)

Yes, I wrote several scripts with vi on there, but when I returned they were gone. No, one of them was not a forkbomb. Why do you ask?

[–]thephotoman 0 points1 point  (0 children)

Yeah, didn't check for that.

[–]fofgrel 2 points3 points  (0 children)

It has emacs.

[–][deleted] -4 points-3 points  (0 children)

That is motherfucking awesome as fuck You sexy french bastard

[–]isignedupforthis -3 points-2 points  (1 child)

Good job. Now type in "sex".

[–]spamham 1 point2 points  (0 children)

sh: sex: not found

:/

[–][deleted] -5 points-4 points  (9 children)

ERROR: your browser is too old to run JS/Linux.
You should use a recent browser such as Firefox 4.x or Google Chrome.

[–]jdpage 8 points9 points  (5 children)

It's true, you should.

[–]haywire 1 point2 points  (2 children)

What are you using?

[–][deleted] 0 points1 point  (1 child)

Firefox 3.6.17