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

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

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

"Chris" <ceo@nospan.on.net> schrieb im Newsbeitrag
news:REY1d.17014$ZC7.9806@newssvr19.news.prodigy.com...

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. :slight_smile:

Kind regards

    robert

* Chris <ceo@nospan.on.net> [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 :slight_smile:
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 :slight_smile:

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

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.

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

···

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?

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 :slight_smile:

···

On Wed, 15 Sep 2004 23:54:51 +0900, Chris <ceo@nospan.on.net> wrote:

--
Bill Guindon (aka aGorilla)

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

···

--- Chris <ceo@nospan.on.net> 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

--------------------------------------------------------
    "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 :wink:

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 :wink:

Kind Regards,

Brian Wisti
brian@coolnamehere.com

In article <REY1d.17014$ZC7.9806@newssvr19.news.prodigy.com>,

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

···

Chris <ceo@nospan.on.net> 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

···

On Wed, 15 Sep 2004 14:50:25 GMT, Chris <ceo@nospan.on.net> wrote:

--
Andrew L. Johnson http://www.siaris.net/
      What have you done to the cat? It looks half-dead.
          -- Schroedinger's wife

Heck, I took all my existing Perl code and converted it to Ruby.

···

--
John W. Kennedy
Read the remains of Shakespeare's lost play, now annotated!
http://pws.prserv.net/jwkennedy/Double%20Falshood.html

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 learned perl well before ruby. I wouldn't say that I'm a hardcore
perl programmer, but I had written some fairly long perl scripts. And
I still work with perl, because that's what most of the other systems
programmers here are familiar with.

For me, I think it's just a question of "how I think". I usually have
to start out on some script with either no idea what I'm doing, or
with explicit instructions which turn out to be wrong (such as "the
data will always be sorted, and in the correct order" -- only to find
out the incoming data is usually in the exactly-wrong order...). So,
whether ruby or perl, I start out to write one thing, and later find
out that I need to change that considerably. When programming in
perl, I end up with the script getting messier and messier. With ruby
I manage to keep refactoring the problem fairly easy, so the script
keeps looking better the more I have to work on it.

I think this is partially because I used to do a lot with ObjectiveC,
so it is pretty natural for me to use object-oriented tactics, if I
have a language where that's easy to do. While I have done a lot with
perl, I never did quite wrap my mind around how to write
"object-oriented Perl". But writing Ruby seems very straightforward
to me.

YMMV...

[...] 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.

I know some programmers who do a fine job writing OO-perl, and end up
with code that is quite readable. My attempts end up a mess. Maybe
my brain is just wired wrong.

Personally, I find C++ to be horrid. I do not consider it a usable OO
language. That's just my opinion, of course. I have certainly read
through a lot of C++ code where the author has absolutely no idea what
OO programming is about.

Java looks pretty reasonable in my opinion, but in my job I have no
real reason to use it for anything. So, I haven't really tried to
write anything major in it.

The object-oriented language that I had a lot of experience with is
Objective-C, in the days when NeXT Computers was still making hardware
(12 years ago...). The combination of Objective-C and the
InterfaceBuilder goes a long way to guiding the programmer so you
really start to understand what OOP is about. You pick up what you
should be trying to do with objects, and what you gain by doing it
correctly. For me, coming from that Objective-C background, Ruby was
easy to pick up.

I have no background with Smalltalk, but I suspect that programmers
who know that OO language would also find Ruby easy to pick up.

···

On Wed, 15 Sep 2004 23:54:51 +0900, Chris <ceo@nospan.on.net> wrote:

--
Garance Alistair Drosehn = drosihn@gmail.com
Senior Systems Programmer or gad@FreeBSD.org
Rensselaer Polytechnic Institute; Troy, NY; USA

On Wed, 15 Sep 2004 23:54:51 +0900

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

Recently it dawned on me that one of the reasons I like Ruby so much is
method chaning. Why? At first, I thought it was because the program
flow went left to right, just like reading. But then it occurred to me
that being able to do something like this:

    `ypcat -k amd_cise`.map { |line|
        line.match(/rhost:=([^;]+)/).captures[0] rescue next
    }.compact.sort.uniq.each { |server|
  ...

is just like using Unix pipes. When I used perl, and I needed to process
the output of a command like the above, I would generally do all the
work with a regular Unix pipeline. With ruby, the processing is very
similar already. You have to do a little more work, like catching
exceptions and things like nil elements, but the program flow is so
natural there's no need to exec the extra programs.

I recently tried hacking on some Perl (I've written thousands of lines
over the years), and I can barely even remember what to do, which is
fine, really :->

Jim

···

Chris <ceo@nospan.on.net> wrote:

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

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

In article <20040915160327.GA4046@lb.tenfour>,

* Chris <ceo@nospan.on.net> [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 :slight_smile:
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:

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

···

Dick Davies <rasputnik@hellooperator.net> wrote:

James Edward Gray II 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.

I've run into this too, and it is a bit of a hiccup, but not too bad. It's easy in Perl to "auto-type" and that's mostly nice.

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.

A great post. Very helpful. I'd probably agree or will end up agreeing with all of this over time. It is difficult to overcome CPAN versus Ruby's youngness as you pointed out. But the rest is on the money too (eg. Perl's "way" of OO'ing, etc.)

-ceo

···

On Sep 15, 2004, at 9:54 AM, Chris wrote:

Bill Guindon wrote:

···

On Wed, 15 Sep 2004 23:54:51 +0900, Chris <ceo@nospan.on.net> wrote:

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 :slight_smile:

Absolutely. One of my primary intriques with Ruby, to be sure...

-ceo

* Phil Tomson <ptkwt@aracnet.com> [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 :slight_smile:

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

Brian Wisti wrote:

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.

I'm seeing this claim more and more and I'm starting to get sold. Where there's smoke, there's fire. Multiple people can't be saying this sort of thing for no reason.

-ceo