Ruby for command line applications

That’s because they’re at the top, in the headers.

List-Unsubscribe: mailto:[email protected]?body=unsubscribe

I was talking about the way people generally use the two languages:
Perl => quick hacks; Ruby => engineered solutions. …

I find that if I have non-trivial structured data to manage, I’ve
crossed the threshold where I want Ruby’s better OO support and more
“literate” Hash and Array representations. Perl’s equivalents, while
perhaps more concise, become harder to understand and use. Plus, I
love playing with blocks :wink:

dean


Dean W.
http://www.aspectprogramming.com

http://www.contract4j.org

How to unsubscribe?
No directions at bottom of each message.

On 4/27/06, Matthew M. [email protected] wrote:

That’s because they’re at the top, in the headers.

List-Unsubscribe: mailto:[email protected]?body=unsubscribe

On 4/27/06, John Brookes [email protected] wrote:

How to unsubscribe?
No directions at bottom of each message.

The main Ruby mailing lists page (
http://www.ruby-lang.org/en/20020104.html ) gives brief instructions:

|
| To unsubscribe from a list, send a mail which body is “unsubscribe” to the
| controller address.
|

Though, just to clean that up, it could be changed to read
something like:

}
} To unsubscribe from a given list, send an email to that mailing
} list’s controller address. The body of that email should contain
} only the word “unsubscribe”. It doesn’t matter what the subject
} line is.
}

I find that if I have non-trivial structured data to manage, I’ve
crossed the threshold where I want Ruby’s better OO support and more
“literate” Hash and Array representations. Perl’s equivalents, while
perhaps more concise, become harder to understand and use. Plus, I
love playing with blocks :wink:

dean

I agree completely, I began converting a small time keeper comand

line app I wrote in perl to keep track of my hours over to ruby as a way
of learning ruby. I quickly began adding new features because the
object model makes that so easy. That said, I still “enjoy” creating
reports in perl over ruby. Probably because I’ve written so many more
in perl.

Charlie B.
www.recentrambles.com

On 4/27/06, John G. [email protected] wrote:

Considering the fact that I won’t develop any web application, Which one
Plusses for Ruby:

  • Ruby seems a little more tailored for admin work than Python (since
    Ruby has built in regexes, easy stdin/stdout)
  • RDoc (documentation for your scripts comes right from plain old
    comments above the thing they’re documenting).
  • Personally, I prefer its (Perl-like) string handling to Python’s.

Minuses for Ruby:

  • Lack of docs (good printed books though)

By the way, there are, of course, other plusses for Ruby that are
relevant if you’re looking at it for other uses besides system
administration.

Also, Ruby’s a very consistent language too (dunno why I only
mentioned this for Python above – they’re both pretty
self-consistent).

Alan M wrote:

Hi,

I am a Linux administrator and I use Perl for scripting.
I do not develop any web applications. My programs are command line
tools.

At this phase I am thinking to upgrade my programming language to either
Python or Ruby.

I’m new to ruby but have years of experience with perl and python. I
generally perfer python over perl. But for oneliners and a lot of
sysadmin scripting I’ve always felt that perl really outshines python.

alex

Alan M wrote:

would be a better choice for me Perl or Ruby?

Well, I don’t know anything about Python and not a whole heck of a lot
about Ruby. I’ve been using Perl for fairly complex “scripts” for almost
ten years now. Like another poster on this thread, I got tired of trying
to manage large “awk” scripts and wanted a language that made it at
least possible to write structured readable programs. That turned out to
be Perl 4.

If I were starting this project or set of projects today, I’d use Ruby.
It’s much better designed for objects than what’s been tacked on to
Perl. I don’t have any pressing need to rewrite my few thousand lines of
Perl into Ruby (or Python), and what I don’t do in Perl is usually
number crunching that I do in R.

So questions for you:

  1. Do you just want to learn a new language, or is there something
    you’ve found Perl weak at?

  2. Is readability of your code by others important? If so, would these
    others be better off if you stuck with Perl, or migrated to Python or
    Ruby?

  3. Have you looked at Perl 6? I must admit I haven’t, and really don’t
    plan to. I’m happy with the current mix of Perl 5 (with my Perl 4 coding
    style) and R, although there is one application I have coming up that’s
    a natural fit for Rails, and if I can sell it to the bean counters and
    nay-sayers, that’s what I plan to use.

