January 3, 2011
I had a very difficult time in my English classes. In fact, there was a period where I simply refused to attempt any writing assignments due to the stress I caused myself. This was the primary reason for many failed classes in high school. Thankfully, I managed to graduate and go on to do much better in college.
It was during 2005 I began programming and a surprising result has been a better appreciation in how the English language is defined and used. Like human languages, programming languages can be broken down into similar constructs of nouns, adjectives, verbs, etc. It's not something I've looked into (someday I will), but I find that common devices in modern programming languages can be compared to simplified examples in human languages.
So yesterday, Elizabeth and I were discussing using the phrase "that that" in a sentence and how awkward it sounds in conversation, even though it's grammatically valid. When writing, I normally try to substitute "which" for the latter "that" (I'm usually not deft enough to do the same in conversation). The unintended side effect though, is the substitution can end up making the sentence read a little too formal and out of character. Most people I know, including myself, rarely use the phrase "that which" in conversation. Not that I judge a good writer by how well their writing mimics conversation, but formalities can interrupt and/or ruin otherwise good prose.
Interested in how this phase functions in a sentence, I looked up the definition of "that". I learned the first instance of "that" serves as a pronoun, while the second as a conjunction.
Take for instance this conversation:
Speaker One:
Why are you are always disrespectful towards me?
Speaker Two:
I'm not. You're just not smart enough to know when I'm right.
Speaker One:
See? It is that, that I'm talking about.
The first that, the noun, is referring to Speaker Two's answer of I'm not. You're just not smart enough to know when I'm right..
The second that, the conjunction, acts as the clause connector, connecting It is that with I'm talking about.
To help me remember how these constructs work I like to try and relate them to something in the world of programming. It usually helps regardless of if I can find any similarities.
Here what the conversation would look like as a hypothetical javascript program:
/*
================================
= Define our variables upfront =
================================
*/
var pronoun = null;
var conjunction = "that";
var speak = function( message ) {
alert( message );
};
/* speakers */
var Ryan = {
role: "Speaker One",
speak: speak
};
var Chris = {
role: "Speaker Two",
speak: speak
};
/*
==========================
= Begin the conversation =
==========================
*/
/* Ryan defines and speaks his question */
Ryan.question = "Why are you are always disrespectful towards me?";
Ryan.speak( Ryan.question );
/* Chris defines and speaks his answer */
Chris.answer = "I'm not. You're just not smart enough to know when I'm right.";
Chris.speak( Chris.answer );
/* Redefine the pronoun to refer to Chris's answer */
pronoun = Chris.answer;
/* Now Ryan defines and speaks his response */
Ryan.response = "It's" + pronoun + conjunction + "I'm talking about.";
Ryan.speak( Ryan.response );
To take this comparison even farther, you could find parallels for nouns, adjectives and verbs in the above program.
Nouns
Each speaker is "typed" as an Object
. Not as in "typed on a keyboard", but as in the speaker's value is of the Object
type. In English, each speaker would be typed as a noun.
Adjectives
A word that describes or modifies a noun is considered an adjective. Similarly, the properties and methods (referred to as members) of an Object
can describe and modify that Object
. Our speakers each have a role
property to describe the part they play in the conversation.
Verbs
A verb describes an action or occurrence and in the beginning of the above program, the function named speak
does just that. Instead of running speak
on as a standalone (via speak()
), I decided to create a speak
member in each speaker and use the standalone speak
function as its value. This effectively creates a method (used as Ryan.speak()
). Now, each speaker can have its own voice.
The speak
function takes one argument, message
, which is the value passed into the parenthesis used to execute the function. The function simply calls alert
, which creates a little browser notification dialog.
While I didn't set out to write a introductory to programming, It's nice to finally write down the way I think about these things. At least I can point to it when my friends want some sort basic understanding of programming, which is never, of course.