On Thinking Programmatically

Just yesterday, a student asked me which programming languages I knew.

The class was about exercises in MS-Excel, and for the record, I’m most at ease working in MS-Excel. I learnt C when I was in undergrad (and haven’t touched it since). I had to learn SAS because I worked in analytics for a while, and I know my way around (but am nowhere close to being an expert in) R. Finally, I’m somewhat comfortable with Python, but again, not exactly an expert.

But as I told my student yesterday, I think the trick lies in learning how to think programmatically. Once you get the hang of it, learning any language becomes that much simpler. A favorite question of mine when I interview candidates is this one: tell me how you will go about writing code to identify the first 100 prime numbers. I’m not very interested in which language you write the code in, and I am perfectly fine with the English language itself being used. I’m just interested in seeing whether the candidate can think programmatically. Fizzbuzz type question, essentially.

But forget fizzbuzz, and forget the first 100 primes.

Write a program to make a PB&J sandwich?

I got to this tweet via this one, and it is a great example of thinking programmatically too!

And the full video is here:

Fun though all of this was, don’t miss out on the larger point I want to make here: learn the art of thinking programmatically.1

And if I may be permitted to end with a quote from my favorite book:

“What I wanted to say,” I finally get in, “is that I’ve a set of instructions at home which open up great realms for the improvement of technical writing. They begin, ‘Assembly of Japanese bicycle require great peace of mind.’”

Pirsig, Robert M.. Zen and the Art of Motorcycle Maintenance (pp. 145-146). HarperCollins e-books. Kindle Edition.

  1. I’m a bit of a hypocrite for saying so, because I honestly don’t think I’m very good at it myself[]

Leave a Reply