Friday, November 15, 2013

Words == Power?

A couple weeks ago, I learned how to draw a line.
To be more specific, I'm taking an online programming class. In addition to NaNoWriMo. And a couple weeks ago, I learned how to write a line of programming code that displayed a line on an otherwise. That was fun.
This week’s project? Well, the class has gotten a little more complicated over the past couple of weeks. Instead of typing out simple lines like canvas.draw_circle(…), we’re getting to create trees of if/elif statements and “for loops.”
Sounds like fun, right?
The problem is, programming means getting the right words into the right place. Most writers can get by without being very specific. We can talk about “a dog,” if we want, and not bother about German Shepherds unless we’re dog-fans. But in programming, if it’s a German Shepherd, you have to say it’s a German Shepherd. Otherwise, you get a blank stare. If it’s a circle you want, you have to say “circle,” not “a round-shaped” object. No "round shaped" tires here, please!

Then there’s the matter of getting the words in the right place.
I spent about twice as long as I should have on this week’s project (creating the card game Memory, complete with code to “turn” cards over and match the pairs of cards as a player finds them). One of my problems was making sure that all of the code had the proper indentation. 
You see, when a program runs, it runs straight down the code. But, if there is an “if” clause, the program has to detour and check out all the code under the “if”, before it can go back to the rest of the program. And the way it knows whether something is part of the “if” clause is based on how much the code is indented. Once the indentation ends, the program assumes things can go on as they were before. (And you thought indenting only mattered in English 101.)
Then there was that problem with trying to talk about that German Shepherd before the program knew what a German Shepherd was. My challenge was that the line of code I needed would send everything into a downward "for loop" if I wasn't careful, but I thought was inescapable, since I could only talk about my German Shepherd once I introduced him to the program—in the "for loop".
Eventually, with some help, I found that I didn’t have to talk about the German Shepherd at all in that case—I could talk about a Poodle instead, since the Poodle had the same value as the German Shepherd, at least as far as telling the program what I meant. Makes sense, right? 
That’s about as intuitive as using a cookbook to find books in the library instead of the library catalogue.

And then, I can make things fancy, by inserting images:

Now, when I see flashing electronic signs or cash registers, I can’t help thinking about all the if/elifs and "for loops" that went into making that piece of machinery function correctly.
And yes, words are very powerful. If I create a line on a blank canvas, and then change one small word, I can change the color of the line from “Red” to “White.” Pictures, on computers at least, really are made up of a thousand words (more or less). Change one, change the picture.
Just think what words can change in a story or a conversation.

No comments:

Post a Comment