Slashdot Mirror


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.

13 of 220 comments (clear)

  1. Ruby and Java, and also Python by kripkenstein · · Score: 3, Informative

    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.

  2. Re:Doing things the slow way by Dekortage · · Score: 5, Informative

    The article suggests that the speed was not bad. (The sample Tetris clone loaded very quickly for me.) And the article's commenters note that this runs on an iPhone. In other words, Orto could be a route to port Java apps to be iPhone aps.

    --
    $nice = $webHosting + $domainNames + $sslCerts
  3. No Perl? by SCHecklerX · · Score: 3, Informative

    Client side perl would kick ass. Then I could match my front end with the back.

  4. Re:Strange by CastrTroy · · Score: 3, Informative

    I think that everybody just has memories from the Netscape 4 days, where every line had to be coded differently depending on which browser you were using. Things have matured a lot lately, and you can almost get by without writing any browser specific hacks. However, the history of Javascript has lead many people to dispise it.

    --

    Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
  5. Re:Doing things the slow way by eln · · Score: 2, Informative

    The game loaded faster than most Java apps do for me, but once it loaded the controls were laggy and the video was pretty choppy. Most of the time for me, the JVM takes a while to load but at least the app runs fairly smoothly once it does. I'd rather have that then a shorter load time on a laggy application.

  6. Re:Java running under Javascript... by spiffmastercow · · Score: 1, Informative

    The primary reason its okay for python to be slow, but not for java, is that python isn't a crippled version of C++ that runs at 1/10 the speed, whereas java is.

    That, and the fact that you can rewrite the performance-critical portions of python code in C if you need to.

  7. Re:I just need to get this out of my system by navarroj · · Score: 2, Informative

    No, it doesn't.

  8. Re:I just need to get this out of my system by baka_toroi · · Score: 2, Informative

    It does. Only (I believe) in Argentinian Spanish though, not in the rest of the Spanish speaking countries. http://www.elcastellano.org/miyara/dic_arg_esp.html (Site in Spanish)

  9. Re:Java running under Javascript... by Galactic+Dominator · · Score: 2, Informative

    but has anybody ever created some sort of platform where each C++ app runs in its own VM? Yeah, it's called Java.

    Java is slow when done inefficiently, like any other programming language. In Java code that is implemented correctly, speed will be one your lesser worries. In fact, under certain conditions, Java can rival, and even surpass, native code for speed. The implemented correctly is a much bigger one.
    --
    brandelf -t FreeBSD /brain
  10. Re:Awesome! by omeomi · · Score: 3, Informative

    : What IS the diff between Java and JavaScript-really?

    Java is an object-oriented programming language originally released by Sun Microsystems in 1995. JavaScript is a functional scripting language originally derived from Ecmascript. Java requires a Java Virtual Machine to be installed on your computer or some other device like a mobile phone. Javascript runs right in your web browser. Javascript was originally named LiveScript, but through a marketing deal between Netscape and Sun, became named JavaScript, even though the two languages are unrelated, thus dooming those in the know to have to constantly correct people who refer to JavaScript as Java, assuming that "Java" is just like a nickname or something. However, they are both based on syntax that looks a good deal like C.

  11. Re:But... by samkass · · Score: 2, Informative

    JDK6u10 solves this. It lets the applet run in a separate process from the browser, and bootstraps the download such that it starts up very quickly. See here for more information.

    --
    E pluribus unum
  12. Re:Doing things the slow way by asdfghjklqwertyuiop · · Score: 5, Informative

    what i can't stand is java's complete lack of accuracy in basic math such as

    int upper = (int) (value * 100.0);
    double newVal = ((double)upper) / 100.0;

    value can start as an int/double/float your choice.

    in the end newValue does not alwasy equal value.. even though it should.. i understand floating point errors but i first saw this cause a problem with value being a double 8.12


    What language can you stand, then?

    % perl
    print int(8.12*100.0)/100.0;
    8.11
     
    % python
    Python 2.4.4 (#2, Apr 5 2007, 20:11:18)
    [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> float(int(8.12*100.0))/100.0
    8.1099999999999994
     
    % php5
    <?= floor(8.12*100.0)/100.0; ?>
    8.11
     
    % cat > test.c
    #include <stdio.h>
    int main() {
        double val; int upper; double newval;
     
        val = 8.12;
        upper = (int)(val * 100.0);
        newval = ((double)upper)/(100.0);
     
        printf("%f\n", newval);
    }
    % make test
    % ./test
    8.110000
     
    % ruby
    print (8.12*100.0).to_i.to_f/100.0;
    8.11
  13. Re:Doing things the slow way by Anonymous Coward · · Score: 1, Informative

    REM MS QuickBASIC 4.5

    DEFINT A
    DEFDBL B

    b1=8.12
    a=b1*100
    b2=a/100

    PRINT b2

    REM answer is 8.1199999999999 ;)