Showing posts with label rio ruby io. Show all posts
Showing posts with label rio ruby io. Show all posts

Monday, July 30, 2007

Why Rio?

Ever set out to write a simple little program only to find that hours or days later you have spent most of your time dealing with code that has nothing to do with the problem you were trying to solve? Ever get to that point and not even remember what you were trying to do in the first place? Ever find yourself mumbling obscenities about people who don't write documentation for their code even though you don't write documentation for your own?


The first time I saw Ruby I was in awe of her beauty -- and she was so smart! It was as if she could read my mind. I would write:

3.times { print "Hello Ruby" }

and she would print "Hello Ruby" 3 times.

She really understood me.

I had dated her older cousin Perl for several years. While Perl was resourceful, she was not much to look at. And while she tried so hard to understand things like objects, it always seemed like she was faking it. She pretended to understand them only because she knew that was what I wanted. She never really got it.

Being so enamored of Ruby I wanted to take her out in public. I was stunned to find that when I tried to have her do common tasks, like dealing with files, directories and streams, she was as clumsy as her cousin. Sometimes she acted like an object and other times she made me treat her like a function. Her I/O interface was spread across File, Dir, IO, and Pathname. Sometimes available through instance methods and other times using class methods. In many ways she reminded me of her grandfather, C. I was getting confused.

I thought the problem must be with me and decided to seek more documentation. The only thing I could find was
Why's Poignant Guide... now I was really confused.

I decided I must find a way to help Ruby be as beautiful when dealing with the public as she was with me in private; to make her Input/Output operations so simple that they would be an afterthought; so that I and others could concentrate on the problem we were trying to solve rather than mundane things like I/O. I also decided to document my work well -- with lots of examples.

I remembered a pretty dress I saw Perl wear once called IO::All. Using that as a starting point, I tried to design a gown that, when adorning Ruby's natural beauty, would make common I/O operations as simple and painless as they should be.