Ex-Perl coders: Howz it feel to convert to Ruby?

Discussion in 'Ruby' started by Chris, Sep 15, 2004.

  1. Chris

    Chris Guest

    I didn't even think about asking this question until now, based on a
    paragraph I wrote in another thread, so I thought I would ask...

    I've had this long time infatuation with Ruby and as a fairly proficient
    Perl coder, have even recreated a few "Ruby things" in Perl over the
    last few years. But a couple of "Wow!" factors in Ruby have kept me
    hanging around and I've finally decided that the only way is to ween
    myself off of Perl and just start using Ruby all the way.

    This is hard because I can't afford a lot of downtime, which has been
    the biggest strike for me against using Ruby. I'm fairly fast, tight,
    and concise at hitting targets using Perl and I don't want to loose that
    productivity using Ruby. Still, it appears a "hit" has to be taken if I
    really want to learn it as well as I know Perl.

    So the question for any hardcore Perl coders out there that have
    converted to Perl (or are fluent in both) is: Is it really worth the
    time? Are the paybacks there? And do you feel you've exceeded your
    capabilities in Perl using Ruby?

    I perceive, from what I've read, that this could be the case. I see all
    these "testimonials" that claim rapid development and this is inticing,
    yet at the same time, having done *some* Ruby coding, this is a little
    hard for me to believe because in my estimation, the paradigm in Ruby is
    entirely different than in just about any other procedural language and
    even from the OO aspects of Perl, C++ and Java. To me, the difference
    between Ruby and just about anything else (common) is the same as when,
    in the development world, many of us made the leap from procedural to
    OO. I think the gap between Ruby and most everything else is that big
    -- as well as the payoffs...?

    So I'm looking for feedback from those that have converted, esp. from a
    hardcore Perl perspective.

    Thanks,
    -ceo
     
    Chris, Sep 15, 2004
    #1
    1. Advertising

  2. Chris

    James Britt Guest

    Chris wrote:

    > ... in my estimation, the paradigm in Ruby is
    > entirely different than in just about any other procedural language and
    > even from the OO aspects of Perl, C++ and Java. To me, the difference
    > between Ruby and just about anything else (common) is the same as when,
    > in the development world, many of us made the leap from procedural to
    > OO. I think the gap between Ruby and most everything else is that big
    > -- as well as the payoffs...?


    Could I can encourage you to go into more detail about this? In what
    ways do you see the Ruby paradigm as being s different from Perl, Java,
    and C++?

    When you started learning Ruby, did you try to adapt familiar Perl/Java
    concepts/structures/object models to Ruby? If so, did this help or
    hinder your learning Ruby?

    >
    > So I'm looking for feedback from those that have converted, esp. from a
    > hardcore Perl perspective.


    Same here. This is an interesting topic.

    Thanks,


    James
     
    James Britt, Sep 15, 2004
    #2
    1. Advertising

  3. Although I don't regard myself as a diehard perl coder...

    "Chris" <> schrieb im Newsbeitrag
    news:REY1d.17014$...
    > I didn't even think about asking this question until now, based on a
    > paragraph I wrote in another thread, so I thought I would ask...
    >
    > I've had this long time infatuation with Ruby and as a fairly proficient
    > Perl coder, have even recreated a few "Ruby things" in Perl over the
    > last few years. But a couple of "Wow!" factors in Ruby have kept me
    > hanging around and I've finally decided that the only way is to ween
    > myself off of Perl and just start using Ruby all the way.
    >
    > This is hard because I can't afford a lot of downtime, which has been
    > the biggest strike for me against using Ruby. I'm fairly fast, tight,
    > and concise at hitting targets using Perl and I don't want to loose that
    > productivity using Ruby. Still, it appears a "hit" has to be taken if I
    > really want to learn it as well as I know Perl.


    IMHO that will be the case with *any* language which you don't use for a
    long time: it just takes some initial learning until you reach the same
    (or even higher) speed as with a language that you're proficient in. If
    you can't afford that at all then I'd suggest to not switch at all *or*
    defer the switch, take your time and do Ruby stuff whenever you can afford
    until you reach the level of proficiency and speed that you need.

    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?


    I'd say Ruby is worth the journey. I never got really acquainted with
    perl OO - which is a major nuisance IMHO. Also Perl has all sorts of
    specialities, which make it fast but can lead to ugly surprises ("sort
    works only with a restricted kind of block" is one of those exceptions).
    Personally I stepped into the "did I dereferenciate often enugh" trap
    often enough to slow me down. That might not be the case in your
    situation as hardcore perl coder though.

    > I perceive, from what I've read, that this could be the case. I see all
    > these "testimonials" that claim rapid development and this is inticing,
    > yet at the same time, having done *some* Ruby coding, this is a little
    > hard for me to believe because in my estimation, the paradigm in Ruby is
    > entirely different than in just about any other procedural language and
    > even from the OO aspects of Perl, C++ and Java. To me, the difference
    > between Ruby and just about anything else (common) is the same as when,
    > in the development world, many of us made the leap from procedural to
    > OO. I think the gap between Ruby and most everything else is that big
    > -- as well as the payoffs...?


    I wouldn't claim that big difference: Ruby OO <-> Perl OO, yes of course -
    perl OO is close to nonexistent. There is no unique way to create
    instances etc, which makes it hard to work with IMHO. Ruby OO <->
    Java/C++ OO, much closer but less hazardous (C++ multiple inheritance) and
    more flexible (not only meta data inspection as in Java but also meta data
    *manipulation*, such as adding methods dynamically).

    > So I'm looking for feedback from those that have converted, esp. from a
    > hardcore Perl perspective.


    I hope these comments helped even I not from a "hardcore Perl perspective"
    but rather from a reasonable Perl background. :)

    Kind regards

    robert
     
    Robert Klemme, Sep 15, 2004
    #3
  4. Chris

    Dick Davies Guest

    * Chris <> [0954 15:54]:
    > I didn't even think about asking this question until now, based on a
    > paragraph I wrote in another thread, so I thought I would ask...


    > .....I've finally decided that the only way is to ween
    > myself off of Perl and just start using Ruby all the way.


    Good on you boy, although your family will starve :)
    I am still 'Writing Perl for Food', though I hope to start sneaking Ruby under
    the radar here now that I've settled in and earned some credit.

    > .... I'm fairly fast, tight,
    > and concise at hitting targets using Perl and I don't want to loose that
    > productivity using Ruby. Still, it appears a "hit" has to be taken if I
    > really want to learn it as well as I know Perl.
    >
    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?


    Perl has a lot of annoying rough edges now I'm used to Ruby -
    lack of iterators and the func(thingy) rather than obj.method syntax.

    But it's also got a few absolutely horrible bits, number one being the whole
    OOP model. Despite this a lot of third party libs use the model because it
    makes namespace management almost feasible.

    It sticks in my eye whenever I try to read another library, sometimes
    when I just try to use them, and means things like unit testing are impractical.

    So with Perl I just throw something together until it works, test it by hand as
    best I can, and hope I can finish it in one sitting, because I won't be able to
    follom it when I come back to it :)

    > OO. I think the gap between Ruby and most everything else is that big
    > -- as well as the payoffs...?


    The nice thing about ruby is that it lets you write code without thinking too
    much about the language, so your brain has more room for your app logic.
    I have almost finished my del.icio.us api library after
    about two days of ten minute coding sessions while I was waiting for kernels to compile.

    Find a problem to solve and get to it, and post here when you get stuck or think
    'there must be a prettier way of saying this' (because in my experience there is).

    but to paraphrase the Envoy Corps: '*you* write the code, not the language'.
    Use what you find easiest. But I think if you already dig it, then Ruby will
    pay off for you.

    --
    God made the world in six days, and was arrested on the seventh.
    Rasputin :: Jack of All Trades - Master of Nuns
     
    Dick Davies, Sep 15, 2004
    #4
  5. Being a long time Perl programmer I tend to reach for Perl when I have a
    problem to solve. Mainly because I can just grab a module off CPAN and
    hack something up.

    However whenever I want to write a simulation (population models, music
    generators etc.) I go straight for Ruby.

    I can hack something up pretty quick in Perl, but I stand a better
    chance of maintaining it in Ruby so I get it to work in Perl and then
    take the design over to Ruby.
     
    Peter Hickman, Sep 15, 2004
    #5
  6. On Sep 15, 2004, at 9:54 AM, Chris wrote:

    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?


    You almost sound like you're looking for the "Silver Bullet" of
    programming languages. I'll tell you upfront that I don't think there
    is one, so you can let that color the rest of what I say...

    I would rate myself as a Perl Expert and an Intermediate Ruby
    programmer. I've recently "converted" to Ruby in that I'm now using it
    for more and more day-to-day tasks.

    Everything else that follows is solely my opinion.

    I feel Perl has a slight edge in quick and dirty scripting. Simple
    things like having to call to_s() on the integers I print or
    remembering when to use times() instead of upto() slow me down or trip
    me up just a bit. Of course, this is probably my familiarity as much
    as anything else. Please don't get me wrong. I'm not complaining
    about the Ruby way of doing things, but I do think I throw down a quick
    throw-away or one-use script a touch faster in Perl.

    On the flip side, Ruby is by far the cleanest most readable language
    I've ever worked with. That gives a huge advantage in bigger and long
    term projects, I think. I can just read my code, without having to
    figure it out all over again. Because of that, I can make changes
    easier and maintain software faster.

    Related to that, Perl's object system is downright laughable next to
    Ruby. Heck Java doesn't stand up that much better. If you're a OO
    guy, there's a lot to like in Ruby and I am.

    I spend more of my time writing big programs than small scripts, so it
    should be clear why I've begun to prefer Ruby.

    The other big difference I've noticed is maturity. Perl and especially
    the CPAN are quite mature, simply as a function of time. Ruby is still
    "young" in places. I view this as a plus and a minus.

    When I need a module XYZ, it's not always immediately available, easy
    to find, easy to install, or completely finished. The CPAN can often
    claim all of those things at once, which is a stunning feat.

    Again though, I also view this as a plus. I sometimes feel like 90% of
    the problems have already been solved in Perl and there's not a lot of
    room let for my mark. I don't feel that way about Ruby. If a module
    is missing, I could be the one to write it. This is more a feeling
    than anything else, but it's kind of fun to be on the adventurous side
    of a young language, to me at least.

    You seem concerned with downtime though, so this may not hold true with
    you.

    Those are just some of my general impressions. Hopefully, they give
    you something of what you're looking for.

    In the end I suppose you need to ask yourself why you would switch from
    Perl to Ruby, and then see if you think Ruby fits that reasoning. Good
    luck with your choice.

    James Edward Gray II
     
    James Edward Gray II, Sep 15, 2004
    #6
  7. Chris

    Bill Guindon Guest

    On Wed, 15 Sep 2004 23:54:51 +0900, Chris <> wrote:

    > I've had this long time infatuation with Ruby and as a fairly proficient
    > Perl coder, have even recreated a few "Ruby things" in Perl over the
    > last few years. But a couple of "Wow!" factors in Ruby have kept me
    > hanging around and I've finally decided that the only way is to ween
    > myself off of Perl and just start using Ruby all the way.
    >
    > This is hard because I can't afford a lot of downtime, which has been
    > the biggest strike for me against using Ruby. I'm fairly fast, tight,
    > and concise at hitting targets using Perl and I don't want to loose that
    > productivity using Ruby. Still, it appears a "hit" has to be taken if I
    > really want to learn it as well as I know Perl.


    Personally, I don't see it as an either/or thing. I'm learning Ruby
    to speed up my coding in another language (Miva - yeah, I know. you've
    never heard of it)

    So far, my focus has been on building tools for code generation, file
    parsing, etc. I can't afford to switch languages, but I think I'll be
    much better off with Ruby than without it.

    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?


    I'm hardly hardcore Perl, but I've done quite a bit of it in the past.
    If it was my core today, I'd continue to use it for it's speed,
    compatibility with existing code, and to appease other dev's working
    in the same environment.

    I'd pull Ruby in to handle the grunt work, and to bring truth to the
    "quick" in "I'll just write a quick script to do X". Granted, it'll
    be some time before that can happen, but I think the minimal syntax
    helps for those "quick" needs.

    I've started by letting it do my local work where speed/compatibility
    isn't important, and I'm using it to generate large blocks of
    consistent code in my core language.

    > I perceive, from what I've read, that this could be the case. I see all
    > these "testimonials" that claim rapid development and this is inticing,
    > yet at the same time, having done *some* Ruby coding, this is a little
    > hard for me to believe because in my estimation, the paradigm in Ruby is
    > entirely different than in just about any other procedural language and
    > even from the OO aspects of Perl, C++ and Java. To me, the difference
    > between Ruby and just about anything else (common) is the same as when,
    > in the development world, many of us made the leap from procedural to
    > OO. I think the gap between Ruby and most everything else is that big
    > -- as well as the payoffs...?


    One of the payoffs is the opportunity to think differently :)

    --
    Bill Guindon (aka aGorilla)
     
    Bill Guindon, Sep 15, 2004
    #7
  8. Chris

    Brian Wisti Guest

    --- Chris <> wrote:

    > I didn't even think about asking this question until now, based on a
    > paragraph I wrote in another thread, so I thought I would ask...
    >
    > I've had this long time infatuation with Ruby and as a fairly
    > proficient
    > Perl coder, have even recreated a few "Ruby things" in Perl over the
    > last few years. But a couple of "Wow!" factors in Ruby have kept me
    > hanging around and I've finally decided that the only way is to ween
    > myself off of Perl and just start using Ruby all the way.
    >
    > This is hard because I can't afford a lot of downtime, which has been
    >
    > the biggest strike for me against using Ruby. I'm fairly fast,
    > tight,
    > and concise at hitting targets using Perl and I don't want to loose
    > that
    > productivity using Ruby. Still, it appears a "hit" has to be taken
    > if I
    > really want to learn it as well as I know Perl.
    >
    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?
    >
    > I perceive, from what I've read, that this could be the case. I see
    > all
    > these "testimonials" that claim rapid development and this is
    > inticing,
    > yet at the same time, having done *some* Ruby coding, this is a
    > little
    > hard for me to believe because in my estimation, the paradigm in Ruby
    > is
    > entirely different than in just about any other procedural language
    > and
    > even from the OO aspects of Perl, C++ and Java. To me, the
    > difference
    > between Ruby and just about anything else (common) is the same as
    > when,
    > in the development world, many of us made the leap from procedural to
    >
    > OO. I think the gap between Ruby and most everything else is that
    > big
    > -- as well as the payoffs...?
    >
    > So I'm looking for feedback from those that have converted, esp. from
    > a
    > hardcore Perl perspective.
    >
    > Thanks,
    > -ceo


    I'm not exactly an ex-Perl coder, since I still use Perl everyday at
    work and at home. I have found Ruby to be an excellent item in my
    toolkit for testing, prototyping, and creating applications where the
    corresponding Perl code would risk melting my brain. Note: High risk of
    brain-melt results in significant difficulties maintaining code.

    More recently, I've also been exploring the use of Ruby as a shell
    scripting language. Guess what? The Ruby code is freakishly similar to
    the Perl code for accomplishing the same tasks, minus a few punctuation
    symbols. This led me to my first assertion of Perl-to-Ruby transition:

    Brian Wisti's First Assertion of Perl-to-Ruby Transition
    --------------------------------------------------------
    "You're probably trying too hard."

    Sorry, I just had to make it look all fancy like that for a second. Ego
    is a delicate thing, and it demands attention at all times ;-)

    You don't need to take advantage of every language feature to become
    proficient in a language. Heck, I was making useful programs in Perl
    for a couple years before I started using references and Perl-style
    objects. So look at the list, admire the cleverness of the Ruby gurus
    with their management of reflection, continuations, Procs, and whatnot.
    Then go make the programs you need to make in the way you know how.
    Take advantage of the similarities between Ruby and other languages.
    Incorporate the really neat features as you develop an understanding of
    them. It's okay if your Ruby code looks a little like Perl at first, or
    a little like C++. You'll get the hang of the "right way" as your
    knowledge improves.

    What's the payoff using Ruby instead of Perl? For me, the end result is
    stress reduction. It takes roughly the same amount of effort to create
    a small program in the two languages, but progressively less effort to
    create Ruby applications as the size and scope of the app increases.
    The Principle of Least Surprise means that most things are done like
    you would expect them to be (or at least like Matz expects them to be,
    which is still more consistent than most languages out there).

    It is nice to have legible code, too. I know that "legible" is entirely
    subjective, and you don't have to agree with it if you don't want to.
    You can make clean code in Perl, but it takes a little more work and a
    lot more discipline. Plus, all of the "my/local/our" stuff and shifting
    subroutine arguments and list context vs. scalar context (and, and,
    ...) in Perl starts to look more than a little extraneous, interfering
    with your reading of the actual code logic. Since Ruby doesn't use any
    of that stuff, it's easier for me to see the meat of the code.

    So that's my thoughts. And everybody else has their own thoughts as
    well, naturally ;-)

    Kind Regards,

    Brian Wisti
     
    Brian Wisti, Sep 15, 2004
    #8
  9. Chris

    Phil Tomson Guest

    In article <REY1d.17014$>,
    Chris <> wrote:
    >I didn't even think about asking this question until now, based on a
    >paragraph I wrote in another thread, so I thought I would ask...
    >
    >I've had this long time infatuation with Ruby and as a fairly proficient
    >Perl coder, have even recreated a few "Ruby things" in Perl over the
    >last few years. But a couple of "Wow!" factors in Ruby have kept me
    >hanging around and I've finally decided that the only way is to ween
    >myself off of Perl and just start using Ruby all the way.
    >
    >This is hard because I can't afford a lot of downtime, which has been
    >the biggest strike for me against using Ruby. I'm fairly fast, tight,
    >and concise at hitting targets using Perl and I don't want to loose that
    >productivity using Ruby. Still, it appears a "hit" has to be taken if I
    >really want to learn it as well as I know Perl.


    I don't think that the 'hit' is all that big. When I moved from Perl to
    Ruby (as a primary agile programming language; I still use C++ ) after
    about 3 days of Ruby coding I actually felt more comfortable and more
    productive in Ruby than I had in Perl (and I had been coding in Perl for six
    years, including OO Perl). I think that Ruby just 'hangs' together a lot
    better. You know all of the methods that will operate on a particular
    object of a certain class (or you can easily find out) and there were more
    methods available on builtin classes (for example, look at all of the
    methods available on Array objects and compare with functions available in
    Perl to operate on @list objects).

    >
    >So the question for any hardcore Perl coders out there that have
    >converted to Perl (or are fluent in both) is: Is it really worth the
    >time? Are the paybacks there? And do you feel you've exceeded your
    >capabilities in Perl using Ruby?
    >


    First off, I _was_ a big Perl fan, however I haven't used Perl for
    anything significant for about 3.5 years now. I've forgotten Perl such
    that anytime I look at Perl code these days it just makes my eyes hurt.
    So in my case, I made a very clean break from Perl.

    To answer your questions: Yes, it's worth the time especially since you
    can be productive in Ruby in a day or two. It doesn't take much time to
    get productive in Ruby coming from Perl. Sure you'll be coding Perl in
    Ruby for the first few months, but keep at it and you'll be learn The Ruby
    Way soon enough. The point is, you can be productive in Ruby in a short
    time - it may not be code you'll want to show off here on the list, but
    it'll get the job done.

    Yes, I definately feel that I've exceeded my Perl capabilities. Do OO
    Perl for a while and you'll really appreciate moving to Ruby.

    >I perceive, from what I've read, that this could be the case. I see all
    >these "testimonials" that claim rapid development and this is inticing,
    >yet at the same time, having done *some* Ruby coding, this is a little
    >hard for me to believe because in my estimation, the paradigm in Ruby is
    >entirely different than in just about any other procedural language and
    >even from the OO aspects of Perl, C++ and Java.


    Yes & no. You mention a mix of agile and static languages. Ruby OO is
    much nicer than OO Perl where everything is a do-it-yourself project. OO
    in an agile language like Ruby feels much different than in C++ or Java
    (you have much more freedom in Ruby).

    Phil
     
    Phil Tomson, Sep 15, 2004
    #9
  10. Chris

    Phil Tomson Guest

    In article <>,
    Dick Davies <> wrote:
    >* Chris <> [0954 15:54]:
    >> I didn't even think about asking this question until now, based on a
    >> paragraph I wrote in another thread, so I thought I would ask...

    >
    >> .....I've finally decided that the only way is to ween
    >> myself off of Perl and just start using Ruby all the way.

    >
    >Good on you boy, although your family will starve :)
    >I am still 'Writing Perl for Food', though I hope to start sneaking Ruby under
    >the radar here now that I've settled in and earned some credit.


    Actually things are changing. This place is hiring Ruby programmers for
    Rails work, for example:
    http://robotcoop.com/

    I know of another Ruby job that is probably still open in my area as well.

    I'd vote for making a clean break from Perl. It might be that learning
    Ruby and Rails will actually turn out to be a good career move (let's
    hope).

    Phil
     
    Phil Tomson, Sep 15, 2004
    #10
  11. Chris

    Chris Guest

    James Britt wrote:
    > Chris wrote:
    >
    >> ... in my estimation, the paradigm in Ruby is entirely different than
    >> in just about any other procedural language and even from the OO
    >> aspects of Perl, C++ and Java. To me, the difference between Ruby and
    >> just about anything else (common) is the same as when, in the
    >> development world, many of us made the leap from procedural to OO. I
    >> think the gap between Ruby and most everything else is that big -- as
    >> well as the payoffs...?

    >
    >
    > Could I can encourage you to go into more detail about this? In what
    > ways do you see the Ruby paradigm as being s different from Perl, Java,
    > and C++?
    >
    > When you started learning Ruby, did you try to adapt familiar Perl/Java
    > concepts/structures/object models to Ruby? If so, did this help or
    > hinder your learning Ruby?


    I think this is precisely the point and your question brings this out
    into the clear a little more. It would be a mistake IMO to try and
    approach Ruby with "Perl eyes." Sure, there are similiar things in both
    languages. It's hard not to think that Matz didn't borrow from Perl, ad
    in fact, I think he states this outright (as well as having borrowed
    from others as well.) Overall, I think it's a mistake to approach ANY
    language from the viewpoint of another to the extent it's possible NOT
    to do so. (If that makes sense?) This is the driving force behind my
    original question, so your question clarifies this more.

    It's easier to make my point in Perl than it is in Ruby, but I'll try a
    couple of examples either way:

    (1) The complete OO nature of Ruby IMO changes everything. Perl is
    still procedural in it's basic constructs. To iterate from 1 to 10 in
    Perl can be shortened *somewhat* from say C or Java using this construct:

    for (0..9) { do_somthing_with( $_ ) }

    But whether the above shorthand is used in Perl, or the traditional "C"
    way (eg. "for (my $i=0; $i<10; $i++) { do_something_with( $i ) }") it's
    still procedural. I think the Ruby way is significantly different:

    10.times { |i| do_something_with( i ) }

    To me, this is a significant difference and I think this gets magnified
    the deeper one goes into Ruby.

    (2) I think the need to be familiar with the class methods and
    properties is magnified in Ruby. This is similiar to C++ where it's
    difficult to be productive unless one gains experience in the classes
    and methods available. In Perl, this is not as much the case, again do
    to the fact you can go completely procedural in Perl and get away with
    it. If you do use OO and modules in Perl, then you only need to know
    the methods for the module you imported and the rest can be procedural
    in Perl. In Ruby, it seems you can't really get away with that it seems.

    (3) Another contrived example, this time in Ruby:

    def Contrived
    3.times { yield }
    end

    [ "tic", "tac", "toe" ].each do |item|
    Contrived { printf "%s ", item }
    printf "\n"
    end

    There is a lot about this that is different than Perl IMO. I could
    create an anonymous subroutine in Perl to function something like the
    yield block, and I realize the Ruby above is itself somewhat contrived,
    but... still, you wouldn't normally do something like this in Perl
    whereas in Ruby, these sorts of things are actually useful.

    (4) Each language has it's own strengths. IMO one of Perl's strengths
    is the simplicity and consistency of it's parameter passing:

    sub shell {

    my @output;
    for (@_) { push @output, `$_` }
    chomp( @output );
    return wantarray ? @output : \@output;

    }

    ## My favorite "Rubyism" I use all the time in Perl -- puts()!

    sub puts { for (@_) { print "$_\n" } }

    puts( shell(
    "ls -l",
    "ps -ef | grep -i foo",
    "rm *.bar",
    ));

    You can't do something like that in many languages. Because of the
    parameter passing, procedures flow very well and usefully in Perl from
    one to the other. The same is true in every aspect of Perl and is in a
    very large sense how OO works in Perl. This is a Perl example of what I
    feel is probably lurking in Ruby. This is how I would do something like
    this in Perl that is not available really in this way anywhere else. My
    feeling is that the same sort of thing prevades Ruby. It "does things"
    that other languages can't do, including Perl.


    So the point is I don't want to approach Ruby as Perl even though there
    are similiarities. Unfortunately, I see most people approach Perl in
    the same way as C and Java and JavaScript and Perl really looses it's
    benefits quickly when approached in this way. I don't want to do the
    same with Ruby.

    Perhaps these weak examples answer your question. And so the original
    question, clarified more (more muddied more as the case may be),
    remains... Howz it feel to convert to Ruby _really_ and not just
    applying the "Perl" mindset to Ruby, which I think is a mistake. It's
    clear from even the basic constructs it isn't the same.

    -ceo
     
    Chris, Sep 15, 2004
    #11
  12. On Wed, 15 Sep 2004 14:50:25 GMT, Chris <> wrote:
    [snip]
    > So the question for any hardcore Perl coders out there that have
    > converted to Perl (or are fluent in both) is: Is it really worth the
    > time? Are the paybacks there? And do you feel you've exceeded your
    > capabilities in Perl using Ruby?


    I'll throw my $0.02 into the pot ...

    I wouldn't call myself a "hardcore" anything, but I have used Perl a lot,
    written about Perl a good deal, and taught a fair number of Perl courses
    (introductory and advanced). I do like Perl.

    If you are fluent in Perl and have a good grasp of OO (Perl's and/or other
    langauges), then fluency in the Ruby language itself should be a relatively
    quick and enjoyable experience. What *will* take a while longer is becoming
    familiar enough with what is and isn't available in the standard libraries
    or on RAA and rubyforge to become as productive as you currently are in
    Perl (but that isn't a "language" issue per se).

    I will mention that I have tried out Python on a couple of occassions, but
    was just never seriously drawn to it.

    Ruby, on the other hand, appealed to me right away. As different as Ruby
    and Perl are, they both "fit" with how my mind thinks and solves problems
    --- and I've always been an advocate of balancing the old axiom of "using
    the right tool for the job" with "using the right tool for your mind". Ruby
    and Perl are both darn good tools in my mind, and for my mind. So for me it
    was worth it, ymmv.

    regards,
    andrew

    --
    Andrew L. Johnson http://www.siaris.net/
    What have you done to the cat? It looks half-dead.
    -- Schroedinger's wife
     
    Andrew Johnson, Sep 15, 2004
    #12
  13. Chris

    Chris Guest

    Peter Hickman wrote:
    > Being a long time Perl programmer I tend to reach for Perl when I have a
    > problem to solve. Mainly because I can just grab a module off CPAN and
    > hack something up.
    >
    > However whenever I want to write a simulation (population models, music
    > generators etc.) I go straight for Ruby.
    >
    > I can hack something up pretty quick in Perl, but I stand a better
    > chance of maintaining it in Ruby so I get it to work in Perl and then
    > take the design over to Ruby.
    >


    Interesting, and I think I can/could continue to relate to this. As
    already stated, I can usually whack out a concise, tight solution in
    Perl in just a little bit of time. I'm anxious to see if I can get to
    that place in Ruby and what that would look like. This sounds like Ruby
    might be more suited to "bigger" tasks and Perl to the small ones. I'm
    sure others will jump in here momentarily and dispute this...

    -ceo
     
    Chris, Sep 15, 2004
    #13
  14. Chris

    Curt Hibbs Guest

    Phil Tomson
    >
    > Actually things are changing. This place is hiring Ruby programmers for
    > Rails work, for example:
    > http://robotcoop.com/
    >
    > I know of another Ruby job that is probably still open in my area as well.
    >
    > I'd vote for making a clean break from Perl. It might be that learning
    > Ruby and Rails will actually turn out to be a good career move (let's
    > hope).


    Very interesting... I don't know where your "area" is, where is all this
    happening?

    Curt
     
    Curt Hibbs, Sep 15, 2004
    #14
  15. Chris

    Brian Wisti Guest

    Hmm ... TMTOWTDI applies in both Perl and Ruby. I think I would have
    written most of your examples differently, and that difference is
    probably why Perl<->Ruby isn't a big deal for me.

    > (1) The complete OO nature of Ruby IMO changes everything. Perl is
    > still procedural in it's basic constructs. To iterate from 1 to 10
    > in
    > Perl can be shortened *somewhat* from say C or Java using this
    > construct:
    >
    > for (0..9) { do_somthing_with( $_ ) }


    foreach my $i (0..9) { do_something_with($i) }

    or even

    map { do_something_with($_) } (0..9);

    > 10.times { |i| do_something_with( i ) }


    0.upto(9) { |i| do_something_with(i) }

    > To me, this is a significant difference and I think this gets
    > magnified
    > the deeper one goes into Ruby.


    True enough, but presumably your understanding deepends as you go
    deeper into Ruby, yes?

    >
    > (2) I think the need to be familiar with the class methods and
    > properties is magnified in Ruby. This is similiar to C++ where it's
    > difficult to be productive unless one gains experience in the classes
    >
    > and methods available. In Perl, this is not as much the case, again
    > do
    > to the fact you can go completely procedural in Perl and get away
    > with
    > it. If you do use OO and modules in Perl, then you only need to know
    >
    > the methods for the module you imported and the rest can be
    > procedural
    > in Perl. In Ruby, it seems you can't really get away with that it
    > seems.


    Sure, but POLS is a decent guideline, and when all else fails I call
    obj.methods() from irb to see what I get to play with. I generally
    don't need to refer to docs for libraries that I haven't imported, so
    I'm not sure I understand that bit.

    And maybe things aren't as straightforward in Perl as you describe. One
    still has to be familiar with the full standard library, the various
    sigils, the built-in types, and all of the modules that you've
    imported.

    >
    > (3) Another contrived example, this time in Ruby:
    >
    > def Contrived
    > 3.times { yield }
    > end
    >
    > [ "tic", "tac", "toe" ].each do |item|
    > Contrived { printf "%s ", item }
    > printf "\n"
    > end
    >
    > There is a lot about this that is different than Perl IMO. I could
    > create an anonymous subroutine in Perl to function something like the
    >
    > yield block, and I realize the Ruby above is itself somewhat
    > contrived,
    > but... still, you wouldn't normally do something like this in Perl
    > whereas in Ruby, these sorts of things are actually useful.


    Useful, sure. Widely used, you betcha. Fact is that I've still never
    needed to use yield in any production code. Use what you need, not what
    you feel like you're supposed to. Your sample Perl code didn't show
    taint-checking or full conformance to strict and warnings, even though
    that is widely promoted as the "right way" to do things.

    >
    > (4) Each language has it's own strengths. IMO one of Perl's
    > strengths
    > is the simplicity and consistency of it's parameter passing:
    >
    > sub shell {
    >
    > my @output;
    > for (@_) { push @output, `$_` }
    > chomp( @output );
    > return wantarray ? @output : \@output;
    >
    > }
    >
    > ## My favorite "Rubyism" I use all the time in Perl -- puts()!
    >
    > sub puts { for (@_) { print "$_\n" } }
    >
    > puts( shell(
    > "ls -l",
    > "ps -ef | grep -i foo",
    > "rm *.bar",
    > ));


    Yup, it's a strength of Perl, and that's a nifty puts subroutine :)

    > So the point is I don't want to approach Ruby as Perl even though
    > there
    > are similiarities. Unfortunately, I see most people approach Perl in
    >
    > the same way as C and Java and JavaScript and Perl really looses it's
    >
    > benefits quickly when approached in this way. I don't want to do the
    >
    > same with Ruby.


    What's wrong with taking advantage of the languages that Ruby builds
    on? Familiarity with Perl, Python, Smalltalk, and LISP are all
    incredibly useful with Ruby, and sometimes a design is easiest to
    express in something resembling one of those languages.

    I can see a problem with trying to make your Ruby code look *exactly*
    like Perl code, same as writing a C-style for(;;) loop instead of a
    for/foreach loop in Perl is ugly. But hey, sometimes it's useful. I
    don't knock what works, as long as I can read it :)

    >
    > Perhaps these weak examples answer your question. And so the
    > original
    > question, clarified more (more muddied more as the case may be),
    > remains... Howz it feel to convert to Ruby _really_ and not just
    > applying the "Perl" mindset to Ruby, which I think is a mistake.
    > It's
    > clear from even the basic constructs it isn't the same.


    Sure, it's not the same. But insisting on doing things the "Ruby Way"
    immediately is naturally going to result in a serious dip in
    productivity compared to going out and writing code that works, right
    away.

    But this is a philosophical difference, and I doubt that our
    philosophical worlds will intersect much ;-)

    Kind Regards,

    Brian Wisti
    http://coolnamehere.com/
     
    Brian Wisti, Sep 15, 2004
    #15
  16. Chris

    Dick Davies Guest

    * Phil Tomson <> [0909 19:09]:

    > .... You know all of the methods that will operate on a particular
    > object of a certain class (or you can easily find out) and there were more
    > methods available on builtin classes (for example, look at all of the
    > methods available on Array objects and compare with functions available in
    > Perl to operate on @list objects).


    That's something that shouldn't be overlooked -

    when I went back to perldoc after maybe 9 months away from Perl I had
    major problebs remembering the right function to do a particular bit
    of manipulation on a Hash. perldoc -f isn't much use without a method name,
    and even Google is only useful if can say what you want :)

    With Ruby it was just 'ri Hash;ri Enumerable' to see all the methods
    that worked on a Hash.

    --
    No problem is so formidable that you can't just walk away from it.
    -- C. Schulz
    Rasputin :: Jack of All Trades - Master of Nuns
     
    Dick Davies, Sep 15, 2004
    #16
  17. Chris

    Zach Dennis Guest

    Chris wrote:

    > Peter Hickman wrote:
    >
    >> Being a long time Perl programmer I tend to reach for Perl when I
    >> have a problem to solve. Mainly because I can just grab a module off
    >> CPAN and hack something up.
    >>
    >> However whenever I want to write a simulation (population models,
    >> music generators etc.) I go straight for Ruby.
    >>
    >> I can hack something up pretty quick in Perl, but I stand a better
    >> chance of maintaining it in Ruby so I get it to work in Perl and then
    >> take the design over to Ruby.
    >>

    >
    > Interesting, and I think I can/could continue to relate to this. As
    > already stated, I can usually whack out a concise, tight solution in
    > Perl in just a little bit of time. I'm anxious to see if I can get to
    > that place in Ruby and what that would look like. This sounds like
    > Ruby might be more suited to "bigger" tasks and Perl to the small
    > ones. I'm sure others will jump in here momentarily and dispute this...
    >
    > -ceo


    I'm not a hardcore perl user. I learned perl and ruby at the same time.
    After a few months I dropped Perl and went with Ruby. A coworker of mine
    uses Perl a heck of a lot (and refuses to try Ruby...ignorance..arghh)
    and we did a test one day. We both wrote a script to parse out Flash
    ActionScript code. In one hour I was done with the requirements we had
    came up with. About an hour later he was finished. He even stated that
    my code looked cleaner then his, and mine was about 60 lines less of
    code. Although his code did run about 4 seconds faster per 1000 files
    of about 200 lines of code.

    On another note I think that Perl coders like Perl because if they have
    a specific problem they can write up a script start to finish relatively
    quick to solve it. Where Perl lacks here is that if that problem changes
    or evolves (which they often do) and the requirements change, perl
    coders don't go refactor their code...they just start a whole new script
    and rewrite it, which works for small scripts and small problems, but
    not for larger ones. Perhaps this is how it should be interpreted when
    you say "sounds like Ruby might be more suited to "bigger" tasks and
    Perl to the small ones", because I would think more Ruby programmers
    refactor their code instead of doing a rewrite everytime a requirement
    changes. (Assuming that the requirement change is a month or two or more
    after the initial script was written).

    Zach
     
    Zach Dennis, Sep 15, 2004
    #17
  18. Chris

    Zach Dennis Guest


    > I'm not a hardcore perl user. I learned perl and ruby at the same
    > time. After a few months I dropped Perl and went with Ruby. A coworker
    > of mine uses Perl a heck of a lot (and refuses to try
    > Ruby...ignorance..arghh) and we did a test one day. We both wrote a
    > script to parse out Flash ActionScript code. In one hour I was done
    > with the requirements we had came up with. About an hour later he was
    > finished. He even stated that my code looked cleaner then his, and
    > mine was about 60 lines less of code. Although his code did run about
    > 4 seconds faster per 1000 files of about 200 lines of code.
    >
    > On another note I think that Perl coders like Perl because if they
    > have a specific problem they can write up a script start to finish
    > relatively quick to solve it. Where Perl lacks here is that if that
    > problem changes or evolves (which they often do) and the requirements
    > change, perl coders don't go refactor their code...they just start a
    > whole new script and rewrite it, which works for small scripts and
    > small problems, but not for larger ones. Perhaps this is how it should
    > be interpreted when you say "sounds like Ruby might be more suited to
    > "bigger" tasks and Perl to the small ones", because I would think more
    > Ruby programmers refactor their code instead of doing a rewrite
    > everytime a requirement changes. (Assuming that the requirement change
    > is a month or two or more after the initial script was written).
    >
    > Zach
    >

    My assumption on Perl "coders" here is my experience with them. I am
    not trying to stereotype the whole perl world.

    Zach
     
    Zach Dennis, Sep 15, 2004
    #18
  19. On Thu, 16 Sep 2004 03:46:00 +0900, Curt Hibbs <> wrote:
    > [...]
    > Very interesting... I don't know where your "area" is, where is all this
    > happening?
    >
    > Curt
    >


    Portland, OR, and the surrounding 'burbs. I'm working at Intel using
    Ruby right now, (in a position which Phil vacated a few months ago)
    and we're looking to hire another coder to work with me. We're not the
    only group in-house using Ruby either; we're just (AFAIK) the first of
    be hiring Ruby coders specifically.

    --
    Lennon
    rcoder.net
     
    Lennon Day-Reynolds, Sep 15, 2004
    #19
  20. Chris

    Bill Kelly Guest

    Hi,

    From: "Chris" <>
    >
    > As already stated, I can usually whack out a concise, tight solution in
    > Perl in just a little bit of time. I'm anxious to see if I can get to
    > that place in Ruby and what that would look like. This sounds like Ruby
    > might be more suited to "bigger" tasks and Perl to the small ones. I'm
    > sure others will jump in here momentarily and dispute this...


    One of the things that thrilled me with ruby was that
    it didn't force me to give up quick one-off hack style
    scripting, in order to have a cleaner language for bigger
    tasks....

    I invoke ruby from the command line fairly frequently,
    for random things like:

    ruby -i -pe 'gsub(/\015/,"")' *.cpp *.h

    If I recall my perl correctly (been about three years now)
    the perl is slightly shorter:

    perl -i -pe 's/\015//g' *.cpp *.h

    But ruby has proved sufficiently concise for my needs
    in this regard. Actually, sometimes the ruby comes out
    shorter than what I think the equivalent perl would be.

    Couple days ago a friend who has been learning ruby
    asked me about making a program to gather and print a
    sorted list of all unique IP addresses in a logfile he
    had. (He said a simple string-based sort was OK, and
    the logfile structure was simple enough that a very
    basic regexp would identify IP addrs without false
    positives.) I first approached the problem with a
    hash, as I would have in Perl... and then I remembered
    ruby has Array#uniq.... So the solution ended up
    being:

    puts ARGF.read.scan(/\d+\.\d+\.\d+\.\d+/).uniq.sort

    =D

    Not effing bad, we both thought. :)


    Regards,

    Bill
     
    Bill Kelly, Sep 15, 2004
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kathy Rogers
    Replies:
    0
    Views:
    352
    Kathy Rogers
    Dec 11, 2003
  2. Lois Parker
    Replies:
    4
    Views:
    398
    Lee Fesperman
    Dec 12, 2003
  3. Armin Roehrl
    Replies:
    12
    Views:
    182
    Armin Roehrl
    Jul 30, 2003
  4. Robin

    just curious about perl coders

    Robin, Apr 4, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    89
    Joe Smith
    Apr 4, 2004
  5. Replies:
    21
    Views:
    254
    Mirco Wahab
    Apr 3, 2007
Loading...

Share This Page