Programming Languages Need Nouns and Verbs

I created the following Grammar Lesson many years ago:

grammar lesson

Like many people my age, my first programming language was BASIC. Next I learned Pascal, which I found to be extremely expressive. Learning C was difficult, because it required me to be closer to the metal.

computer-memory-2Graduating to C++ made a positive difference. Object-oriented programming affords ways to encapsulate the aspects of the code that are close to the metal, allowing one to ascend to higher levels of abstraction, and express the things that really matter (I realize many programmers would take issue with this – claiming that hardware matters a lot).

Having since learned Java, and then later…JavaScript, I have come to the opinion that the more like natural language I can make my code, the happier I am.

Opinions vary of course, and that’s a good thing. Many programmers don’t like verbosity. Opinions vary on strong vs. weak typed languages. The list goes on. It’s good to have different languages to accommodate differing work styles and technical needs.

But…

if you believe that artificial languages (i.e., programming languages) need to be organic, evolvable, plastic, adaptable, and expressive (like natural language, only precise and resistant to ambiguity and interpretation), what’s the right balance?

Should Programs Look Like Math? 

Should software programs be reduced to elegant, terse, math-like expressions, stripped of all fat and carbohydrates? Many math-happy coders would say yes. Some programmers prefer declarative languages over procedural languages. As you can probably guess, I prefer procedural languages.

Is software math or poetry? Is software machine or language?

I think it could – and should – be all of these.

Screen Shot 2015-01-31 at 6.04.00 PM

Sarah Mei has an opinion. She says that Programming is Not Math.

Programming with Nouns and Verbs

First: let me just make a request of all programmers out there. When you are trying to come up with a name for a function, PLEASE include a verb. Functions DO things. Like any other kind of language, your code will grow in a healthy way within the ecology of human communicators if you make it appropriately expressive.

Don’t believe me? Wait until you’ve lived through several companies and watched a codebase try to survive through three generations of developers. Poorly-communicating software, put into the wrong hands, can set off a pathological chain of events, ending in ultimate demise. Healthy communication keeps marriages and friendships from breaking down. The same is true of software.

Many have pontificated on the subject of software having nouns and verbs. For instance, Matt’s Blog promotes programming with nouns and verbs.

And according to John MacIntyre, “Take your requirements and circle all the nouns, those are your classes. Then underline all the adjectives, those are your properties. Then highlight all your verbs, those are your methods”.

When I read code, I unconsciously look for the verbs and nouns to understand it.

codefragment-thumb-300x268-258

When I can’t identify any nouns or verbs, when I can’t figure out “who” is doing “what” to “whom”, I become cranky, and prone to breaking things around me. Imagine having to read a novel where all the verbs look like nouns and all the nouns look like verbs. It would make you cranky, right?

The human brain is wired for nouns and verbs, and each is processed in a different cortical region.

fig

There are two entities in the universe that use software:

(1) Computers, and (2) Humans.

Computers run software. Human communicate with it.

mammalian-brain-computer-inside

-Jeffrey

Advertisements

7 thoughts on “Programming Languages Need Nouns and Verbs

  1. I am a software engineer who has lived through scenarios you describe, so I do appreciate this post. Many software engineers are writers and vice versa, and there is a good reason for it as the post suggests.

  2. Not sure what you’re take on Ruby is, but I remember being introduced to it through “why the lucky stiff’s poignant ruby” e-book, which I think is still online. He tried breaking it down into parts of speech, which made it sound really neat to use. However, when I started trying to use Ruby, it wasn’t always as intuitive as the claim. Of course, my programming experience is rather slight, to say the least. Still, I like the ideas you bring up.

  3. Nice post, and cartoon. But I think you missed one: adverbs can describe adjectives as well as verbs. Thus, you need one more: Two adverbly adjective nouns verbing adverbly proposition each other.

  4. My memory of you learning C after a Pascal is that you didn’t like how much more terse it was than Pascal, and that it uses symbols in places where Pascal uses words (ie, begin vs }).

    • Robert! Wow – a blast from the past – so cool to see your comment! Gosh, I remember that time so well at the SU Graphics Lab. I was accustomed to Pascal’s BEGIN and END and didn’t like “{” and “}”. Of course, now that I am used to the syntax, it is second nature, and these have since become expressive “words” that I read and write. Now BEGIN and END seem cumbersome :)

  5. The crux of this proposition is to make machine language more in line with human expression than the opposite, which is what it has been from the beginning. Of course coding looked alien; you were telling a machine what to do, If/Then notwithstanding. Human, expressive, even poetic language as the basis of data manipulation is coming very close to the realization of AI; WhenTheMood StrikesYou/ConsiderThePossiblityOf.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s