Monday, July 7, 2008

Holy Ruby Deliciousness!

So I am mucking about with Ruby, Rails, Groovy, Grails, and whatnot. I find them all pretty incredible and the more I use scripting languages, the more I decide that unless you really NEED a precompiled piece of code, this is the only way to fly. I just took results from a database and did some string replaces and wrote a new file in Ruby. It went a little like this:

file ="/awesomedirectory/mylist.TXT", "r")
out_file ="/awesomedirectory/mylist-formatted.TXT","w")
while (line = file.gets)
newline = line.gsub(/ /, '')
out_file.puts( newline )

Now that is silly easy. Anyone who has used Java IO knows it's cumbersome and kinda annoying - not hard - but definitely kinda annoying. This is sweet. I am going to do more with this. When you spend 7-10 hrs a day programming, even a 10% increase in productivity that can be gained from the faster feedback loop and the terseness of the scripting syntax can really add up, and let's face it, much of what we do doesn't REALLY need to be precompiled code - it's okay if it compiles on the fly!