Ruby as an OS-independent application platform

I originally wanted to write a little post to help non-nerdy friends install filebydate, my simplistic picture organizer. This does that, but also covers some larger issues that were so well put in this email I got:

As I sit here building a new machine, I’m thinking of all the little shareware utilities I have and how long it takes to set them up. Last time I built a machine, I spent forever just finding installers for all these buggers. It strikes me there are three problems:

  1. Finding a useful utility
  2. Deploying utilities on any computers you have – not just installing a new utility, but having a list of your favorites and being able to say Set Me Up and it’ll install everything on your list.
  3. Keeping them up to date – I like to have the latest versions, but it takes forever to go to each site and check for an update – especially when several of these apps have plugins. (just getting a slimserver up to date with all its plugins can take a half hour).

‘twould seem like a niche begging to happen…

This email came from my friend Rob, a very computer-savvy guy. These kinds of problems are much worse for a novice user.

The trouble has been, although there are some good single-platform solutions to this kind of problem for open source software on Linux or Mac (which you can see below in the Ruby install steps), there hasn’t been a good, unified cross-platform solution. But working on my little ‘filebydate’ Ruby gem has got me thinking how the Ruby language, libraries, and runtime are getting tantalizingly close.

Even for a novice, it’s easy to install Ruby. Even if you never want to write a line of code, this can be nice, because Ruby includes its own package manager (rubygems) which makes finding and installing useful ad-ons easy. All this is cross-platform — it can work whether you’re using a Windows, Mac, or Linux box. Getting started can be summarized in one or two steps.


  1. One-click install (1.8.5 r21)


  1. Get DarwinPorts
  2. % port install ruby rubygems

Linux (Ubuntu)

  1. % sudo apt-get install ruby irb rdoc rubygems

Try it if you don’t already have Ruby! Once you’ve got this done, installing a ruby library or application on any of these three platforms is as simple as running

% gem install filebydate

on the command line. This command will go up onto the internet, see if this thing called ‘filebydate’ exists, download it, install it, and put any scripts (like ‘renwdate’) in your path so they’re also usable from the command line.

It’s like downloading a typical program installer, except that

  1. The installation process is standardized
  2. Upgrades are as simple as
    % gem update
  3. You can tell what’s previously been installed with a simple
    % gem list
  4. Gems build on each other, and are able to install what’s needed automatically (dependency handling)
  5. When you move to a new computer (even running a different OS), it’s easier to get the same programs re-installed

All this is nice, but it’s obvious that most normal computer users will simply say “you lost me at ‘command line’”. To make Ruby more viable as an OS-independent application platform, there’s a few things we Ruby developers have to do.

  1. Gems should provide a bit more consistency in supporting multiple platforms, or declaring any platform dependencies
  2. Gems should consider adding GUI frontend for any scripts (as I should do for filebydate)
  3. And some ideas for rubygems …
    1. Create a gui frontend for rubygems itself
    2. Add a section in the gemspec for some post-install, platform-specific processing for all supported platforms (e.g. to add shortcuts to start menu on Windows, etc.)

Is Ruby the only game in town? Not by a long shot. There’s ppm for Perl, pypan for Python, any of the Linux package managers, solutions like Macromedia Central (Flash), or any number of others — but most are either not multi-vendor, not multi-platform, or aren’t as well matched to the problem as Ruby and rubygems.

So are Ruby and rubygems ready for prime-time as an OS-independent application platform? Not yet, but they’re usable today and getting closer all the time.

Do you have a better, preferred set of technologies to start solving these problems?

Technorati tags: computers and Internet, software, ruby

Java is back

nullJava has been in a state of slow decline, rightly loosing ground steadily to other language/platform choices. Sun’s decision to release the Java language and VM under the GPL changes everything. Sun has realized that licensing under the GPL will provide maximum future innovation with minimum balkanization, and they’re right.

For more detailed commentary, see David Berlind (ZDNET).

It may take a long time to detect the change in momentum (think how long it took to get from Netscape to Firefox), but … Java is back.

Technorati tags: ,

Simpler photo library management (filebydate)

Looking for a simpler way to manage your digital photo library?

A lot of people we know are burying themselves under a mountain of media files, loosing things.

And the software out there can really get you in trouble — tie you to one vendor or one platform, prevent you from organizing “your way”, hide information from you so you can’t back stuff up properly or use other programs to manage the library, etc.

A few years back I wondered if there wasn’t a simpler way. What I really wanted was to just use the filesystem directly, no fancy photo database or metadata. And then just use the nice, built-in Windows or Mac shell functionality to view the picture folders. But I wanted the files organized, and the date the photo was taken was the one thing that would never change — the primary way I wanted to look for pictures later. Unfortunately, I couldn’t trust the OS or the apps I was using to never touch that file date, and I needed it to be easily seen in all views.

So I wrote a simple little perl script to prepend the last modification date to the image files. “PIC_023812″ becomes “2005-12-04 180624 PIC_023812″ (you can, of course, then rename the PIC… part). We’ve been using it the last 5 years, a few friends have been using it, and that plain & simple solution has stood the test of time and been surprisingly useful.

So now, I’ve finally given it an upgrade to life as a Ruby gem, and gotten it out on a repository. The gem is called filebydate, and the renaming script which will get added to your path on installation is called renwdate.

I’ll post more later once the first release has propogated from rubyforge (once it has, installation will be as simple as ‘gem install filebydate’ for ruby users). Until then, please visit the rubyforge page.

Of course, turning it into a nice gem with complete docs, unit tests, etc. has made it a larger package. Here’s the original perl script, if that’s more to your liking.


Takes a wildcard as input, reads the date on each file, and
prepends that date into the file name (if the filename doesn't already
have a YYYY-MM-DD in it).  The purpose is to allow files (usually image
files) to be tagged with their creation date in the filename itself, so
that the creation date isn't lost when the file is further renamed (beyond
the date characters) or manipulated (such as rotating it or fixing red eye).
The filename is also used by many on-line photo printing services to print
the description of the picture, and this makes sure the date is part of
that string.

Bernie Thompson Jan 2001


use File::Basename;

@files= <$ARGV[0]>;

foreach $oldname (@files)
        if ($oldname =~ m/\d\d\d\d-\d\d-\d\d/) { next; }
	($readtime, $writetime) = (stat($oldname))[8,9];
        ($name, $dir, $ext) = fileparse($oldname,'\..*');
        ($sec, $min, $hour, $day, $month, $year, $junk) = (localtime($writetime));
        $year += 1900; $month += 1;
        $newname = sprintf("%s%04d-%02d-%02d %02d%02d%02d %s%s%s", $dir, $year, $month, $day, $hour, $min, $sec, $name, $ext);
        print "$newname\n";
	rename $oldname, $newname;
	utime($readtime, $writetime, $newname);

I’m hoping we can get a few more utilities created around this simple solution, to cover things like automatic renaming when picture files are imported, etc. And this Ruby gem could be a place to collect them.

Please let me know if you have any feedback or ideas for filebydate.