Linux Kernel Running In JavaScript Emulator With Graphics and Network Support
New submitter warmflatsprite writes "It seems that there have been a rash of JavaScript virtual machines running Linux lately (or maybe I just travel in really weird circles). However until now none of them had network support, so they weren't too terribly useful. Sebastian Macke's jor1k project uses asm.js to produce a very fast emulation of the OpenCores OpenRISC processor (or1k) along with a HTML5 canvas framebuffer for graphics support. Recently Ben Burns contributed an emulated OpenCores ethmac ethernet adapter to the project. This sends ethernet frames to a gateway server via websocket where they are switched and/or piped into TAP virtual ethernet adapter. With this you can build whatever kind of network appliance you'd like for the myriad of fast, sandboxed VMs running in your users' browsers. For the live demo all VMs connect to a single private LAN (subnet 10.5.0.0/16). The websocket gateway also NATs traffic from that LAN out to the open Internet."
Can we go back to trying to target for time+space efficiency rather than buzzwords?
What does one use this for?
Self-achievement? Learning? To get chicks?
Be or ben't
The change of name from LiveScript to JavaScript roughly coincided with Netscape adding support for Java technology in its Netscape Navigator web browser. The final choice of name caused confusion, giving the impression that the language was a spin-off of the Java programming language, and the choice has been characterized by many as a marketing ploy by Netscape to give JavaScript the cachet of what was then the hot new web programming language.
20 characters max for the password? How will I use my favorite poems as passwords?
Infect Windows with Linux Viruses?
Make firefox faster?
Simpler BotNet design?
It was likely a learning project, and is kind of cool. But it is more reason to run NoScript and similar.
20 characters max for the password? How will I use my favorite poems as passwords?
A lack of network support was what was holding back a JavaScript VM running Linux from being useful. No other reason whatsoever.
Imagine a Beowulf cluster of these! It would be the slowest, worst cluster ever!
For the runtime errors. The lovely, lovely runtime errors!
As a component of a Beowulf cluster, obviously.
No kidding!!! What do you say at this point?
..er, forget it.
Join the Slashcott! Feb 10 thru Feb 17!
The most incredible thing is the speed at which it runs: 11.5 MIPS.
My desktop dual-core Xeon W3503@2.40Ghz barely manages 40 MIPS in Chrome.
The iPhone 5s is crazy fast by most standards
Artificial intelligence is no match for natural stupidity
Comparing Java and JavaScript is like comparing a bicycle and a space shuttle. Sure, they're vaguely related as means of transportation but are otherwise completely unrelated.
JavaScript faster than Java? No. It's not. Not even close. Java has fantastic performance when used correctly. It just happens to be a common intro-course language, so lowest-common-denominator sorts of programmers write a lot of crap code with it. The HotSpot VM JIT is basically magic, and the garbage collection beats out everything else.
Can this Linux kernel run a Javascript VM? If so, can that VM run the Linux kernel? And if so, can that kernel run a Javascript VM? And if so...
It lets you be a VPS provider, using nothing other than a copy of Chromium. No need for fancy processors and virtualizing instructions, no hypervisors, no containers, whatever.
Scales beautifully: Got a new customer? Just open another tab!
As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
It's amazing to me that "tech for the sake of tech" posts like this elicit much the same responses I would expect from a non-nerdy audience. At what point did slashdotters become mostly a group of curmudgeonly old-men who care only about what use can be made of new things and who find NO INTEREST what-so-ever in new and different ideas?
THIS is why it takes that ex-jock-turned-business man to make money on technology. Somebody who isn't an old-fart slashdotter who "ho-hum"s everything new. This community is SUCH a disappointment.
What does one use this for?
The same thing we do every night, Pinky - try to take over the world!
Um, Javascript can also have fantastic performance if you "use it correctly". Neither is particularly fantastic if you use like like an average programmer, though.
I'm just learning javascript. I'm puzzled how one makes it "fast". When my highly active programs run in a browser they tend to glitch and halt after a while if they have been doing lots and lots of quick object instantiation and destruction. My guess was this was some memory leak or deferred garbage collection. I see inconsistent results across browsers.
I'm enjoying learinging at how easy it makes doing graphics in a browser window. however It's a weird mishmash of incomplete grammars and high level commands. For example the lack of a class statement or a defined way to access a superclass is bewildering. It's even less complete that perl objects in many ways. Listing all the keys in a hash (associative array) gets conflated with all the other attributes of the hash, so there's weird kludges like "hasOwnProperty" that smack of being bandaid and afterthoughts. On the other hand it's got things like timed thread execution and some quite high level concept built in as primitives.
What perplexes me the most is I haven't figured out how to debug it yet. I've been relying on a particular package called "processing.js" which has some very simple graphics. since processing.js acutally re-writes your javascript at run time, the messages in the browser console log are worthless. they don't even tell you the line number where the error occurs most of the time. The other debugging problem Ihave is that often the javascript one is writing only can work in the context of a web page (for example to play loaded sounds). so I don't see how one runs or debugs this outside of a browser. I don't get what the IDE's offer. I'm a noob so give me a clue not heckling please.
Anyone have any advice on how to debug in java, especially when using processing.js.
Some drink at the fountain of knowledge. Others just gargle.
From my OpenRISC ORK Javascript Emulator Running With Network Support
i.imgur.com/zJPsjCT.png
Wonderful now that I can finally run a full operating system in a browser, I can finally deliver a rich client server experience in my web-based applications :-)
Repeal the 17th Amendment TODAY! Also Please Read http://www.gnu.org/philosophy/right-to-read.html
I wonder how useful it would be for security sensitive applications. For example, even though it sounds goofy to run a Web browser in a Linux kernel running in a window, the difficulity for malware to get out of rings of context (including multiple instruction sets) would be enormous. Not impossible, but highly unlikely.
Something like this would provide a decent defense against browser-based (or browser add-ons) attacks (which is a significant vector for malware these days.)
All we need now is JS acceleration built in to cpus.
Yo dawg, I heard you like VMs so..
Someone here had a sig that was "Java is to Javascript as Car is to Carpet".
Lots of small quick memory allocations/releases is generally a performance killer regardless of language or environment - if you use a garbage collecting environment it tends to be even worse, but regardless you're asking a memory manager that has to be able to deal with memory requests of all sorts of sizes and use-cases, to deal with an extreme special case that demands near-maximum amount of effort to mitigate memory fragmentation. In almost all cases your performance and stability will increase substantially if you instead allocate a sufficiently large pool of objects and manage their usage yourself.
Here's hoping someone can suggest a decent Java debugger - I abandoned it after a while in part because of the lack of something I would consider only slightly less vital than the compiler itself. Of course that would be of absolutely no use to somebody programming in the unrelated Javascript language.
--- Most topics have many sides worth arguing, allow me to take one opposite you.
There are many times when I need to do remote admin on a machine from a location where I don't have SSH available. Currently that usually involves some type of hacky browser-based terminal emulator. Actually running a Linux based OS in the browser would be perfect for such occasions, assuming I'm someplace where making outbound port 22 connections isn't a problem.
JavaScript != Java indeed. I'm still amazed at the silliness of the choice.
I've actually seen a newbie developer paste a snippet of one into the other... Finally I had an occasion to use the phrase "that's not even wrong" in an actual conversation.
The dev didn't last at our company.
Gosh, thanks. That must be why the other ships call me Meatfucker -- GCU Grey Area (Eccentric)
javascript != java
But you can still ask the question whether JavaScript is faster than Java.
You can ask a lot of questions, but that doesn't mean they're good questions.
> Comparing Java and JavaScript is like comparing a bicycle and a space shuttle.
which one is the space shuttle?
Your comparison comparison is like comparing monkeys with the Eiffel tower.
A year ago, when I started the project it was simply interest in learning Javascript. I was fascinated by the emulator from Fabrice Bellard http://www.bellard.org/jslinux/
:)
I am a programmer focused on simulations/emulations and performance. I was also interested in learning the internals of how a computer nowadays works. The x86 CPU is way to compilcated. You lose the clear sight for stupid details like the A20 gate. The OpenRISC project is perfect. It is a CPU with a very easy and clear CPU. Nothing historic. It has even some similarities with byte code, which makes it very fast if you emulate it properly. I optimized especially for running Linux violating the specification a bit.
The whole CPU with MMU fits in around 1000 lines of code. During that day I never expected to get that far. Now with all three cores and devices it needs around 7000 lines of code.
I have a list of useful things you can do with it:
1. Use it as an education system of the Linux system or other tools. For example you could write a git tutorial with live examples.
2. This emulator provides an alternative way to port old software to run on modern systems. In direct comparison to the project Emscripten it is slow, but the porting could be much easier. For terminal applications probably no porting is neccessary at all (e. g. Frotz).
3. The emulated OpenRISC CPU is very easy and contains around 1000 lines of code. So it is the perfect example to learn how emulation works.
4. With network support it allows you to access other computers within the Web Browser providing ready to use tools. (Even an encrypted chat is possible if you run the sshd daemon)
5. Use it as a speedtest for Javascript engines.
6. It is an advertisement for the OpenRISC project.
You can also read the motivation of Ben Burns in his Blog: http://www.benjamincburns.com/2013/11/10/jor1k-ethmac-support.html
And I have to admit that I did the wayland support last time only to get some news.
For people who can't help but "rm -rf /"
If we colonize Mars, it won't be the World Wide Web anymore. UWW?
Yeah, he was happier back in those days. Until His Mom took away those toys and told Him to clean up His room. He's been in the sulking place ever since. Now he just want to throw things at the walls, and shove those who want to friend him too much under the bus.
Mom's pretty cool, though. Cakes and ale parties just about anytime you ask for one, and if you promise not to make a mess, She'll get out the fingerpaints or anything else you want to play with, and even help you through the tough spots, like when you mix the colors together wrong and get something yuckie. She knows how to fix that, and if you come up with something really neat, she'll change the whole room to match your theme. Like what she did when Schroedinger did that sketch of a cat. Wow!
Will
Considering that most smartphones will happily run a terminal program...and you can get bootable linux on a usb stick or a whole linux computer on an HDMI plug.
.... only if you live in a magical fairy land.
Ok, supposing that instead of presenting a command line to the browser user the websocket/javascript instead installed a reverse command line back to the server, essentially giving a remote user access to the internal commands within the browser via the javascript kernel. All the remote user needs is a bug. plugin, or other feature that allows the browser to perform operations on the websurfer's host, like a fly-by install of malware or scraping the user environment of all information available. What prevents this scenario? How would the user even know other than the browser got reaaaalllly slooooowwwww.....
Idunno. Can you even call them runtime errors in a setup like this?
This is using a Linux VM, emulated in Javascript, in a sandbox, inside your browser. I don't think the thing could possibly run. Or even walk. I think the fastest it could go would be a slow crawl.
Will
The Linux Kernel was improved because of this emulator. Bugs in the OpenRISC part of the Linux Kernel were removed.
Or you could just write a JVM in Javascript
oh yes, Windows is much more complex, needing about twice the resources and memory to get the same job done as a Linux or BSD, in between siezeups needing a reboot. truly a powerhouse.
Or like similes to metaphors.
I read TFA and all I got was this lousy cookie
Very true. :D
This is a cool project. Thank you for working on it.
-l
Help cure AIDS, cancer, and more. Donate your unused computer time to worldcommunitygrid.org. Join Team Slashdot!
I'm sure they'd be all over some guy because he managed to run a VM in a web browser.
I'm puzzled how one makes it "fast". When my highly active programs run in a browser they tend to glitch and halt after a while if they have been doing lots and lots of quick object instantiation and destruction.
You've almost figured it out!
Recycle your objects. Enjoy instant performance improvements. (While this is not just true for JavaScript, it's obviously the advice you need.)
Oh, and try learning the language. It's not like Java and C#. If you try to treat it that way, you'll end up writing crap. You can break yourself out of that easily enough by working through The Little Schemer in JS instead of Scheme.
Required reading for internet skeptics
Depends on where the heavy lifting is.
If you've got a JavaScript that implements web SQL and web GL, well, those are implemented in low-level languages and you're just going to call them from JavaScript. If that happens to be where the bulk of the work is for a given program, you might get better performance out of JavaScript than Java.
(The devil is in the details. I do not know the details in this specific case.)
I'm puzzled how one makes it "fast". When my highly active programs run in a browser they tend to glitch and halt after a while if they have been doing lots and lots of quick object instantiation and destruction.
You've almost figured it out!
Recycle your objects. Enjoy instant performance improvements. (While this is not just true for JavaScript, it's obviously the advice you need.)
Oh, and try learning the language. It's not like Java and C#. If you try to treat it that way, you'll end up writing crap. You can break yourself out of that easily enough by working through The Little Schemer in JS instead of Scheme.
How one does that is not obvious to me. let's take an example. Suppose I create a function like this:
var recylceObj = function( oldObj, newAttitributes) {
for (var i in newAtritutes) {
oldObj[i] = newAttributes[i];
};
}
var foo = recycleObj( oldObj, { x:1, y:2, z:3} );
so superficially I just reused an old memory allocated object oldObj by overwriting it's attributes with new ones. But wait, to do that I had to instantiate the temporary hash { x:1, y:2, z:3} to transfer in those attributes. Which is memory allocation and object creation. It would in fact be simpler to write:
var foo = { x:1, y:2, z:3};
foo.prototype = oldObj.prototype;
I would in fact think this latter way would be more efficient in both speed and memory. So How do I save anything by recylcing?
is there a better way to recycle? what am I missing
Some drink at the fountain of knowledge. Others just gargle.
It runs. It's not fast, no, but it runs fast enough to actually play around with.
Dupe, or maybe just an update to this:
http://tech.slashdot.org/story/13/10/12/1819231/javascript-based-openrisc-emulator-can-run-linux-gcc-wayland
I deny that I have not avoided attaining the opposite of that which I do not want.
it can run anything, inside it's browser vm it's quite "complete" computing platform so why not.
just not anything in parallel ;) so you have to be sneaky...
and java can run in parallel and is superior in just about every way but due to politics of days past they integrated javascript and not java as the language the browser has facilities to run.
on both of them it's what you code and how that make them choke, try to do something that does things slowly and it will do them slowly.
using a websocket is kind of a cheat though, with the same technique(and simpler) you could launch nuclear missiles from javascript in browser. sure it would depend on a gateway to actually launch them....
world was created 5 seconds before this post as it is.
No need—it has already been done.
We are talking about a browser running on Linux running on a browser that's running on Linux...
A nerd rides up to his friend on a shiny new bike.
His friend asks, "where'd you get the bicycle?"
The first nerd relates, "a beautiful woman came up to me, dropped the bike to the ground, tore off her clothes and said "take anything you want!", so I took the bike."
His friend insightfully notes, "yeah, the clothes probably wouldn't fit you."
I am having trouble setting up WINE with this. Can someone help me setup WINE so I can play Crisis on my Nexus?
The Official Site of 1337 Pwnage
java can run in parallel and is superior in just about every way
Wow, no. JS is pretty obviously the more sophisticated language.
Required reading for internet skeptics
Yes, Javascript sucks. But which language runs on all devices?. Do you think if this would be programmed in Perl someone would notice it? One click and you have a Linux system in front of you. But I hope as well that we can get rid of Javascript someday.
Got a new customer? Just open another tab!
Based on your description, I believe that I've already seen prior art in restaurants.
Ezekiel 23:20
I'm not sure where this analogy is going...
Unity? Screw that: XFCE. Slashdot Beta? Screw that: SoylentNews. Australis? Screw that: Pale Moon. UX developers DIAF
I don't know what you mean by real OS. But if you mean Windows. Windows 95-Windows2000 should be possible to emulate. The newer Windwows version might work as well in future. It depends on the amount of memory the web browsers provides you and of the bandwidth of your network connection. Download 500MB before you see the Desktop? But you can't put them online as this will violate copyright law.
+1 - very cool project.
"Ignorance more frequently begets confidence than does knowledge"
- Charles Darwin
Actually garbage collecting environments like the JVM deal with lots of small object creation on the heap much faster than compiled C++ for example.
http://programmers.stackexchange.com/questions/208656/java-heap-allocation-faster-than-c
"Ignorance more frequently begets confidence than does knowledge"
- Charles Darwin
NOTE: may not apply to Javascript - but to say that "garbage collected enviornments" perform worse in this instance is just wrong. Though some may others may not.
"Ignorance more frequently begets confidence than does knowledge"
- Charles Darwin
What does one use this for?
To get chicks?
Unlikely -- doesn't work in Internet Explorer.
Be advised that this isn't a port of the kernel to JavaScript. The JS in that page is emulating a computer which executes a kernel built against the or1k architecture (as opposed to x86, or any of the arm variants).
Stuck at "Loading kernel and hard drive image" for me under windows, online an offline, Chrome and IE.
I must be cursed.
A blog I run for the wealth
Well, if you pile enough VMs on top of each other, eventually you could have some confidence you won't get rooted too many levels deep when downloading off the internets.
I have in my wiki a site describing the speed problems and how I solved them. https://github.com/s-macke/jor1k/wiki/Technical-details
I am not doing any memory allocation during the emulation.Everything is done at the beginning.
Debugging is a real issue. I used mainly console.log. But Firefox and Chome provide some debugging features.
That's a good point... how many levels deep can you run this?
I think a setup like this would be good to develop a OS prototyping engine. Instead of working low to high level like most operating systems you could work at all levels to perfect the upper level look & feel and adjust the lower level to correct for problems affecting higher level & security. Sort of like what going from type writers to word processors did for writing.
*It's not what you can do for the Dark Side but what the Dark Side can do for you!*
What does one use this for?
Self-achievement? Learning? To get chicks?
Silk road?
"Happy families are all alike; every unhappy family is unhappy in its own way." -- Anna Karenina by Leo Tolstoy
And with it they cure cancer, solve world hunger and make perfect soufflé?
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
But where do I get TurboCOBOL for Firefox?
The Tao of math: The numbers you can count are not the real numbers.
Notice I said *tends*. Java has had a couple decades of optimization to it's memory manager, so I'm not surprised it's finally surpassing the rather simplistic default C++ implementations.
On the other hand a specialized memory manager tuned to the task at hand will of course tend to completely trump any of the alternatives, which was my main point, and depending on the demands it can be fairly simple to implement as well, provided you understand at least the basics of the underlying memory manager you're building upon.
--- Most topics have many sides worth arguing, allow me to take one opposite you.
The JVM and C# garbage VMs *are* specialized memory managers. That's why they do work so well. You just get them "for free" with the environment.
"Ignorance more frequently begets confidence than does knowledge"
- Charles Darwin
No, they aren't, they're general purpose memory managers. They handle every memory-allocation request, large or small, short-lived or long, all through the same interface with minimal apriori information, and that flexibility comes at a price.
If I know I'm going to be repeatedly allocating and deallocating millions of 12-byte objects per second I will likely get much better performance allocating a single sufficiently large array of objects and reusing them (i.e. make my own domain-specific memory manager). If I know I'm going to be operating in "batches" where I will allocate lots of objects before finally deallocating them all at once (not uncommon in games and other iterative/simulation/rendering environments) then I can do one better and completely eliminate all the overhead associated with deallocation, and instead just start reusing the array as if it were fresh after each conceptual "mass deallocation".
Either way I've managed to eliminate not just the overhead directly associated with millions of allocations and deallocations per frame, but also completely eliminate the additional work required behind the scenes to defragment memory. And as a bonus I've kept my messy, memory-abusive allocations completely isolated from the general-purpose memory manager, helping to reduce the amount of fragmentation that gets introduced elsewhere, boosting performance even further.
--- Most topics have many sides worth arguing, allow me to take one opposite you.