Slashdot Mirror


JRuby Great Addition To Java Development

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."

5 of 51 comments (clear)

  1. So... work with me here.... by FooAtWFU · · Score: 1, Funny
    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.

    --
    The World Wide Web is dying. Soon, we shall have only the Internet.
    1. Re:So... work with me here.... by Anonymous Coward · · Score: 1, Funny

      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 methods for each field in the file, then associa... hey wait a minute these are trade secrets.. you gotta do some work, that's what I'm saying.

      And this Ruby language, I doubt it can make adding two numbers any easier than this:

      mathOperation adder = operationFactory(BinOp.ADDITION);
      expressionNumbe r addend = new Number(2);
      expressionNumber augend = addend.clone(); //shortcut

      // TODO: set this up with an XML file
      mathExpression exp = new Expression();
      try {
      exp.setOp(adder);
      exp.setLHS(addend, mathExp.ASSUME_INTEGER);
      exp.setRHS(augend, mathExp.ASSUME_INTEGER);
      } catch mathExp.pointlessError { }

      expressionResult result = exp.compute(mathExp.IMMEDIATE);

      int intResult = result.getInt();

      System.out.println("2 + 2 =" + intResult);

      Don't you just love the POWER OF JAVA!!! I feel like I can achieve anything in Java, given enough time.

  2. JRuby versus Java [code comparison - short] by tod_miller · · Score: 4, Funny
    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
    --
    #hostfile 0.0.0.0 primidi.com 0.0.0.0 www.primidi.com 0.0.0.0 radio.weblogs.com
    1. Re:JRuby versus Java [code comparison - short] by bzhou · · Score: 4, Funny
      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)
  3. About that name by HughsOnFirst · · Score: 4, Funny

    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 ( J. Ruby ) ?