One Task, Three Languages: Ruby vs Python vs Perl

Basic Description

The object of this experiment is a fairly straightforward one. I have a single task that I’d like to accomplish, and I’m going to accomplish it in three languages that I only have cursory knowledge of. By the end of my experiment, I will compare the three languages in terms of relative size of the programs I’ve written, ease of understanding what I wrote, ease of understanding the interfaces I had to work with, and the usefulness of the documentation I find on what I need to know. Because I honestly don’t know any of these languages, I will be literally googling the things I need and looking in the results, and only resorting to more thorough documentation if necessary. The three languages, if you haven’t guessed by now, are Ruby, Python, and Perl, in that order.


The task I have is this: As wonderful as the graphical login managers gdm and kdm are, I have them set up on my system to run through XGL and all of its related modules, and there are times when I don’t want to deal with any of that and instead rely on ‘startx’, the old-fashioned way of launching the server. ‘startx’ relies on a file, .xinitrc, to know what window manager, if any, is being started after the X server initializes. It’s a plain old shell script, essentially, and it will run varying commands based on what window manager one wants to start. The most common examples are KDE ( exec startkde ), fluxbox ( exec startfluxbox ), Gnome ( exec gnome-session ), and Xfce ( exec xfce4-session ). If one wants to change what command(s) are started when initializes, one has to manually comment out or remove what they don’t want and add what they do to this file. I’d like it to be done automagically. The script – titled txtdm – will allow for the following features:

  1. Add new choices to the .xinitrc. They will be categorized by a user-chosen name.
  2. Add executable entries to a choice. Sometimes a user will want to start more than one thing. txtdm must have the ability to do this.
  3. Remove executable entries from a choice.
  4. Remove choices from the .xinitrc.
  5. List available choices.
  6. Select a choice to activate. The rest of the choices will be commented out, so they can be chosen when the program is run again.

txtdm will be what I call actively robust – that is, if a user enters incorrect input as a command line parameter, the program will halt and display the actual options. If a user enters incorrect input while the program is running, the program will display a list of what they can actually do. There’s a chance that my programs in one language or another won’t be able to tell if the commands I’m running are genuine, but I’m doing this experiment for more than the actual gain in functionality my program will provide in the end.

Required Functionality: In one form or another, each program must be able to:

  • Read data from a file
  • Write data to a file
  • Receive user input
  • Display formatted text

These requirements are very standard, I believe, and will provide a useful cross-section of usability for each programming language.

If you do comment, please try not to provide me a solution – I don’t want to cheat!


Post a Comment

Required fields are marked *

%d bloggers like this: