12 ms·
Run Unix processes inside your browser
- libeclipse 10y agoCan a more experienced/knowledgeable HN user than myself comment on any security implications that arise as a result of this?
- H4CK3RM4N 10y agoI'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.
- H4CK3RM4N 10y agoI'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.
- dfarts 10y agoWe can already do this I think: http://bellard.org/jslinux/ http://bellard.org/jslinux/
- detaro 10y agoVery 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.
- fredley 10y agoAre 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/
- digi_owl 10y agoTheir 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(!).
- jamescostian 10y agoIt seems they only have these binaries available on their shell demo: ``` $ ls /usr/bin cat cp curl echo exec grep head ld ls mkdir nice node rm rmdir sh sha1sum sort stat tail tee touch wc xargs ```
- userbinator 10y agoAnd their shell demo do not even support cd(!). That means their claim that "Unmodified C, C++, Go, and Node.js programs run as processes on Web Workers" ...is not true, as otherwise they could've just "compiled" e.g. bash or some other shell to run on their system, along with GNU coreutils or similar.
- roblabla 10y agoMy guess is, they can, it's just horrendously slow.
- nteon 10y agoThe shell is dash, compiled from C. We run each command as dash -c "$COMMAND" Processes can change their current directory (We support the chdir(2) system call), but the way the shell demo is currently implemented no state is retained between command invocations. We plan to address this shortcoming soon as part of a bigger TTY refactoring.
- chei0iaV 10y agoIt 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...
- userbinator 10y agoLooks 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.
- detaro 10y agoIf I understand right it compiles said languages to browser-compatible JS and provides an environment for them, so no, I don't think it includes an interpreter in itself. Everything is JS running in the browser's JS interpreter.
- emeryberger 10y agoCorrect. To quote Bobby's comment above: 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).
- ChuckMcM 10y agoIf you start the seed of an idea at least three emulators deep when the browser returns to the top level it thinks it originated that idea.
- prodigal_erik 10y agoThey skipped limbo, where time has no meaning. There you can create a world with only a state machine and infinite tape.
- bryanrasmussen 10y agoBut my browser wouldn't let go of the idea and then it cr....
- deleted 10y ago[deleted]
- mwcampbell 10y agoReminds me of this talk by Gary Bernhardt: https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript https://www.destroyallsoftware.com/talks/the-birth-and-death...
- fidz 10y agoI don't want his prediction happen, unless we have WebAssembly.
- deleted 10y ago[deleted]
- akerro 10y agoThere it is, shoot yourself. https://i.imgur.com/pC6EV0v.png https://i.imgur.com/pC6EV0v.png
- cyberpunk 10y agoI'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....
- grogs 10y agoCan I use this to run Scala Native apps in the browser? Making Scala.js redundant. :P
- mwcampbell 10y agoPerhaps, 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 10y agoAsm.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
- sjrd 10y agoScala.js is not only about making your Scala app run in the browser. It's also (and mainly) about letting you develop in Scala for the Web environment, which includes manipulating the DOM and calling any existing JavaScript library. Scala Native run with Browsix (or compiled to asm.js/WebAssembly for that matter) would not give you that. So no, it would not make Scala.js redundant.
- roywiggins 10y agoI wonder if it can run emacs...
- IncRnd 10y agoEmacs 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.
- notadoc 10y agoFun
- the8472 10y agoNow start a JVM on it.
- mataug 10y agoand be sure to run a browser inside the JVM to check webmail.
- azinman2 10y agoThrow on Emacs and it's system-in-a-system and you'll have an infinite mirror of horribleness.
- nteon 10y agoI know you were kidding, but one of the co-authors of Browsix wrote the Doppio JVM: http://doppiojvm.org/ http://doppiojvm.org/ a full JVM in pure JavaScript. It will soon run under Browsix!
- drorwolmer 10y ago$ curl google.com Error while executing undefined: Uncaught TypeError: Cannot read property 'split' of undefined
- 1ris 10y agoOf of the things i always wanted to do, but never had the time to.
- to3m 10y agoJust goes to show the truth of the old adage: those that know Unix are condemned to reimplement it.
- amelius 10y agoIt would be seriously cool to compile Chromium and run it inside Firefox, or the other way around :)
- mataug 10y agoBrowserception
- agumonkey 10y agoAd infinitum. Or nauseam.
- amelius 10y agoJust once is sufficient. The reason why you would want to do that is compatibility: now you only have to support webkit OR gecko/servo, not both :)
- icebraining 10y agoYou'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 10y agoInteresting link, but I got a "nested emulation timeout" exception when I tried to run that.
- turnip1979 10y agoCan someone knowledgeable about NaCL comment?
- contestabili 10y agook
- snadal 10y agoDisclaimer: not being sarcastic at all. Can someone explain what can be the use case for this?
- ddp 10y agoNo, I cannot. I'm mystified why anyone would spend their time building this...
- bgirard 10y agoBecause 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.
- prodigal_erik 10y agoIt's the JavaScript platform that's advancing, leaving the web behind. A browsix process might happen to use a web page to bootstrap but it can't be part of the web because it doesn't have a URL.
- nilved 10y ago> Because it's a good demonstration of how the Web is advancing by showing that this kind of thing is possible. This being possible is a glaring deficiency of the Web, and an example of how it is stalling the state of the art.
- haddr 10y agoThe 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...
- the_duke 10y agoSo, how does it actually work? The dedicated section on the page is not very informative.
- detaro 10y agoVarious 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 10y agoThat still doesn't explain how syscalls are exposed as webworkers without a modified browser.
- detaro 10y agoThey don't expose syscalls, they implemented replacements for them. There is no access to anything outside the browser environment. Web Workers simulate processes, file system calls access a virtual file system etc.
- ris 10y agoThey 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.
- pgbovine 10y agotechnical paper is online: https://arxiv.org/abs/1611.07862 https://arxiv.org/abs/1611.07862
- nteon 10y agoWe use Web Workers as the basis for our processes, and processes perform system calls to the kernel (running on the main browser thread). Our standard system call mechanism is asynchronous and uses the standard postMessage API to/from Web Workers. When executing a system call, the language runtime saves the current call stack, and when the Web Worker gets a response to the system call, it resumes that thread. So we build these low-level primitives (kernel, system calls, processes) on top of APIs the browser provides, and extend to-JS compilers + runtimes to use these primitives.
- sigill 10y agoFunny 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.
- seiferteric 10y agoHmm, 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 10y agoDoppio (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.
- vessenes 10y agoThis 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 10y agoOne 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.
- sandebert 10y agoDoes 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.)
- ensiferum 10y agoMmmh, I don't need a browser to run these applications though.
- imode 10y agoso, enter an invalid command, then press and hold backspace. kind of hilarious. wonder why that is..?
- cestith 10y agoI'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 $
- giis 10y agoIs this like shellinabox or ajaxterm - terminal emulators? If not, could you let us know the differences.
- paulddraper 10y ago$ curl --help Error while executing undefined: Uncaught TypeError: Cannot read property 'split' of undefined
- cyphar 10y agoThere'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/
- luckystarr 10y agoFinally I can put a real vim instance on all my textarea fields. :)
- deleted 10y ago[deleted]
- automatwon 10y agoIt 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..