Thank you,
Alan


M. Edward (Ed) Borasky

I think the consistency comes down to how many
different ways there are to do things. That makes
it more difficult to master the idioms, because
different code does similar things in different ways.

But there is a /huge/ plus for Ruby that is lurking
in the background. After spending the weekend at the
SDForum’s Ruby conference, the meta-message for me
was that Ruby was great at building a /language/
geared towards solving a particular set of problems.

In standard terminology, they’re known as Domain Specific
Languages. But I prefer to think of them as Design
Solution Languages.

Not since Forth have I seen a language in which it
was so easy to create a problem-specific vocabulary.
I used to wish for a Forth with C-style syntax. (I
didn’t know enough to wish for OO-ness back then.)
It turns out that Ruby is it.

So my pick would be Ruby for the promise of huge
vistas of opportunity that will open up once you scale
the learning curve and reach the peak of the mountain.

(When I manage to get there, I’ll tell how the view is.)
:_)

On 4/26/06, Alan M [email protected] wrote:

would be a better choice for me Perl or Ruby?

Thank you,
Alan

They’re both good choices. I’m fairly new to Ruby, but here’s my 2
cents.

Plusses for Python:

  • Tends to be a consistent language (not too many ways to do the same
    thing).
  • Good library support.
  • Good written docs (command-line pydoc docs are lacking though, IMO).
  • Easily embeddable.

Minuses for Python:

  • OO features seem a little trickier to me than Ruby’s (bound vs.
    unbound methods, class vs. static vs. plain vanilla methods).
  • Some Python snobbishness in the community (just my opinion). Though,
    the majority of Pythonistas are friendly and helpful.
  • They put their docstrings below the thing they’re documenting
    instead of above it, where nature of course intended. :wink:
  • Personally, not fond of the whitespace-dependent code formatting
    (though many many folks claim they get used to it quickly).

Plusses for Ruby:

  • Ruby seems a little more tailored for admin work than Python (since
    Ruby has built in regexes, easy stdin/stdout)
  • RDoc (documentation for your scripts comes right from plain old
    comments above the thing they’re documenting).
  • Personally, I prefer its (Perl-like) string handling to Python’s.

Minuses for Ruby:

  • Lack of docs (good printed books though)

Eric A. [email protected] writes:

Not since Forth have I seen a language in which it
was so easy to create a problem-specific vocabulary.
I used to wish for a Forth with C-style syntax. (I
didn’t know enough to wish for OO-ness back then.)
It turns out that Ruby is it.

.oO(And that’s probably the only thing Ruby and Forth have in common…
}:-))

On 4/26/06, Alan M [email protected] wrote:

Hi,

I am a Linux administrator and I use Perl for scripting.
I do not develop any web applications. My programs are command line
tools.

At this phase I am thinking to upgrade my programming language to either
Python or Ruby.

I started to use perl for scripting maybe 10 to 12 years ago, when I
finally decided that I was trying to force ‘awk’ to do things it was
never meant to do. I wrote a lot of useful sysadmin-type programs
in perl (reading log files, summarizing data, etc). But many of those
scripts were written in bits-and-pieces. I start out needing a 3-line
perl script for some simple task. Then a week later I need to add
something else. Then I realize I could use the same script on two
different log files if I just made a few more changes. Before long,
my initial 3-line perl script is up around 700 lines. And, well, it’s a
mess. It’s a mess because it was never designed to be a 700-line
program, it was built up a few dozen lines at a time, over many
weeks or months.

When doing the same kind of scripts in ruby, I found that I do a
much better job of re-factoring the program as I added more
features to it, or as I found out that the data I needed to process
looks nothing like I was told it was going to look like. I could
write a good perl script if I started out with a fixed goal, and
stuck to whatever that original goal was, but that almost never
happens to me…

I used to do some Objective-C programming under NeXTSTEP,
and I found that the object-oriented support in ruby fits very
well with how my mind thinks. I’ve looked over python a few
times, and I know some excellent sysadmins who use python
for their work, but python just never quite caught my interest.
I’m not sure why. The usual complaint about python is the
whitespace-requirements that it has, and actually that does
not bother me at all. But for some reason I found ruby much
more compelling to the way that I think than I found python
to be.