• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ruby as multi purpose scripting language?

 
Lars Behnke
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Obviously most people use Ruby for developing Rails web applications. So I'd like to hear your opinion/experience on Ruby as multi purpose scripting language. How suitable is Ruby for performing the following tasks as compared to other scripting languages such as Perl, JavaScript or Groovy:

(1) Running Ruby scripts as part of an ANT/Maven build procedure.

(2) Executing Ruby scripts from a shell/batch script in order to perform
file system tasks (lets say traverse directories and rename files)

(3) Executing Ruby scripts within an java application in order to perform customizable data validations.

What do you think?

Lars
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lars Behnke:
Hi all,

Obviously most people use Ruby for developing Rails web applications. So I'd like to hear your opinion/experience on Ruby as multi purpose scripting language.


I don't know whether most people use Ruby as Ruby on Rails or not. I played around with RoR a bit and decided it would be more fun to spend some time learning Ruby than continuing to learn Ruby on Rails.

I don't really feel like addressing your specific task questions, but thought I'd point out some Ruby-specific books that are available.

This one seemed particularly pertinent to your query:
Everyday Scripting with Ruby - for Teams, Testers, and You

Enterprise Integration with Ruby

Before the Scripting with Ruby book came out I got Data Crunching - Solve Everyday Problems using Java, Python, and more and I did ruby versions of the examples instead of just typing in the example in python or whatever they were using. I had to do a bit of research to find the ruby equivalent for some of the coding, but it was pretty easy (especially since the 1st edition of programming ruby is available on the web free).
 
Lars Behnke
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply, Carol. I think I'll spend a weekend to get into Ruby.
Lars
 
Justin Gehtland
author
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also check out the PLEAC-Ruby site, which is a rewrite of the Perl cookbook in Ruby. Walks through most of the major scripting tasks you would normally perform, and you can compare them directly against their Perl counterparts for a direct comparison.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Lars Behnke:
How suitable is Ruby for performing the following tasks as compared to other scripting languages such as Perl, JavaScript or Groovy:

(1) Running Ruby scripts as part of an ANT/Maven build procedure.

(2) Executing Ruby scripts from a shell/batch script in order to perform
file system tasks (lets say traverse directories and rename files)

(3) Executing Ruby scripts within an java application in order to perform customizable data validations.


Regarding (1), I wrote an article back in 2003, titled Scripting Ant for the journal, which shows how to embed Python code into an Ant script but the same stuff can be done with Ruby, too. And, of course, running a Ruby script with the <exec/> task is just the same as running a Python or Perl script.

Regarding (2), the same functionality exists in Ruby's standard libraries as can be found in Python or Perl, for example.

Regarding (3), Ruby beats Perl 12-0. With JRuby, you can embed Ruby code into your Java application or vice versa. The same is not possible with Perl, as far as I know. For Python, however, there's Jython.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic