Archive for October, 2010

Ruby: A non-programmer’s foray into a programming language.

In high school, English was my thing. (What does this have to do with Ruby? I’m getting there.) I loved picking up a pen and chasing down words to discuss novels or detail moments or to wax poetic about the political structure of  Rome. Have you ever watched someone make pottery on a wheel? Their fingers sliding over wet clay, pressing in slightly and urging a shape where moments before there was only a glob. All the while, their feet work steadily, finding the right rhythm to keep everything moving. Sometimes, their lips move just a little, as though they were whispering to the clay the way one might whisper to a lover or share secrets with a friend- they seem to coax out beauty and share instructions with the clay, until it bends softly and forms the way they want it to. I was never any good at the pottery wheel, but  what I witnessed as other people worked was how I felt when I wrote in English class. I could grope around whisper to an idea and then keep my hands and pen moving rhythmically along until some essay appeared, fully formed on my page. It was was natural.

Then I started taking Spanish. Spanish did not come naturally to me at all. I remember this blind feeling of knowing what I wanted to say, but needing to look up not only the words, but the tense and the grammar and the punctuation. I’d get little phrases slightly off, I’d forget an accent mark or make a masculine verb feminine and then the whole sentence sounded wrong.  My teacher would carefully correct them, handing back a red stained piece of paper for me to go over again. I’d pull out the dictionary and go over each word, waiting for the moment when the words could flow effortlessly out of me and be magically correct on their own. When a phrase or sentence would “sound wrong” to me the way English does when there is a misused word.

Now, I am trying to learn to program. As I slog through lines of ruby, I get that same feeling I had in Spanish class. Learning to program is, of course, a foreign language. But it is also a language with a different set of rules.    I am not just trying to turn my english verbs and nouns into Spanish ones, I am trying to learn the very structure and sound of verbs that computers understand. Flowing descriptive sentences are chopped and spliced- removed of ambiguity and flourish and left as a series of commands strung together with a punctuation that is not dictated by the pauses and breaths of human speech. Again and again, my rake commands are greeted with lines of red errors detailing my every mistake. I grab a book and settle in, going over the code word by word one line at a time, and feel somehow super human (if only for a moment) when I clear an error. Then, when I get stuck, I show someone who actually knows what they are doing, and my super-human feeling completely vanishes as I watch them lay their fingers gently on the keyboard. They see instantly what “sounds wrong” and know exactly where to place the punctuation, when adjust a word or a space and how to clear out the red errors. And in the middle of it, some times I see their lips moving just slightly, coaxing the code to bend in just the right way.

I have a long way to go and a lot to learn. But with each error I start to recognize and each problem I figure out, I catch just a glimpse of that rhythm. One day when it, too, is natural, perhaps I will argue in praise of the art of  Ruby’s simplicity, its ease. For now, I fumble in the dark, waiting for the moment I can intuitively “hear” or feel how it is supposed to be and perhaps, even to whisper words of encouragement as the code takes shape.