Slashdot Mirror


Ruby, Now In English

PM4RK5 writes: "For those of you interested, the News & Observer had an interview with Andrew Hunt about Ruby, in response to a book he and David Thomas authored. The book, "The Pragmatic Programmer" was written for the old-fashioned programmers who seek to learn how to use newer technologies, and use them better. It has an example of code differences between Java and Ruby, on how to print 'Ho Ho Ho.' Contains information and thoughts on its current applications, how its growing, and the types of things that it is suited for."

20 comments

  1. local press by b-side.org · · Score: 2, Informative

    wow, it's weird to see a local rag doing such an in-depth article on programming. well done, N&O. (even weirder that it's my local rag, but, hey..)

    since i know all 6 people who read this article are going to skim it for exactly the same thing i did, here it is:

    To print "Ho Ho Ho" in Java, you have to write code like this: 'for (int i=0; i 3; i++)
    {System.err.print("Ho ");}.'

    In Ruby you write:

    '3.times do print "Ho " end.'

    --
    Indie rock lives! b-side!
    1. Re:local press by Anonymous Coward · · Score: 0
      Dude, I've got that beat.

      10 PRINT "Ho Ho Ho"

      Qbasic - half the size and twice as readable

    2. Re:local press by VA+Software · · Score: 1


      Both those programs are buggy.

      Neither produce the expected output.

      --

      ---
      http://slashdot.org/moderation.shtml
    3. Re:local press by Cheetah86 · · Score: 1

      Still, I like pythons approach to it more:
      for i in range(3): print 'Ho '
      It's a little less complex than the ruby example, and much less complex than the java one.

    4. Re:local press by micje · · Score: 1

      3.times {print "Ho "} is complex?

      --

      The nice thing about standards is that there are so many to choose from. - ast

    5. Re:local press by thrig · · Score: 1

      print 'Ho ' x 3;

      print 'Ho ' for 1..3;

      Mind you, I think it's great we have a handful of languages in the same problem domain-- diversity is spiffy.

    6. Re:local press by Anonymous Coward · · Score: 0

      So far, the only correct implementation is the Basic one. Guess these modern languages aren't all they're cracked up to be :-)

    7. Re:local press by Anonymous Coward · · Score: 0

      both pieces of code will print this out

      "Ho Ho Ho "

      there is a space at the end.... not good

    8. Re:local press by Anonymous Coward · · Score: 0

      $_ += "Ho " for (1..3); chop; print;

      I don't see what's so difficult about that...

    9. Re:local press by Anonymous Coward · · Score: 0

      Doh! '.=' not '+='! Damn languages are getting all mixed up in my head.

    10. Re:local press by Anonymous Coward · · Score: 0

      Fortran-90: print *, repeat ("Ho",3)

    11. Re:local press by SnapShot · · Score: 1

      There was a bug in the original question. It should have been: print out "Ho Ho Ho ".

      --
      Waltz, nymph, for quick jigs vex Bud.
    12. Re:local press by ryanflynn · · Score: 1

      (1..3).each{print 'Ho '}

  2. Last year in English by mlinksva · · Score: 3, Informative
    Actually Andy and Dave's book has been available for nearly a year. O'Reilly is scheduled to publish Ruby in a Nutshell this month, and Matz is scheduled to publish another English tome early next year. Sheesh, even Sams is getting into the picture soon apparently.

    More interesting might be slides from last month's Ruby conference as well as a nice writeup with pictures. Wish I could've been there!

  3. Pronoun Mixup by mlinksva · · Score: 1

    The newspaper article contains the Java/Ruby example. The book Pragmatic Programmer was written before they got involved in Ruby, and has no Ruby. To muddy the waters even more, their Ruby book is subtitled The Pragmatic Programmer's Guide, but it doesn't have Java comparisons. Someone will have to write a "Ruby for Java Programmers" book.

    1. Re:Pronoun Mixup by leifw · · Score: 1
      The book Pragmatic Programmer was written before they got involved in Ruby...

      Actually, that's not entirely true. They used ruby in the scripts they used to format, etc. the text for the "Pragmatic Programmer".

  4. Familiarity by zaphod123 · · Score: 1

    Judging from the code in the article, one of the things that would appear to hinder Ruby is its lack of closeness to other languages. Perl, Java, etc have at their heart, C. You can see this in the bracing uses, control structures, etc.

    In the end, this may not be a "bad thing" for Ruby....

    --
    :q!