254 comments

[ 4.4 ms ] story [ 266 ms ] thread
Not sure how long ago he posted this. This guy never ceases to amaze me. He's the Grigori Perelman of Hackerdom.
Not long ago:

Last-Modified: Mon, 16 May 2011 21:14:50 GMT

uname -a shows

Linux (none) 2.6.20 #3 Sat May 14 19:08:30 CEST 2011 i586 GNU/Linux

I wonder why he chose this kernel version instead of the latest
This is the most amazing thing I've ever seen in my browser.
interesting!
The page was near-unreadable for me because the CSS uses the font stack "courier,fixed,swiss,sans-serif", and courier is just too thin and wispy against a black background. I opened Firebug and changed the CSS declaration to be "monospace" and then all was right with the world.

That said, it's a phenomenal achievement, and should be a great way for websites to demonstrate command-line tools to people. :)

(also: browsers let you store more information with DOM Local Storage than you could in a cookie; If you could expose that to Linux as a block device...)

Anyone know how to get the network working? ping/wget don't work. But seriously, this is pretty flippin sweet!
Implement emulation of a network card... ;) The tech notes page states that "there is no network emulation at this point".
Yeah. That would be a whole interesting can of worms. Would need PCI/USB/whatever bus your ethernet card was on. Plus emulation of the selected ethernet card itself.

Loopback (which is present) is so much simpler.

I guess a tun/tap to some server-side service might be possible too, but perhaps not very interesting. The x86 dynamic library api suggested in the tech notes sounds more useful.

Edit: Easier idea might be adding ttyS1 and connecting that to a websocket on the server. Combined with something like socat or ppp, that ought to work. Since the console is already ttyS0 and connected to the js terminal, it might be doable even with the obfuscated source.

Maybe power the network using a server side relay script and an ajax request?
Or you can write a simple paravirtualized eth card driver and its implementation side, without trying to emulate real hardware. Linux is free software, take advantage of that.
You can't - Javascript can't generate arbitrary network traffic like that. You'll have to wait for someone to write a driver for /dev/json, I guess. ;)
"ping 127.0.0.1" works :)
this is some crazy shit
My favorite bit:

# cat /proc/cpuinfo

...

f00f bug: yes

#

Hah!

20 bogomips by the way, at least on Chrome on a MacBook Pro.

I sense a whole new era of browser performance testing..

Okay, I take that back. My favorite part comes from the tech notes, when he lists all the stuff he added:

[... and] my unfinished but usable emacs clone QEmacs.

?!? I am wasting my life in comparison to this super-hacker.

Further update: qemacs works.

Unfortunately, M-x spook does not, so he clearly still has some work to do for feature completeness.

Esc-x works for me.
Heh, I get 'Illegal instruction' when I compile and run:

long main = 0xc8c70ff0;

That used to crash my old Pentium box.

Neat. You can mount sysfs like so:

  # mkdir /sys; mount -t sysfs /sys /sys
That would allow you to look at the emulated hardware that is present. Looks like only virtual devices are present -- ram, loopback network etc.

Makes sense to me. The MVP here is cpu emulation.

After FFmpeg (used in all your TVs and gadgets, very likely), QEmu (used also by Xen and VBox and other), tcc and his IOCC entries, the DVB-T emission with an ATI card, Fabrice comes, once again with something crazy...

He is really impressive...

Any Macarthur Grant folks floating around here? Take note! That's an impressive resume.
Great idea. That guy deserves it. Though I suspect he would be too modest to accept the money since he GNUed all his creations.
In the days before KVM, he wrote a paravirtualization kernel module for QEMU (kqemu), gave away binaries and tried to sell the source. I don't know what happened with that business.
Yes he wrote that.

Indeed he also wrote QEMU.

Wikipedia says you have to be a US citizen or resident for the MacArthur grant. As far as I know he's French.
According to the Wikipedia page, you need to be a US citizen or resident to be eligible. He seems to be residing in France and I doubt he has a US citizenship. Otherwise, he definitely fits the bill.
damn it they should take mine and give it to this guy . i just can not believe what my browser can do . what the f k!
Don't forget that he discovered the fastest known algorithm for computing an arbitrary digit of pi. If you ever are tempted to get egotistical, just think of this guy. If you are prone to low self esteem, avoid reading about him.
And still, he has normal job in a normal company... Not in a start-up or not in a mega-tech-corp...
Perhaps he's able to produce great stuff like this because he has a normal job in a normal company.
It isn't so much the "normal" company thing, I think, as having a good work/playthings/life balance. The main reason none of my personal/toy/experimental projects are languishing on note paper or electronic equivalent is that my balance is very wrong and getting worse!

He is presumably working for a good company (or at least one that is good for him) and has time management skills himself.

That, and a brain to be envious of plus a supply of inspiration!

No more excuses, I'm going to finish those damn projects I have on the backburner...

Seriously, who does Bellard work for?

