You are viewing a read-only archive of the Blogs.Harvard network. Learn more.

Small is small despite all we do and say

info = Hash.new {|h, k| h[k] = [] }
Find.find(*paths) { |f| info[File.size(f)] lessthan lessthan f }

What is it I am facing?

Almost a year ago, I was comfronted with a similar situation. Some code I could not understand in Objective C. Only I dropped Objective C, while eventually I get it with Ruby. It helps that Ruby is so easy to run, so easy to print things out to see what is happening, or run irb. And it helps that folks are writing about Ruby:

For the top line, I found
http://www.oreillynet.com/ruby/blog/2006/04/nubygems_hash_initialization_1.html
which explains hash initialization.

for the second line, I realized that lessthan lessthan was a string method, not a hash method. And on an inspiration, I figured out how to use ri:
ri String#length
becomes
ri String#\lessthan\lessthan
I am brilliant.

I don’t think I am facing Ruby. I think I am facing whatever shortcuts folks have been using. And I don’t know those short cuts, and those short cuts are hard to read. There are whole books written on a type of short-cut called regexp. I have used them. They work. You can write very powerful code which looks very snazy, one liners even. But they are difficult to read.

I think these brilliant short cuts probably have a long history. Maybe I am facing Human’s synthetic mind. The mind that invented writing. But I suspect I am also facing men’s minds. The competitive mind. The mind that enjoys looking down on the uninitiated. Whatever it is, I think it is worth my time finding a long-hand way which is easier to understand. It is not enough to get a ruby book. It is not enough to understand the code. At the end of the day, I need to take one more step, the imagine I want others to understand this easily ruby way.

Comments are closed.

Log in