
JSLinux rewritten to be human readable, deobfuscated and annotated - luu
https://github.com/levskaya/jslinux-deobfuscated
======
ern
Did the person doing this get his permission? Seems unclear from the readme.

 _The readable source code of the JS PC emulator itself is not yet available.
At this point, any mirroring or redistribution of the code needs my explicit
permission_

<http://bellard.org/jslinux/faq.html>

~~~
alevskaya
The author here. There is a difference in spirit between publicly accessible
and published. I did this in a burst of mania over a few days more than a year
ago and only pushed it to github as an afterthought. I never really expected
more that one or two people would look at it. I am very surprised to see it
here. Given that the hivemind has discovered it, I'll happily contact Mr.
Bellard to see if he wants it out in the world or not.

I'm a synthetic biologist, not a professional coder. I did this primarily
because I wanted to study how emulation worked, and I pushed it solely in the
hopes that one or two other people might find it useful as a study guide of
the original codebase.

------
hwh
When I did a little project using jslinux, just for fun on the Chaos
Communication Camp 2011, I contacted Fabrice about it. And he was helpful and
gave permission to do with the code what I planned to do (I wrote a network
hardware emulation, the corresponding Linux driver and a central server, so I
could connect to the remotely running Linux instances in peoples' browsers).

It's allowed to discuss Fabrice's code, it's allowed to post a de-obfuscator
software tool, but it's certainly not permitted to publicize a derivate
without his consent. It's plain respect for intellectual property.

------
peterkelly
Fabrice Bellard is smart enough that he can probably work directly with
obfuscated code without it having to go through a separate translation
process. The "obfuscated" source could in fact be the original :)

~~~
nimrody
While this may seem like a joke when referring to this size of code, some
people actually write this way:

<http://nsl.com/papers/origins.htm>

(Arthur Whitney's initial implementation of "J")

~~~
derekp7
The example I use is: is it easier to read "a + b", or "a plus b"? In many
cases, what looks like obfuscation is just shorthand notation.

~~~
AnthonBerg
The appropriate counterexample here is which is easier to read, "a plus b" or
"aplusb"? :)

------
szc
Fabrice is a 2 time winner of the IOCCC <http://www.ioccc.org/winners.html#B>.

------
euroclydon
Questioning the wisdom of saying this on the public internet, but the first
line of the first file has caught me up.

What is the purpose of this function, from the clock emulator:

    
    
      function formatter(a) { return ((a / 10) << 4) | (a % 10);}

~~~
alexkus
Why don't you try it for a bunch of input values and find out yourself?

Hint: 0->0, 1->1, ..., 9->9, 10->16, ..., 19->25, 20->32, 29->41, 30->48, ...

~~~
euroclydon
I did. But I don't understand the purpose. Something to do with hex?

------
exim
Pardon my ignorance, but besides being a quite tedious task to write an
emulator, what are genius or other similar aspects of it?

I mean, AFAIK you just need to closely follow the SPECS.

------
SeanDav
I see stuff like this (The original JSLinux, not the de-obfuscated one) and am
simply in awe. Guys like Fabrice Bellard are on another level completely.

Someday, I am going to have to produce an emulator, just to see how it is done
and to try prove that part of me that thinks maybe I am just not good enough,
wrong.

~~~
zellyn
I am working on one now (Apple II, in go). It turns out it is not that
difficult. You just have to be persistent, and be willing to do a lot of
reading.

Although I don't have a ton of free time at the moment, I would be happy to
help people get started.

------
calleskonto
Bellard has updated his site since this was made. The Newer version has an IDE
disk.

------
jscheel
Looking at this code really makes me wish I had taken an OS design class in
school.

~~~
chris_wot
Why not learn now?

~~~
jscheel
Heh, I would love to, but between co-founding a startup and having my first
child, I find that I no longer have much free time anymore!

~~~
robertk
Homeschool your kid and give this to them as homework. No food until they've
written their own!

------
martinced
There are mere mortal programmers, there are geniuses and then there's Fabrice
Bellard. In french slang: "Tu peux pas test".

Go read the list of Open Source project he's done: it's a humbling experience
(even for those who managed to make it big with their startups).