He seems to leave virtually no trace (other than awesome software) on the Internet. I googled the shit out of him tonite...

He works for Netgem.
"He seems to leave virtually no trace (other than awesome software) on the Internet."

Probably because he spends his time writing awesome software.

Take a look at his IOCCC entry in 2001/02:

OTCC is an Obfuscated Tiny C Compiler for i386-linux. It generates FAST! i386 32 bit code (no bytecode) and it is powerful enough to compile itself. OTCC supports a strict subset of C. This subset is compilable by a standard ANSI C compiler. OTCC compiles, assembles, links and runs C code without the need of any other program.

http://www0.us.ioccc.org/2001/bellard.hint

(Note for those not familiar with the IOCCC: This is done in 2048 bytes)

Whatever happened to IOCCC? Last update was they announced an announcement due a year ago; nothing since.
So pg was wrong, the greatest hackers don't use Lisp, they write in (and invent) obscure versions of C all day.
One of my favourite hackers is an academic who creates languages just for fun.
Great hackers can use whatever languages/tools they like. The fact that they're being great is not the consequence of the tools they chose, but of the masterpiece work they achieved.

I am always fond of such an analogy: in terms of efficiency, the greatest hackers has an algorithmic complexity of O(1); meanwhile, the majority of us may be O(n), if you can manage to get a O(log n) you can make into the club of good hackers. The tools, be it OS, programming languages, etc, are only a constant coefficient to that complexity, i.e., they can make you noticeably more efficient, but they won't improve your "greatness".

Close but I think you have your orders understated. A normal programmer faces O(n^2), while a great programmer achieves O(n log n). Really bad programmers do O(k ^n) amount of work to achieve the same, with k>2.
Why k > 2? k > 1 is bad enough. Otherwise, recursive fib(n) would be just fine (O(~1.618^n)).
Because 1.00000000000001 ^ N is not bad for most values of N that you will actually use.
Pity me - I work in pretty much the same role as Fabrice in one of his company's direct competitors...
Didn't know about this guy! Unbelievable track record of consistently releasing groundbreaking software. Oh, and the x86 js emulator is cool too! made my day!
~ # tcc -o hello hello.c

~ # ./hello

Hello World

That is just too impressive for me to process.

boots in firefox on android although you can't type anything. I am amazed
Woohoo! Kernel panic! Haven't seen one of those in... well... forever. (Newbie here)

Edit: This is damn cool.

I'm utterly dumbfounded. Not only does it boot, it's got emacs, and a compiler.

  Welcome to JS/Linux  
  ~ # emacs test.c
  ~ # cat test.c                                                                                                                                                 
  void main(void) {                                                               
      printf("Hello World!\n");                                                   
  }      
  ~ # tcc test.c -o hello                                                         
  ~ # ./hello                                                                     
  Hello World!
[Edit: just realized that there is already a 'hello.c' in the directory that shows just this with better diction.]
adduser works (except you need to create a /home directory)
cd /bin for binaries. I just tried telnet, but fails as "no network"
If you start the httpd you can telnet HTTP requests by hand.
and VIM !
I don't see vim in there, but there's a minimalistic vi.
Looks like it's part of busybox.
(comment deleted)
(comment deleted)
(comment deleted)
Unbelievable, this is like magic. I am totally impressed. It is a real linux instance. BTW. I see the hello.c file someone mentioned here. Have we all mounted the same disk image?

I see so many use cases for this, but I don't fully understand what is going on behind the scenes. Maybe someone can shed some light on it:

  1) How is the disk emulated. Is it a local image, or is it running on the backend?

  2) Is there a remote possibility to get the networking up and running?

  3) Can the disk image be externally accessed to be customized?
1): The disk doesn't seem to be emulated; it's just a rootfs in RAM.

2): See another thread here.

