Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Java Programming

JRuby Great Addition To Java Development 51

An anonymous reader writes "JRuby combines the object-oriented strength of Smalltalk, the expressiveness of Perl, and the flexibility of the Java class libraries into a single, efficient rapid development framework for the Java platform. This article introduces JRuby, a sophisticated addition to your Java development toolbox."
This discussion has been archived. No new comments can be posted.

JRuby Great Addition To Java Development

Comments Filter:
  • So... it compiles Ruby-type code... into Java bytecode? and then links the bytecode against Sun's libraries? Nifty!

    Time to cue the Java-is-slow/big/bloated crowd and s/Java/JRuby/, though.

    • No, it's a tree-based interpreter like the standard Ruby one AFAIK.

      I'm still wondering why we're seeing a story on this so long after it's release, when the likes of Rails [rubyonrails.org], one of the more exciting Ruby libraries in recent memory, gets completely ignored.

      Of course, nobody here would really be interested in a powerful, easy way to develop web applications with practically zero configuration. It's just not *fun* without 800k of XML just to configure your ORM library :/
      • by Anonymous Coward
        Hey sonny, some of us Java programmers need jobs. If word gets out about Rails, I'll be sent out into the street.

        AND WE CAN'T HAVE THAT SONNY! So just you keep that Rails business under your hat.

        Why, I hear in Rails if you want to add a page to your web site, you just, uhm, create the file. What kind of madness is that! You gotta save the file, then edit an XML file to give the file a name string, then edit another XML file to associate a bean to the name string, then write a bean with getter and setter m
        • Okay, this isn't quite fair. I know you are joking around, so don't accuse me of having no sense of humor. :) There are a lot of things I like about Java, and J2EE is absolutely, positively NOT one of them (and yes, I've done fairly large rollouts with it and know how to optimize it, but I still think it's atrocious stuff and very ineffecient in terms of developer time and runtime performance, and no, 'scalability' is not a viable excuse since it's rarely as scalable as it ought to be). There are other n
      • > Rails

        Yup, and since it's installable via a Ruby Gem [rubyonrails.org] it's easy to get it running.

        > why we're seeing a story on this

        I bet the O'Reilly folks would accept an article on Rails...
  • other languages (Score:4, Informative)

    by Intrigued ( 757997 ) on Monday September 13, 2004 @10:48AM (#10236208)
    To my understanding, this is one script interpreter that is being developed for Java. It offers ease of use for people accostumbed to working with Ruby.

    For a larger view of the language development being done similar to this, take a look at List of Java virtual machine languages [robert-tolksdorf.de].

    I should think that most people will find at least something that appeals to them.

  • ...between this and Groovy [codehaus.org]?
    • by bonniot ( 633930 ) on Monday September 13, 2004 @11:34AM (#10236675) Homepage Journal
      Ruby and Groovy are different languages. They happen to be both scripting languages, and to have an implementation that runs on the jre (Java Runtime Environment), that's all.

      The JRuby article is part of the alt.lang.jre [ibm.com] series, with announced articles about "Rhino [mozilla.org], Nice [sourceforge.net], and NetRexx [ibm.com], and many other exciting alternate languages for the JRE". It looks like the articles are coming in this order, one around the beginning of each month.

    • The difference is, Groovy is not Ruby :-) Groovy is a new language, and it borrows some syntax/features from Ruby (as well as Python).
    • I haven't tried either JRuby or Groovy, to tell you the truth (but I have a good amount of experience with plain Ruby), but my impression is that Groovy is a language that's modeled primarily on Ruby, but designed from the ground up to live in a Java environment. I think this is a pretty good idea, but I'm in no position to judge if it's been implemented properly.

      Groovy seems to have more momentum than JRuby, and to have had more work getting it properly debugged and so on. Again, I have not tried eithe

  • by tod_miller ( 792541 ) on Monday September 13, 2004 @11:49AM (#10236842) Journal
    JRuby
    require 'java'
    module Swing
    include_package 'java.awt'
    include_package 'javax.swing'
    end
    module AwtEvent
    include_package 'java.awt.event'
    end

    $calculator = Swing::JFrame.new
    class << $calculator

    def init
    end

    end

    $calculator.init
    $calculator.setSiz e(400, 400)
    $calculator.setVisible(true)
    versus Java
    import javax.swing.JFrame;
    public class Calculator extends JFrame {
    public Calculator(){
    super("Slashdot Rul3z");
    setSize(400, 400);
    setVisible(true);
    }
    public static void main(String[] args) {new Calculator();}
    }
    and we have a winner
    • Of course, it is a very nice language as scripting languages go, and I suppose the sample I choose (swing) was a little misleading, I guess simpler tasks, and more 'do this then that then the other' un-OO tasks might look cuter in JRuby.

      Who knows.
    • by bzhou ( 138968 ) on Monday September 13, 2004 @12:21PM (#10237222)
      vs. Jython
      from java import awt
      from pawt import swing

      labels = ["0", "1", "2", "+",
      "3", "4", "5", "-",
      "6", "7", "8", "*",
      "9", ".", "=", "/" ]

      keys = swing.JPanel(awt.GridLayout(4, 4))
      display = swing.JTextField()

      def push(event):
      display.replaceSelection(event.actionCommand)

      d ef enter(event): # <= def, slashdot formatting bug?
      display.text = str(eval(display.text))
      display.selectAll()

      for label in labels:
      key = swing.JButton(label)
      if "=" == label:
      key.actionPerformed = enter
      else:
      key.actionPerformed = push
      keys.add(key)

      panel = swing.JPanel(awt.BorderLayout())
      panel.add("North ", display)
      panel.add("Center", keys)
      swing.test(panel)
    • ... and we have a loser writing.

      When you have zero clue how to write the language, I suggest you shut up.

      The equivalent Ruby is (sorry about the lack of indentation - Slashdot seems to eat it):

      require 'java'
      include_package 'javax.swing'

      class Calculator < JFrame
      def initialize
      super("Slashdot Rul3z")
      setSize(400, 400)
      setVisible(true)
      end
      end

      Calculator.new()

      That's exactly one require-line and two blank lines more than your non-idiomatically-indented Java with missing newlines. It is one li

      • When you have zero clue how to write the language, I suggest you shut up.

        *waves* hello, you must be new around here, *points at article* If you would like to read that while you wait, we call it reading the article.

        I copy and pasted that code out of the article - I didn't make it up.

        hint
        The article was about JRuby.

        And it wasn't a penis measuring contest, but a legibility contest. Now I can read java easier than JRuby because I read it daily. But looking at the redundant entropy in the bytes (I won't
        • I copy and pasted that code out of the article - I didn't make it up.

          So?

          You were criticizing the language, not the article. That code was awful Ruby. Your code was good Java.

          I've seen awful Java a lot of times - but I don't rewrite that to good Ruby and then criticize Java based on the single awful piece.

          I read both Java and Ruby more or less daily (neither is my primary pay-the-bills language at the moment, though I've paid bills with both before, and expect to do so again). My personal, subject

          • So?

            <snip/>

            That code was JRuby.

            As I said, welcome to slashdot, please read the article. [I didn't read your reply past 'that was bad ruby']

            Also, who cares about programming language penis size contests?

            I pasted some JRuby code unmodified, and clicked up the normal Java code, and thought, why script this?

            Thats about the meat of my post, now if you would like the potatoes, gravy, fancy cutlery and napkins, just ask!
            • I did read the freakin' article; it was irrelevant to my point. Go read the freakin' reply which tell you WHY. And your Java code wasn't most of the issue; your judgmental comments were.

              And I still claim: Only judge between things you know. But this is Slashdot - maybe expecting thought is too much to ask.

              Eivind.

              • Not wanting to continue redundant thread - I am not sure what you were arguing, only that you said I posted bad 'ruby' code, which was not actually the point of my code, only the fact that I had found the readability very poor - I also mentioned that as a Java programmer, I would find the readability very poor.

                As an artist I found it ugly.

                Of course, I am biased. I do respect your greater knowledge of Ruby, of course, and that you wrote very nice Ruby code, but also I respect my artistic opinion that it wa
      • I will admit that the article left redundant import statements in the code though, but again, I wasn't going for line count, otherwise I would loose all sense of identity and... and...

        write in perl! aaaaargh.
    • by Anonymous Coward
      (define frame (javax.swing.JFrame. "Slashdot Rul3z"))
      (.setSize frame 400 400)
      (.setVisible frame #t)
  • by HughsOnFirst ( 174255 ) on Monday September 13, 2004 @12:32PM (#10237356)
    So when I tell somone that this is the right tool for the job , how am I supposed to pronounce it?
    ja-ru-bee? ( gummie candy treat perhaps? )
    har-you-bee ?
    or jay-ru-bee as though it were named after Lee Harvey Oswald's killer Jack Ruby [doctorcosmo.com] ( J. Ruby ) ?
  • Jython is the python/java bridge. Unfortunately, it hasn't had a new version in quite a while.. but it allows the same thing.
    • Jython is not a bridge in the java to native sense, if that is what you mean. It is an interpreter [jython.org] of the Python language fully made in Java.
      • that's interesting. I didn't realize that. I'm new to python/jython. So, is jython slower than "normal" python?
        • Haven't used it directly but is likely. How much impact depends on what you are doing. I assume that for the purpose of scripting Java apps it shouldn't be noticeable.
        • See here [developer.com] for some rough (and somewhat outdated) assessments of CPython vs. Jython performance. It is somewhat slower, but depends on the nature of the task. And is it slower than the equivalent compiled Java bytecode? Again, probably yes, but for some tasks it doesn't matter. And the nice thing is you can write a whole app in Jython and easily rewrite performance critical components in Java and just call them from Jython, which is much easier given that everything happens in the bytecode realm than writ
    • So following tradition: JPython becomes Jython, then JRuby becomes Juby?
  • by tcopeland ( 32225 ) * <tom@NoSPaM.thomasleecopeland.com> on Monday September 13, 2004 @03:32PM (#10239440) Homepage
    ...just skip Java and go with Ruby.

    I needed a small app to analyze SQL query usage [postgresql.org], and Ruby worked great. As long as you're conscientious about writing unit tests, you won't miss Java's static typing at all.
  • I know that JavaScript does not have the same capabilities for server based OO apps as Ruby or Python (yet), but it is still a very competent language nonetheless for small to medium sized apps.

    JavaScript's similarity to Java can also be helpful for readability.

    The Moz guy's are still hacking the core of Rhino and are releasing new version regularly.
  • Hrmph. (Score:4, Informative)

    by Estanislao Martínez ( 203477 ) on Tuesday September 14, 2004 @04:10AM (#10244199) Homepage
    Last I looked (which can't have been over a month ago), JRuby was far from being ready for prime time. I'm a Ruby guy myself, yet I really wouldn't touch JRuby just yet, unless my purpose was to develop it myself.

    Groovy [codehaus.org] is, IMO, a near-clone of Ruby designed from the ground up to integrate with Java, and would probably be a better choice than JRuby. I think the Groovy documentation isn't quite there yet, tugh.

  • Oh you mean the "language".
  • i think the 'jruby' project has been inactive for about 6 months. (and is a little behind versions: 1.6~ vs. 1.8.2)

"I'm a mean green mother from outer space" -- Audrey II, The Little Shop of Horrors

Working...