Programming, Mathematics, and Language

I’ve been struggling for a while now to find a way to frame and articulate the answer to what seems like a simple question: “What is mathematics?”

At the same time, I’ve been seeking to layout the similarities and differences between the concepts listed in the title: Computer programming, mathematics, and natural language.

Recently, I was pointed to an article by Jeremy Kun that was a rebuttal to an article by Sarah Mei. The articles deal with the question of the importance of mathematical savvy for successful programmers. Both articles are worthwhile reads, but I think that Mei lays out her position more convincingly. This may well be because I happen to agree with her more than with Kun.

I have experience with natural language. I am a published fiction writer, I am certified to teach English, I have a Master’s in Linguistics, and I have studied several languages (although I am fluent in none). I have also studied Esperanto and made a few stabs at creating a conlang.

I have experience as a mathematician. I am currently a mathematics teacher, and have a college degree in the subject (which, especially pertinent to this topic, is a BS in “Mathematics and Computer Science”). When I was a teen, my father talked me out of a career as a baseball statistician.

I have experience as a computer programmer. I have been programming perhaps roughly as long as Mei: My first programming language was actually BASIC, but in college, I also took Fortran, as well as COBOL and Pascal. To my knowledge, there was no such thing as “Object-Oriented Programming” in those days; if you wanted to carry a bunch of information around together, you had to name your variables as a set. Since then, I have worked with languages across the gamut of complexity, from strictly script-oriented things like SAS and HTML through the red-headed stepchild of languages, VBA, up to ASP, VC#, PHP, and a bunch of other things. I think I have a decent idea of the range, power, and variation in computer languages.

So, there’s my background, and whatever bias it brings.

The obvious similarity between natural language, mathematical convention, and computer programming is that all involve effective use of a system of communication.

Computer programming and natural language

That’s pretty much the raison d’être of natural language: To communicate thoughts, feelings, and perspectives between people. An effective language user knows denotation and connotation, semantics and pragmatics, and even kinesthetics. A sigh can be a lecture in the right pause. But without the need for people to communicate with each other (or even with themselves), natural language wouldn’t exist.

I have seen some programmers argue that natural languages are inferior to programming languages, which I consider to be an insult and an affront. The basis of this argument is that programming languages are non-ambiguous: There is only one interpretation for a specific line of code. This is to a large extent true: There is only one way in which a computer will interpret a specific line of code, which is a danger in computer programming. Computer systems don’t generally ask, “Wait… did you mean…?” the way that human interlocutors will. This means that computer programmers have to be diligent, and the cause of many a programming bug is the result of a programmer meaning one thing but writing something else.

This is not to say that programmed code has no flexibility. Different code can produce different outcome, and the aesthetics of computer programming is complex. And this commentary addresses merely the codification and translation process itself, not the matters of pseudocode and optimization.

So. The overlap between natural language and computer programming is in the realization that the process of taking ideas and putting them in a meaningful, parseable form.

A difference, in my mind, is that so much of natural language is between the edges. Consider the sentence, “I never said that she stole my money.” Read it seven times, stressing each word once. Seven different meanings. All of that meaning packed up in one string.

In contrast, the meaning of computer programming is entirely denotational. HAL does not lean over and give a bunch of the old wink-wink-nudge-nudge to WALL-E. The art of writing beautiful code is in working within that level of rigor to be effective and yet communicating to other human programmers in a clear way. The computer is indifferent between

for i = 1 to m
  if p(i).t == 5 then p(i).cp = p(i).bp * 0.8
next

and

PaperbackDiscount = 0.80
for aBook = 1 to BookCount
  if Books(aBook).Type == "Paperback" then
  Books(aBook).CurrentPrice = 
  Books(aBook).BasePrice * PaperbackDiscount
next aBook

but humans will generally find the second version clearer to read.

All this said, I think that studying the structure of a natural language will be useful to a computer programmer for a few reasons, the most significant of which may be that it reinforces that different languages are good at different things, and that it shows what communication systems are capable of doing. Ideas, ideas, ideas.

Computer programming and mathematics

Once upon a time, most computer programmers used their programs to solve problems. My first computer programmer, for a high school class, was a mathematics quiz. It randomly generated ten problems, including four multiple choice answers. It recorded the user’s responses and then told them their score. This was indisputably a mathematics task far more than a language task.

The National Research Council has identified five strands of mathematical competence: Conceptual understanding, procedural fluency, strategic competence, adaptive reasoning, and productive disposition (Adding It Up: Helping Children Learn Mathematics, 2001). The communicative aspect of mathematics appears to be part of “strategic competence” and “conceptual understanding”, which I think is undermining its significance.

What most people tend to think of as “mathematics” is mostly in that and in “procedural fluency”: The ability to identify the appropriate algorithm for a particular problem. “Conceptual understanding” is often taken for granted in mathematics education (“of course students will know what division is if we just show them enough examples”; “two means two, what else is there to discuss?”).

The last two strands are often peripheralized or absent entirely from standard public education, reserved for college or even graduate school.

I believe this is a significant portion of Kun’s objection to Mei’s presentation; it is, at any rate, where he starts off. I agree with him that many programmers have this misunderstanding, whether or not it applies to Mei.

There are some clear overlaps between the NRC’s strands and the attributes of a successful computer programmer. A successful programmer has a balance between flexibility of thought and rigorous defense reflected in “adaptive reasoning”; a successful programmer has procedural fluency and strategic competence. Like a mathematician, a successful programmer has to have an understanding of the meaning of the objects of their chosen language (but this is also true of an effective natural language user).

An overlap of concepts, though, is not sufficient to say that one sort of education is necessary for another. Veterinarians and doctors perform similar tasks; I’m sure many vets take and benefit from human medical classes. But a round as an intern in a human hospital is not, to my knowledge, a requisite part of a vet’s training.

Computer programming is a complex task, and becomes more complex with each year that passes. In most professional shops, there are dozens if not hundreds of people touching code. Even in my roles where I was the only one actively programming, I was working on code I’d inherited from others.

So would many computer programmers benefit from mathematics courses, particularly courses taught the way mathematics ought to be taught (that is, consistent with the NRC’s strands, not the pure plug-and-chug algorithmic approach)? Certainly. But not all programmers need that, and for some, it wouldn’t be a value-add at all.

A deeper question, framed by the NRC’s strands and modified by a view of mathematical conventions as being a system fairly akin to computer programming (mathematical conventions ought to have the same lack of ambiguity, although this is more debatable), is whether effective programming and effective mathematics involves substantively the same sort of reasoning and cognition.

I think the way that “core subjects” have diced up the world, that context would say, “Yes.” Personally, I’m not sure. But let’s say it does. If so, what would a computer programmer gain from studying mathematics that they wouldn’t gain from studying computer programming?

I don’t think it’s seriously contentious to claim that a high-level computer programmer at the top of the game is approaching problems with the same sort of cognitive approaches (as the strands say, “ability to formulate” and “capacity for logical thought”) as a mathematical researcher. Looking at entry-level computer programming and high school mathematics, I think it’s just as non-contentious to say those are completely different.

Concluding Remarks

So, then, I think that a serious study of mathematics will be helpful to a computer programmer. I think that a serious study of language will be helpful to a computer programmer. For that matter, I think a serious study of computer programming would be helpful to a natural language speaker and to a mathematician, while mathematicians and natural language speakers benefit from each other. For me, they’re three separate realms that are intimately interconnected. But they’re separate, and none of them inextricably rely on each other.

1 Comment

  1. Pingback: Object-Oriented Geometry | Curious Cheetah

Leave a Comment

Your email address will not be published. Required fields are marked *