?

Log in

No account? Create an account
Rake - Yarrow [entries|archive|friends|userinfo]
Yarrow

[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Rake [Nov. 28th, 2008|10:25 pm]
Yarrow
[Tags|]

I've been doing more and more with Ruby, mostly Ruby on Rails. The current project, though, is a non-Rails application that needs to cooperate with PHP code -- the PHP code will send requests to update files to a Ruby daemon that will fetch them from other web servers.

We'd originally intended to use home-grown communication using Unix signals, but that turns out to freeze if too many signals come in too fast. So I'm going with beanstalkd, an in-memory queuing system that was originally written for Ruby but can communicate with many different languages.

That means installing beanstalkd, libevent (which beanstalkd needs), and the PHP and Ruby communications libraries; not a tremendously big deal, but big enough that we'd usually put the build instructions in a Makefile so we don't forget a crucial step if we have to re-install in a hurry.

But Ruby has its own version of the make program, called rake -- typical programmer-ese for "Ruby make". (The Java competitor to make, on the other hand, is called not jake but ant -- go figure.)

So this time instead of writing a Makefile I wrote a Rakefile. The nice thing about rake it's just an extension of Ruby, so you've got all the power of Ruby available in the Rakefile. In particular, you can create subroutines. Modern GNU make has that ability too, but it's bolted on to a program that like its contemporary sendmail was an amazing, incredibly useful invention with an incredibly ugly user interface. Bolting make's capabilites on to Ruby is much more elegant -- elegant enough that it doesn't feel bolted on. Ruby is a language that's particularly suited to being extended for specialized purposes -- Ruby on Rails is an extension of Ruby for building database-backed web applications, rspec is a Ruby extension for writing automated tests, rake is an extension for automated builds, and so forth.

So it took me about a day to write the Rakefile, learning rake in the process; but I don't think I'll be going back to make for new projects.

Offering:
Into the water,
Cold or warm,
Into the water,
Into the sea,
To drown, to swim, to breathe beneath the wave.
Into the water,
Into the sea.
linkReply