3): Check out cpux86.js. In the start() function at the very end, the following section might be enlighting (even though it is a bit obfuscated by a javascript compressor):

  function start() {
  [...]
    If=32*1024*1024;
    ya.phys_mem_resize(If);
    ya.load_binary("vmlinux26.bin",0x00100000);
    Jf=ya.load_binary("root.bin",0x00400000);
    start=0x10000;
    ya.load_binary("linuxstart.bin",start);
    ya.eip=start;
The files vmlinux26.bin, root.bin and linuxstart.bin are fetched from the server.
Thanks for the info. I got it running locally with those bins you mentioned. There is currently no further backend action.
This is completely awesome. When I saw http://cb.vu a few years ago I thought hey, someone has finally done it, but that turned out to be a hack. Kudos to Bellard once again.

Nitpicking: the terminal emulation is messed up. It keeps resizing horizontally, and less gets confused. I'm sure the terminal emulator was fun to play with. A correct vt100 state machine implementation [1] would probably not be quite as fun [2]. There's a vt100.js library used by a couple projects that might improve things. [3]

[1] http://vt100.net/emu/dec_ansi_parser

[2] http://vt100.net/emu/vt500_parser.png

[3] http://fzort.org/bi/o.php

Indeed, this is completely awesome. I first thought it was some remotely hosted virtual machine, but it really runs inside the browser. Insane! Especially considered how fast it is.

When he adds X, we can run Firefox inside Linux inside Firefox inside Linux :')

Edit: seems the terminal emulator supports ANSI escape codes such as the 16 Linux colors, but not the XTerm 256 color mode (\e[38;5;CCm) or Konsole 24 bit (\e[38;2;RR;GG;BBm). Guess it could be easily added as it's HTML.

> When he adds X, we can run Firefox inside Linux inside Firefox inside Linux :')

Reddit has a meme for that. ;) (downvote away, I've earned it!)

The Esteban one?

"I don't always write Linux Kernels"

"But when I do, it's in browser hosted Javascript"

The "yo dawg".
or the INCEPTION for that matter :)
HN would appreciate if you left reddit at reddit.
No network connection yet either :(

~ # ifconfig

     lo   Link encap:Local Loopback

          inet addr:127.0.0.1  Mask:255.0.0.0    
                               
          UP LOOPBACK RUNNING  MTU:16436  Metric:1    
                          
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0  
                  
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0    
              
          collisions:0 txqueuelen:0                              
               
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B
This would require a server-side component, as the browser has cross-domain limitations and couldn't generate arbitrary network traffic anyway. You could tunnel through websockets, however.
> When he adds X, we can run Firefox inside Linux inside Firefox inside Linux :')

Skip the middle man, output gtk via html5 http://blogs.gnome.org/alexl/2011/03/15/gtk-html-backend-upd... (I don't actually know if it still has dependencies on X11 :P)

That would be even better. One could make a Linux device driver to directly access Canvas, WebGL, or even the DOM. It seems that in my post I used "X" as a generic name for "Linux graphics" which is pretty short-sighted.
Gecko's GTK backend has dependencies on X11, if that's what you were asking about.
Interestingly, you can run Firefox inside of Firefox... just enter the url: chrome://browser/content/browser.xul
Sadly my dreams were also crushed when I discovered that lynx wasn't in there.

However, wget is there, so all the building blocks are in place.

As far as I can guess, any networking implementation would have to pass low level requests through a proxy on the server, which would end up making things pretty slow even on an unburdened server.
I just tried out my ansi_colours.sh [1] script and it mostly worked. A few notes:

wget is available, and it would be cool to piggy back the linux network stack through the browser.

cut & paste support is a must for any terminal

The space characters are very narrow. Needs to be monospace.

All fairly minor compared to the coolness of this.

[1] http://www.pixelbeat.org/scripts/ansi_colours.sh

If anything deserves a HackerNews circle jerk, this is it.
I'm sad the source has been compressed so there's no easy human-readable View Source, like there was on the VAX emulator that came up a few weeks ago. :( Still awe-inspiring, though. :)
Chrome dev tools now have pretty print built in. Probably need dev channel.
Any volunteers to wrap a websocket transport in an network interface driver? :)
What are the high-level steps for writing a driver?
(comment deleted)
Feel bad to miss out on this as I am on FF 3.6. But this remind reminded me of a service from a long time ago. Dont remember their name, this was some 10 years ago. But they used to provide a KDE desktop via the browser as a java applet. It was not terribly snappy, but quite surprisingly usable. Any one remembers this ?
With Guacamole (http://guacamole.sourceforge.net/) you can run a VNC session in Javascript, so you can have your desktop, but alas this still needs a remote (virtual) machine running the desktop.

Hmm if network emulation was added to the javascript VM you could combine it with this.

You can build your own custom Linux distribution, run it in your browser, and share it with others using http://susestudio.com/ — it might not be what you're thinking of (as it's only a few years old, not 10 years), but it does what you mention (and more).
Is there a reason you're still on 3.6, if I might ask? 4.0 is a _much_ better browser....
Looks so similar to Linux booted on an embedded device. Nostalgia.

  ERROR: your browser is too old to run JS/Linux.
  You should use a recent browser such as Firefox 4.x or Google Chrome.
No, it isn't. Stop using user-agent matching and start using JavaScript feature detection instead.
It does. It tests for ArrayBuffer support, outputting that message if the necessary constructors aren't found. What browser are you using that you expect to be supported? (Safari doesn't have support for ArrayBuffer, but a recent WebKit nightly does, and this runs in that).
I believe Opera does not support typed arrays either.
I get that error with Opera 11.10
Even in that case the error messages is still wrong. My browser is up to date, it just does not support the needed feature(s).
http://nightly.webkit.org/

I downloaded a webkit nightly from here, and it works now. Also, of note, the nightly picks up all my Safari settings, so it's not too much of a pain.

Yeah, its a poorly worded error message for anyone running the latest version of Opera