# Talking to computers

Suppose I described to you the following procedure (let’s call this statement 1):

Keep adding more numbers to the sequence,
always by summing the last two numbers.

If you started following this procedure, you’d gradually get a longer and longer sequence:

1 + 1 →2
1    1 + 2 →3
1    1    2 + 3 →5
1    1    2    3 + 5 →8

You might recognize this as the procedure for creating the sequence of Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13 … a sequence that is very useful because it describes all kinds of things in nature, such as the way populations grow, the spiraling pattern on a sunflower, and the shapes of seashells and galaxies, to mention just a few.

If I just want the nth Fibonacci number, I might say things slightly differently (let’s call this statement 2):

If n is 1 or less, the answer is 1.

Otherwise,
add the (n-1)th and (n-2)th Fibonacci numbers.

I’m guessing that everyone reading this post will be able to understand the above statement just fine, after looking at it for a few moments.

Here is how I might convey the above statement to a computer (let’s call this statement 3):

fibonacci(n):
if n ≤ 1 then
1
else
fibonacci(n-1) + fibonacci(n-2)

Statement 3 – the one that looks like a computer program – is exactly the same as statement 2, except that writing it as a program makes it a little easier for a computer to read.

So here’s my question: Assuming we would like to put the power of programming into the hands of everybody (the way we already try to put the power of written language into everybody’s hands), would it be worthwhile to get millions of people to learn things like statement 3 – the one that looks like programming?

Or should we get both people and computers to understand statement 2 – ie: the same statement, except written out in English? Or should we work really really hard and try to figure out how to get computers to understand statement 1 – the one at the very top of this post?

Unfortunately, if you opt for choosing statement 1, you might have to wait a very long time. That kind of casual natural language description is fairly beyond what people have been able to get computers to understand. The reason is that even simple statements like “summing the last two numbers” tend to stump a computer. An inference that would seem immediately obvious to us humans, like the fact that we are referring to the last two numbers in the sequence, is incredibly difficult for a computer to work out. Computers lack our ability to figure things out from context.

I find myself wondering whether the big leap for most people would be going from statement 1 to statement 2, or going from statement 2 to statement 3. Whereas statement 1 just kind of assumes you can fill in the parts that are unsaid, statement 2 really spells things out in a way even a computer could understand. And that’s the leap that might be hard for people.

I suspect that the real hurdle might not be teaching people to read things that look like computer programming, but rather teaching people to think in a way that makes it possible to program – the kind of step-by-step way of thinking about a problem that makes it possible to get a computer to do our bidding.

## 4 thoughts on “Talking to computers”

1. Jon says:

Its interesting that you write: “If n is 1 or less, the answer is 1”. I suspect my own first draft would have been like this:

if n is 1 the answer is 1, otherwise, add the (n-1)th and (n-2)th Fibonacci numbers.

Lets call this statement 1.1. It seems fairly close. Then by experimenting with examples in my mind or trying it on a computer I’d realize this works for all cases except for n=2. So I might be tempted to write statement 1.2:

if n is 1 the answer is 1, if n is 2 the answer is 2, otherwise, add the (n-1)th and (n-2)th Fibonacci numbers.

Getting from 1.2 to your statement 2 isn’t hard but it takes a little insight and a desire to see things compressed to their most minimal form… why use two “if” statements if one will do? This kind of elegance/compression is effortless for a mathematician, but for many people, as you suspect, I think the hurdle is getting from 1.1 to 1.2 – from a first draft incorrect approximation to a correct if inelegant solution.

Good point Jon!

Interestingly, I was actually thinking of statements 2 and 3 as implicitly describing the “starting” cases fibonacci(0) = 1 and fibonacci(1) = 1.

But I was wrong. The actual Fibonacci sequence starts with zero (ie: 0, 1, 1, 2, 3, 5, …).

Putting this together with your insight, we could write it like this:

if n ≤ 1 then
n
else
fibonacci(n-1) + fibonacci(n-2)

3. Marc says:

“I suspect that the real hurdle might not be teaching people to read things that look like computer programming, but rather teaching people to think in a way that makes it possible to program – the kind of step-by-step way of thinking about a problem that makes it possible to get a computer to do our bidding.”

Well, that sounds quite obvious after that argument, and note that people also have to learn to think Mathematically, and that’s pretty much a given, so why not programming?