Ruby for Java Folks?

Discussion in 'Ruby' started by Eric Schwartz, Mar 15, 2006.

  1. I've agreed to give a brief talk on Ruby for the Pikes Peak Java
    Developers Group. I've done stuff like this before at work, but that
    was for a crowd coming from a background of shell scripting and Perl.
    I'm not much of a Java guy myself, but I know there's a lot of overlap
    between the Java and Ruby communities. I can easily spend 45+ minutes
    on Ruby no matter what, but if any of you have any suggestions on what
    an audience of Java programmers would be interested in, I'd welcome

    Here's some topics I plan to cover:

    * Everything's a class.
    * Interpreted vs. compiled, and how that affects
    both language design and performance.
    * Static vs. dynamic typing, leading into
    * Duck typing.
    * Modifying library classes.
    * Modifying individual objects-- emphasis on
    using this for testing frameworks.
    * Briefly cover Test::Unit and maybe JRuby.

    This is all subject to modification. I may bring Test::Unit in
    earlier, when I tart talking about duck typing. I don't, I think,
    want to get into too much comparison between the two languages-- these
    are very knowledgable Java people, much more so than I am. My best
    approach, I think, is simply to present Ruby to them as a fun
    language, perhaps for prototyping Java solutions, ideally as an end in

    Any ideas on what else I should cover, or if I should de-emphasize
    some of what I listed above would be welcome.

    Eric Schwartz, Mar 15, 2006
    1. Advertisements

  2. Eric Schwartz

    Bill Kelly Guest

    One possibility might be to show them JRuby? I used to do
    that with Jython. Show Java people Python by running Jython
    in interactive mode, and creating Swing or AWT windows right
    from the command line. I presume JRuby has an IRB. . . .

    If JRuby works like Jython, you can load any ol' compiled
    Java class and instantiate Java objects and call methods on
    them interactively.

    Back when I was programming in Java, I did as much coding in
    Jython as possible, including writing all my unit tests in
    PyUnit instead of JUnit. Far less tedious, from my point of
    view. These days, I'd want to use JRuby instead of Jython...

    Well, just a thought. . .


    Bill Kelly, Mar 15, 2006
    1. Advertisements

  3. ------=_Part_2250_32628358.1142443300876
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    One topic that I haven't seen covered anywhere and would find useful is a
    mapping between java and ruby libraries, organised by application domain,
    and their differences in functional coverage: java is more than a language,
    it's a platform and people spend more time learning libraries than the core
    One common question for a java developer starting ruby is: in java I would
    use this lib to perform that task, what should I use in ruby?
    I guess we should have a wiki page with that.

    For example
    domain: http
    jakarta http-utils -> http-access2, open-uri

    [email protected]

    Patrick Chanezon, AdWords API evangelist

    Patrick Chanezon, Mar 15, 2006
  4. Eric Schwartz

    James H. Guest

    James H., Mar 15, 2006
  5. Julian I. Kamil, Mar 15, 2006
  6. ------=_Part_517_20077083.1142454410335
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    I agree with what others have said about presenting Ruby, and I'd sure love
    to find a good presentation I could give my own Java devs.

    I'd want it to cover:
    - Ruby the language, Objects, Class, cool stuff
    - How Java features map to Ruby...someone else mentioned this, and it would
    be a huge help, especially with examples
    - JRuby would be very useful for demonstrating how Java devs can start usin=
    Ruby today. A lot of shops have standardized on "Java Only" and this is a
    sneaky way to get Ruby into the mix. If anyone complains about a non-Java
    language being used, you just have to mention SQL, XML, JavaScript, and so

    For the first item, I'd hope someone has a good hour-long walkthrough of
    Ruby and why it's cool. I don't know of any such document for the second
    one. Finally, we have some good demos in JRuby CVS that might help you with
    that last one.

    Charles Oliver Nutter @
    JRuby Developer @
    Application Architect @

    Charles O Nutter, Mar 15, 2006
  7. How about working through some of the examples from Refactoring by
    Martin Fowler, or Smalltalk Best Practice Patterns by Kent Beck, using
    both Java and Ruby side-by-side?

    One thing I really like about Ruby is that certain tasks (like
    enumeration) have much less code overhead than in Java, which promotes
    nice, small methods that are easy to refactor or rework. Even if it's
    only 6 lines, there's some mental resistance to setting up a loop in
    Wilson Bilkovich, Mar 15, 2006
  8. Most of my good books (like Refactoring) are packed up, alas! But
    I'll see if I can't come up with some simple examples of "Here's how
    you do it in Java, now here's Ruby". I want to avoid appearing to
    diss Java at all; these are presumably smart people who don't care to
    have advocacy thrown at them; I just want to give them info.
    Yeah, I have to admit that, having done some C recently (had to
    interface with a new device driver, and didn't want to learn how to do
    ioctls in Ruby at the time), I hate doing C/Java-style for loops like

    String [] fileNames = new File( "/home/emschwar" ).list();
    for(int i=0; i < fileNames.length; i++) {
    System.out.println("directory entry named [" + fileNames + "]");

    There's no real reason for it, but it focuses my mind more on the
    array (how I set it up, how I'm iterating over it) when I'm reading it
    than in the Ruby below:

    Dir.entries('/home/emschwar').each { |e|
    puts "directory entry named [#{e}]"

    Here, I'm more focused on what I'm doing to each element-- this
    reminds me a lot more of Perl's map (and Lisp's mapcar) function, but
    when I use Perl, I feel like I'm turning the iteration inside out;
    here it's just a much simpler way of doing the same for loop above.
    Without complaining about Java, showing how Ruby iteration eliminates
    the need for explicit iterators would certainly be powerful stuff.

    (personally, I prefer do...end, but used {} here to make Java people
    feel more comfortable :)

    Eric Schwartz, Mar 15, 2006
  9. Right. The problem I have is that I'm, as I said, much more of a
    Perl/Ruby guy than a java one; they'll know standard (and useful,
    nonstandard) libraries better than I will.
    That would be useful. I'm giving the talk on Tuesday, though (I
    volunteered as a last-minute replacement for the regular speaker who
    had to cancel), so if someone has information like that, I can use it,
    but I don't think I have time to develop it on my own.

    Eric Schwartz, Mar 15, 2006
  10. String [] fileNames = new File( "/home/emschwar" ).list();

    File yourFolder = new File("/home/emschwar");
    for (String n : yourFolder.list()) {
    System.out.println("directory entry named [" + n + "]");

    /// shorter:

    for (String n : new File("/home/emschwar").list()) {
    System.out.println("directory entry named [" + n + "]");

    /// shorter:
    /// using jakarta-commons-IO + Java 5 static-imports
    /// I'm always using jakarta-commons

    for (String n : list("/home/emschwar")) {
    out.println("directory entry named [" + n + "]");

    Christoph Hess, Mar 16, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.