
Run Unix processes inside your browser - corv
https://browsix.org/
======
mwcampbell
Reminds me of this talk by Gary Bernhardt:

[https://www.destroyallsoftware.com/talks/the-birth-and-
death...](https://www.destroyallsoftware.com/talks/the-birth-and-death-of-
javascript)

~~~
fidz
I don't want his prediction happen, unless we have WebAssembly.

~~~
cyberpunk
I've not watched that in a while! Enjoyed it again, so thanks!

Have we not almost arrived at this dystopian javascript hella-future though?

I mean, with unikernels which run node in ring 0:

[http://runtimejs.org/](http://runtimejs.org/)

And that we can run an emulated linux in browser:

[http://bellard.org/jslinux/](http://bellard.org/jslinux/)

I'm doing my best to ignore it all....

------
userbinator
Looks like yet another example of the [https://en.wikipedia.org/wiki/Inner-
platform_effect](https://en.wikipedia.org/wiki/Inner-platform_effect) ...when
will this abstraction madness end?

 _Extended JavaScript runtimes for C, C++, Go, and Node.js that support
running programs written in these languages as processes in the browser._

Does that mean it's an interpreter? The main page doesn't say much.

~~~
nteon
Hi - main author here.

Browsix is not an interpreter. Browsix provides a shared kernel and primitives
like system calls to _existing_ interpreters and runtimes that target
JavaScript.

For example, we extended both the GopherJS and Emscripten compilers and
runtimes to talk to our shared kernel, so that processes written in C and Go
can run in parallel (on separate Web Workers) and communicate over pipes,
sockets and the filesystem in the browser (much like they can in a standard
Unix environment).

~~~
cyberpunk
Are you not easier emulating x86 then trying to reimplement the entire linux
syscall table in javascript?

Then you can run anything that works on ia32 unmodified -- gcc, linux, X,
firefox.. Whaytever...

Someone already did it:
[http://bellard.org/jslinux/tech.html](http://bellard.org/jslinux/tech.html)

~~~
nteon
JSLinux is a tremendous feat of engineering.

If you want to run realistic programs in the browser (and not just technology
demos), WebAssembly, asm.js, and compilation to JavaScript in general is the
way to go. WebAssembly can easily execute within a factor of 2 of optimized
GCC binaries, whereas JSLinux is ~80x slower.

Paired with compilers like Emscripten and GopherJS Browsix has the potential
to be a relatively fast and lightweight solution to running legacy code in the
browser in a way that integrates with existing tools for web UIs.

~~~
cyberpunk
Do you have a real world use case for this sort of thing? I'm digging the
ability to do these kinds of satanic rites, but I'm not really sure that
there's a practical use today other than pushing the bounds of what's
possible..

~~~
nteon
I think the most compelling use case is running legacy code in the browser
(and in applications like Atom and Visual Studio Code) - like our Latex
example.

Another good use case are command line tools like graphviz. Someone wrote a
wrapper around an emscriptenized Graphviz that looks great, but Browsix should
lower the bar for using great existing tools like these from JavaScript.

------
vessenes
This is still really rough. I see lots of "why?" questions in the comments
here, so I'll tell you what I immediately thought of -- getting close to a
container system on an iPad Pro would be really amazing. For a while I
traveled with just an ipad pro for work, and one of the largest pain points
was the lack of any real OS for work without ssh-ing somewhere.

That said, my vibe is that by the time this matures enough (and Safari on iOS
works well enough with it) that it's performant, there will likely be another
solution that's better.

~~~
Mahn
One solution for this problem that is very mature and stable today is not
using an iPad Pro for work on the go :)

Seriously though, as a developer I find the Surface Pro far better suited for
mobile productivity, I can't imagine getting much done on an iOS device while
traveling besides answering email.

------
digi_owl
Their github may be more informative.

[https://github.com/plasma-umass/browsix](https://github.com/plasma-
umass/browsix)

Seems they are using web workers to implement a POSIX environment.

And their shell demo do not even support cd(!).

~~~
chei0iaV
It doesn't support a lot of very basic things, like variables

    
    
        $ TEST=1
        $ echo $TEST
        $TEST
    

Interestingly, in the example they show:

    
    
        $ cat README | while read L; do echo "README: $L"; done
        

...and yet:

    
    
        $ read L
        /usr/bin/read: command not found
        $ while true; do break; done
        /usr/bin/while: command not found
        $ echo "quotes"
        "quotes"
    

Seems like a horribly backwards approach to implementing a posix shell...

~~~
ris
Surely one can just compile bash for browsix though?

~~~
nteon
That example is actually running dash - the Debian Almquist shell.

The weirdness (and reason that cd + setting variables doesn't work) is because
whenever you type a command in, it executes:

$ dash -c '$COMMAND'

Rather than having a long-running shell process listing to standard in. We
plan to fix this and implement a full TTY subsystem in the next month or so.

------
amelius
It would be seriously cool to compile Chromium and run it inside Firefox, or
the other way around :)

~~~
icebraining
You're in luck: you can run Windows 95 in your browser, and then launch IE in
that! [https://win95.ajf.me/win95.html](https://win95.ajf.me/win95.html)

~~~
amelius
Interesting link, but I got a "nested emulation timeout" exception when I
tried to run that.

------
fredley
Are we reaching the limitations of Atwood's Law[1]?

[1]: [https://blog.codinghorror.com/the-principle-of-least-
power/](https://blog.codinghorror.com/the-principle-of-least-power/)

------
haddr
The latex demo has blown my mind! How did they do it? I can undesrstand
running some shell in the browser, but the _whole_ latex distro? Amazing...

------
snadal
Disclaimer: not being sarcastic at all.

Can someone explain what can be the use case for this?

~~~
ddp
No, I cannot. I'm mystified why anyone would spend their time building this...

~~~
bgirard
Because it's a good demonstration of how the Web is advancing by showing that
this kind of thing is possible.

It's also a good project to learn about both the web and POSIX. Not that this
kind of project is required when applying to job but it would seriously catch
my attention when reviewing a candidate for any web or systems job. It's also
top of hacker news so it's an excellent way to get your name out there.

~~~
the8472
I wouldn't call this an advance. The web does not interact well with your host
system. it creates its own silo. and this is just another step in the silo
direction. why talk to the host at all? embrace the web! entrust all your
files and software to us!

you're emulating a filesystem inside the browser to manage files. while you
have highly advanced filesystems sitting outside the browser with direct
access to NVMe SSDs, much lower power consumption and all that. But nope, "do
it in the browser" nullifies all the advances that native makes.

------
dfarts
We can already do this I think:
[http://bellard.org/jslinux/](http://bellard.org/jslinux/)

~~~
detaro
Very different approach: emulating a full x86 machine and booting an OS into
it, vs recompiling applications to run in the browser and providing kernel
APIs. The latter should be a lot more faster and integrate better with other
web tech, but of course can't run arbitrary application binaries.

------
sandebert
Does this mean we finally can ditch JavaScript and use bash when we code our
web apps? (Only joking a little bit, actually curious about the answer.)

~~~
sjrd
Not if you want to manipulate the DOM or use many of the browser APIs, AFAICT.

~~~
kpil
Ah, but why not expose the DOM on /sysfs and just hack away using sed and awk.
What could possibly go wrong.

------
seiferteric
Hmm, when I first opened this I thought they implemented a POSIX api on top of
js, but it does not look like they actually did this. Actually I think it
could be really cool if someone did this. Not sure what it would take, maybe a
libc and kernel and then recompile gnu tools and a character driver for the
terminal, local storage for persistence. I think it could be a neat
alternative to spinning up a VM to test something, obviously not useful for
running anything real. If it was fast enough though... I could see using it as
a dev environment if you were stuck in windows or something. Or just for
online coding tutorials, or a way to teach kids "real" computer OSes if they
only tablets or something.

~~~
emeryberger
Doppio ([https://github.com/plasma-umass/doppio](https://github.com/plasma-
umass/doppio)) is exactly this: a POSIX layer (for a single process), while
Browsix is a Unix layer. Both are JS only. Doppio implements a ton of libc
functionality, enough to host a full JVM interpreter (see [http://plasma-
umass.github.io/doppio-demo/](http://plasma-umass.github.io/doppio-demo/)).
Doppio contains BrowserFS (available separately as
[https://github.com/jvilk/BrowserFS](https://github.com/jvilk/BrowserFS)), an
in-browser file system that abstracts over local storage _and_ lets you mount
remote filesystems like Dropbox, Zip files, and more. Archive.org is using it
for all of its DOS and Windows games.

------
drorwolmer
$ curl google.com

Error while executing undefined: Uncaught TypeError: Cannot read property
'split' of undefined

------
automatwon
It can run C++? Cool. Can you run a web browser instance in it? Then you'd
have a web browser, running inside an operating system, running on top of a
web browser, running on top of an operating system. Potentially, this
operating system is a virtual machine, inside another operating system. But
wait! There's more! This operating system is running inside of a browser. It's
JavaScript all the way down! That's right we're running inside of a an
advanced computer simulation written in JavaScript. Now about that XDS (cross-
dimensional scripting) attack..

------
grogs
Can I use this to run Scala Native apps in the browser? Making Scala.js
redundant. :P

~~~
mwcampbell
Perhaps, but you wouldn't actually want to run a Scala program that way.

To implement C semantics, Emscripten uses a single, large JavaScript typed
array as the heap. To the JS garbage collector, this heap is a big, opaque
blob. Then your Scala Native program has its own garbage collector operating
within its heap. The two garbage collectors are unaware of each other. This is
just a vague intuition on my part, but it seems to me that an arrangement
involving nested garbage-collected heaps is bound to be suboptimal. Scala.js
is much better in this regard, since Scala objects are just JS objects,
sharing a garbage-collected, compactable heap with the other JS objects.

~~~
paulddraper
Asm.js optimized browsers should make the unneeded JS GC have no overhead.

But you are correct that it's a bad idea. Like running Scala.js on
Rhino/Nashorn

------
roywiggins
I wonder if it can run emacs...

~~~
IncRnd
Emacs must always be the first target, right? :)

The real use case is running the browser in emacs, then that browser can run
emacs with evil. That's a super quick way to get vim commands in emacs without
any configuration issues.

------
libeclipse
Can a more experienced/knowledgeable HN user than myself comment on any
security implications that arise as a result of this?

~~~
H4CK3RM4N
I'd assume that it wouldn't be any worse than code written in js. My best
guess would be that they're implementing processor instructions in HTML5, then
doing a compiler from there.

~~~
bradfitz
Which x86 instruction is <MARQUEE>?

~~~
Senji
MRQ

------
the8472
Now start a JVM on it.

~~~
mataug
and be sure to run a browser inside the JVM to check webmail.

~~~
azinman2
Throw on Emacs and it's system-in-a-system and you'll have an infinite mirror
of horribleness.

------
to3m
Just goes to show the truth of the old adage: those that know Unix are
condemned to reimplement it.

------
luckystarr
Finally I can put a real vim instance on all my textarea fields. :)

------
ensiferum
Mmmh, I don't need a browser to run these applications though.

------
1ris
Of of the things i always wanted to do, but never had the time to.

------
giis
Is this like shellinabox or ajaxterm - terminal emulators? If not, could you
let us know the differences.

------
the_duke
So, how does it actually work? The dedicated section on the page is not very
informative.

~~~
detaro
Various languages can be compiled to JS, e.g. C/C++ using emscripten. This
project implemented POSIX/Linux APIs in JS using browser features, so now you
can compile applications that depend on those APIs to JS and run them in the
browser. At least that's what I got from skimming the paper.

~~~
the_duke
That still doesn't explain how syscalls are exposed as webworkers without a
modified browser.

~~~
ris
They aren't _real_ syscalls. From the looks of it this is essentially a mock
POSIX-ish "os" for containing webassembly-compiled applications.

What _will_ be interesting is to see if anyone ever gets to implementing X11
emulation.

------
imode
so, enter an invalid command, then press and hold backspace.

kind of hilarious. wonder why that is..?

~~~
cestith
I'm not sure of the cause, but it's a known issue.

$ cat README Welcome to Browsix!

For more info, please check out: [https://github.com/plasma-
umass/browsix](https://github.com/plasma-umass/browsix)

Known issues with this shell: \- 'cd' is not implemented. \- backspacing past
'$' produces "interesting" results $

------
sigill
Funny to see this. I once considered x86 emulation plus emulation of a number
of Linux system calls in JS as a way to get Go programs running in the
browser. In contrast to the submission, this would have allowed umodified
programs yo be run, even written in another language than Go.

------
cyphar
There's also RISC-V's ISA emulator which lets you boot a GNU/Linux install in
your browser. [http://52.32.189.224/angel-
simulator/](http://52.32.189.224/angel-simulator/)

------
turnip1979
Can someone knowledgeable about NaCL comment?

------
paulddraper

        $ curl --help
        Error while executing undefined: Uncaught TypeError: Cannot read property 'split' of undefined

------
notadoc
Fun

