Ruby and Java Running in JavaScript
John Resig is reporting on his blog that a recent trip to Tokyo opened up some very interesting JavaScript projects to him that haven't met with widespread popularity outside of Japan yet. "One project, in particular, really caught my eye. It's called Orto and is an implementation of the Java Virtual Machine (JVM) in JavaScript. This means that you can take an existing Java application, compile it to bytecode, run it through Orto (which produces the JavaScript, and embed it in a web page. While it doesn't provide the full capabilities of most Java code it does provide enough to make for some interesting demos." In a separate post he also detailed how the HotRuby project is allowing a Ruby VM to run in a browser using JavaScript or even indirectly using ActionScript in Flash.
Finally, a way to combine the feature-rich capabilities of Javascript with the speed of Java!
Because neither one is slow enough on its own?
What this is, basically, is emulating the Java in Javascript, an interpreted language. I can't help but feel that anything written in this is going to be very slow, and I can't, personally, see why anybody would bother. Of course, I'd be very happy to be proven wrong!
Good, inexpensive web hosting
Does it run Linux? ;)
In all seriousness, though... I'm struggling to see how this is truly beneficial. Aren't most pages already hopelessly clogged with mounds of JavaScript? Is it that difficult to expect a user to have a Java interpreter already installed when they visit the page such that having your Java "emulated" in JavsScript is the better solution?
Just seems like a solution needing a problem to me.
Proudly supporting the Libertarian Party.
Also worth mentioning that PyPy allows you to run Python as Javascript, inside a browser. Like all of these things, it isn't 100% mature, but pretty cool nonetheless.
While not exactly the same thing, the Google Web Toolkit (GWT) lets you write your code in Java and then run it in the browser. The difference is that the GWT translates the Java into JavaScript instead of giving you a full JVM. I'm not sure what practical advantage having a full JVM gives you.
Bradley Holt
Seems odd to use languages that weren't really designed to be embedded in a browser. One of the nice things about Javascript in the past couple of years has been the great DOM support. Add a library like JQuery and you have full cross platform goodness and a sane way to write code. Getting Java or Ruby code to interact with the DOM seems like it would be a huge pain compared with JQuery.
Why does everyone hate Javascript so? If you're going of cut-n-paste examples from the web yes it looks like an ugly language. Check out how the OO stuff works, or some JQuery code, and you'll be pleasantly surprised.
std::disclaimer<std::legalese> sig=new std::disclaimer; sig->dump(); delete sig;
This just reminds me of the "octoparrot" from The Simpsons. "Braawk! Polly shouldn't be!"
Use the Firehose to mod down Second Life stories!
Congratulations! Sounds like a very secure platform. Maybe there's time to include it in IE8.
'Orto' means 'ass' in Spanish.
Client side perl would kick ass. Then I could match my front end with the back.
writing a java VM in javascript? *head asplodes*
that's pretty cool but man, talk about a daunting tedious task. I'd rather bail 600 acres with a weed wacker and twisty-ties.
I came to the datacenter drunk with a fake ID, don't you want to be just like me?
One word - Slllllllllllllllloooooooooooooooooooooow!!!
Ok, so maybe we can run python in pypy in ironpython in java in javascript.
Now all we need to get is a C compiler to output python code. If someone can then write an x86 VM in python we could then run Linux in Firefox!
SJW n. One who posts facts.
http://www.haskell.org/haskellwiki/Haskell_in_web_browser
Matt
Anybody else twitch at the sight of that headline?
/* No Comment */
All what is needed now is an implementation of Javascript in Java (and possibly have it be compiled).
As a side note: "orto" in argentina means ass. I don't think I'd want to run anything through it.
diegoT
So how Orto different from Google's Web Toolkit? Does it accomplish it's goal without AJAX?
Finally the name JavaScript makes sense
NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
Now all we have to do is compile that Javascript into bytecode with Rhino, and it will tear a hole in the fabric of space and time.
Why the hell would you use a JVM in Javascript when there are Java plugins for every major browser anyway? The only good use I could think of is if you want Java to run on some user hostile DRMd machine that doesn't let you do Java but lets you do javascript.
While Ruby and Java are nice and all, I give you Brainfuck and Ook!.
http://virtuelvis.com/
Brainfuck has been available for JavaScript for years!
Clearly the top application of this project is me playing that Tetris game and telling my boss that it's research for my job.
Democracy Now! - your daily, uncensored, corporate-free
They don't know if it works properly yet - they're still waiting for it to finish running "Hello World"....
There are people who love Java and those who hate it. You missed a chance to trash it, so you are not of a former variety :)
DLR in Silverlight 1.1 and 2.0beta already has Ruby/Python/compiled Javascript and C# on the browser. F# for functional programming is coming soon.
Under their VM, it's 1000x faster than interp JS.
I know this will go under the "lalalalalalalalalalala I cant hear you lalallaallalal" camp, but someone needs to say it's already been done.
Previously, so-called RIA applications were limited to those with Flash and JavaScript expertise. These advances may open this field up further to Java and Ruby developers who don't know JavaScript. This puts less cognitive burden on the individual developer which, on the whole tends to be a good thing.
The most interesting part in the last link is that the following process:
..is somehow 5x faster in their example than running the same ruby script on Ruby1.8 as a shell script on the commandline. Their example is incredibly simple, but I am still surprised that it wasn't 5x slower.
- Ruby code in tag sent to the server via XMLHttpRequest
- Code recieved by a Ruby1.9 Cgi program.
- Cgi script compiles the code with YARV to opcodes and sends it back formatted as JSON.
- Browser takes the Ruby opcodes and translates it to javascript with HotRuby and runs it.
In any case I can't wait to be able to have all my application code written in Ruby.
http://en.wikipedia.org/wiki/PerlScript
Neat, in a way. I recall playing a very VERY small bit with this ~5ish years ago, I believe. Not sure how useful it is, but it still warms my perl-loving heart.
That means it's as cumbersome to program in as Java and even slower than JavaScript. What more could you ask for?
Too bad it's compiled to JavaScript rather than interpreted. That would have enabled secure execution of foreign code... and be the worst performance achievement in history.
Month 1: Developer A writes a relatively complicated Java program. Developer A compiles it to bytecode, runs it through Orto and deploys resulting Javascript to company's webserver. Developer A writes no documentation.
Months 2-6: Developer A continues to write no documentation concerning his work in Month 1.
Month 7: Developer A quits, resigns, is fired, or otherwise disappears.
Month 8: Developer B -- Developer A's replacement -- is asked to fix several bugs in the company's web pages. Developer B opens up the Javascript and freaks out while looking at auto-generated Javascript. Developer B slowly but surely makes his way through the Javascript and makes required non-trivial changes, updates and modifications.
Month 9: Developer B flees the scene.
Month 10: Developer C -- Developer B's replacement -- is asked to fix several more bugs in the company's web page. Developer C opens up the original Java program. Developer C opens up the company's deployed web pages with embedded Javascript. Developer C spends several hours looking from one to the other and then back again. Developer C submits the resulting mess to thedailywtf.com and then runs screaming from the building.
To all potential Developer C's out there: Start running!
"Flag on the moon. How did it get there?"
... these.
OMeta: http://www.cs.ucla.edu/~awarth/ometa/
The more recent OMeta 2.0: http://jarrett.cs.ucla.edu/ometa-js/
And, of course, COLA - http://piumarta.com/software/cola/
Self-sustainment, anyone? ;-)
One more link: http://www.swa.hpi.uni-potsdam.de/s3/
Hey, I used to have a TI 99/4A. Great little machine, back then!
College-Pages.com - Online Colleges, Degrees, and Programs
Imagine a Beowolf cluster of Morons running Java w/Javascript on e-mail servers for elderly Koreans, on Linux...with sharks w/laser attachments enabled by default for the inbox!
/. meme here, PLZ don't taze me bro! *I've been trying to fsck up my /. Karma for years now...Mod's- help me out or else 'I'm in ur computer!' until Duke Nukem is released, and runs on Linux!
/. poll? Egads! that may be too much!
Damn it, I know I'm forgetting some
How far do I have to go?....Accept the CowboyNeal option in the
Down With Slashdot BETA!!! I've been around the corner and seen the oliphant; you can only abuse me from your perspecti
What ? You mean a Turing complete language can be compiled to another one and still run on a Turing machine ? Oh noes, my world view collapses!
The JavaScript Ruby interpreter is faster than the "real" one
Game... blouses.
After reading that page, I see that it's a wordplay. Orto is taken from Greek which means "recto" (straight) or "correcto" (right, as opposed to wrong). "Recto" also means "rectum".
The best way to predict the future is to invent it
The Perl 6 people were targeting javascript with KindaPerl6.
has existed for ages...they are called Applets. Every browser supports them.
I understood that Java was an OOL, but failed on the whole JS understanding.
/. moderators give you some 'informative +' love.
/.*... based on that, I feel compelled to add you to my 'Friend's' list here, so be forewarned if your pref's advise you on the change/message. (have not checked your user page,etc.)
Thanks to your reply, I now know enough to differentiate the two: In other words: Java !=JS. I sort of get it and heartily thank you for the informative reply.
I sincerely hope the
I did not really get the diff, but see now I have more learning and research to do, as I do want to 'get it'.
I guess the whole 'Java' vs. 'Javascript' is confusing to n00bs (or 'us morons') since they both contain the (unrelated) root word:java.
Again thanks for a respectful and informative reply that can forward the conversation constructively...*can be a rare thing here on
Down With Slashdot BETA!!! I've been around the corner and seen the oliphant; you can only abuse me from your perspecti
I'd like to point out that there are already two implementations of java on javascript aside from the one in the article:
1. Google Web Toolkit compiles java to javascript.
2. XML11 project actually implements the JVM in javascript. That's right, their script *interprets* and *executes* java bytecode. They let you do things like run existing AWT applications unmodified, by emulating AWT in HTML. Of course, this was pretty slow the last time I looked.
Comment removed based on user account deletion
Orto means "Anus" in spanish.
I bet it performs about as well as C++ programs running under a Visual Basic interpreter.
More than half the comments so far are "why would you do this? it'd be slow!" or "I don't see the benefit of this" or "I would not recommend this enterprise architecture".
Gaaaa!
People, you're supposed to be nerds. Sometimes nerds do things just for the fun of it. Because they can. Look at the comments from a mere 8 years ago about the HTTPD server written in PostScript (and in shell, and in assembly). What's happened in the meantime? Did you all go get MBAs? Did you all start kissing girls or something?
Advice: on VPS providers
This looks more like the kind of stuff that some programmer created just to amaze other programmers.
If it's gonna end up being a js app it makes more sense to me to code it in js from start to finish, i don't see the point in coding it in java first.
But anyway, amazing stuff!
Really sorry about harshing your mellow, man.
Thanks for the extra time to reply. It just gets frustrating sometimes to be slapped with something you have not been informed about without any chance for ref's other than a Google search...which can yield many hairy results to wade through.
I guess it's a matter of experience and perception.
BTW, I consider myself a *nix n00b, but I am trying to soak it all up like a dry sponge....but there is a lot out there, and only so many hours in the day!
Now I am going to take my frustrations out by playing Fallout2 and fscking up some stuff! (via WINE on Kubuntu 8.04--just finished Fallout1...again! then opened another beer!)
Down With Slashdot BETA!!! I've been around the corner and seen the oliphant; you can only abuse me from your perspecti
Microsoft Live Labs is working on a similar project to translate CIL (.NET bytecode) to JavaScript as part of their Volta project. It's part of a larger effort to allow you to write both the client-side and the server-side code in the same project and then have a post-processor split the resulting assemblies and generate all of the boilerplate RPC code to make the client-side bits run on the client and the server-side bits run on the server.
Parent makes a good point...
A true nerd would build a robot to kiss a girl...
Related to this, here is a nice overview of the current state of various Ruby implementations (including a brief discussion of the javascript one) by Charles Nutter one of the lead developers of JRuby: http://headius.blogspot.com/2008/04/promise-and-peril-for-alternative-ruby.html
Jilles
I'm a little befuddled by lack of sleep, but the talk of ass and matching front ends with back made me think you were suggesting that Perl would be involuntarily sodomizing someone. In my defense, we are talking about Perl here -- its not like the comment would be terribly out of bounds.
Help poke pirates in the eyepatch, arr.