Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I face various types of applications (web-based, GUI-based, command-line, etc.) on various platforms (Windows, Linux, etc.) to operate everyday. There is a great opportunity for me to automate tasks by scripting. But almost every type of application and platform has its native scripting language or tools (such as VBScript and PowerShell for Windows, Bash scripts for Linux, Selenium for web applications, and AutoIt for GUI applications, etc.). It kills me to learn and maintain so many scripting languages.

I have a feeling that Ruby can interoperate with various platforms easily, and it is very expressive. So my question is:

  1. It is possible to use Ruby to script everything?

  2. If it is, what are the main disadvantages compared to the native scripting language of each platform?

share|improve this question

3 Answers 3

up vote 4 down vote accepted

Ruby is a fine choice for a general purpose scripting language on Linux, OS X, etc. But I recently needed to write some scripts that would work on every version of Windows from 2000 through 7. VBScript didn't have the functionality I needed (talking to SOAP web services for example) and PowerShell isn't available for Windows 2000, so I looked outside the Microsoft toolkit and decided to give Ruby a shot (having used it on Linux in the past). I don't exactly regret the decision, but I do wonder if there might've been a better choice. My main complaints about Ruby on Windows were:

  • There's no 64-bit Ruby for Windows (as far as I know) which made trying to access virtualized areas of the system like c:\windows\system32 a drag. I ended up shelling out to VBScript for some of that stuff; maybe there's a better way I didn't figure out.
  • It's slow. I have a quad-core CPU and 6GB RAM and irb takes 2+ seconds to load.
  • While there are Windows-specific libraries for stuff like registry access and WMI, things definitely aren't always as easy as you think they might be and the relative lack of documentation does result in some trial and error.

Still, things basically work the way you'd expect and I like working with Ruby about a thousand times better than anything built into the OS, so at a minimum, I'd say you could do worse than Ruby for general purpose scripting on Windows.

share|improve this answer

I agree with all answers above but keep in mind that Windows and POSIX have platform specific differences so it couldn't guarantee that you can reuse your script if it uses some platform specific stuff.

Ruby is fine for general scripting but not really great for performance. Anyway it allows you to identify platform inside script and execute external commands and scripts.

share|improve this answer
1  
You should know that the position of answers on StackExchange sites can not be relied on, because answers of the same amount of votes are put in a random order. So you should not say things like "I agree with all answers above" –  Adam Harte Dec 27 '11 at 4:36

Ruby does seem to fit your requirements with respect to portability across platforms (Windows, Linux, MAC), and ability to automate different kind of applications. AFAIK you can automate browsers and command line apps using ruby libraries but I am not sure about GUI based tools (Some platforms like .NET have Ruby bindings that may be helpful in this regard).

Ruby has large number of libraries so you should be able to automate lot of tasks suitable for scripting. For example, you can manipulated files in different textual formats, access network, database, and so on. However, it may not be best to do some tasks in native ruby - for example, encoding videos (but you can always invoke other tools using Ruby to do that).

If you are comparing it against BATCH and Shell Scripts, ruby can be used to perform almost any tasks these scripts can do. The disadvantage could be:

  • You may need additional installation.
  • Others may need to learn ruby to maintain your scripts.
  • If a tool has binding with some other scripting language, ruby may not be able to match that in terms of performance or even ability to access the functionality. For example, you may not be able to do everything that can be done via JavaScript from inside a browser when you are automating it via Ruby.
share|improve this answer
    
Rukuli may cover some of the GUI testing challenges faced –  Leon Stafford Sep 17 at 1:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.