Wednesday, July 16, 2014

mathematics and programming

I wrote in my main blog about the collision between Mathematics and Programming: More recently my corner of the twitterverse has gone mad on the subject of whether programming is mathematics.

Also recently, John Baez made a relevant comment on google+ (in a thread about learning R: Since we can't link to google+ comments, here it is:
I find that writing math papers, teaching, and explaining things online makes me as clear as I want to be.  Programming goes further, into making me clearer than I want to be.  I don't really want to explain something to a complete idiot who goes berserk and throws a temper tantrum whenever I make a simple typo.  :-)
 But Voevodsky would say that Mathematics has got too hard, and we need to explain it to a computerized idiot to avoid significant mistakes:

The problem with serious software development isn't typos, it is the huge amount of stuff you have to know to get it done. Jonathan Edwards wrote recently (
The way things are today if you want to be a programmer you had best be someone like me on the autism spectrum who has spent their entire life mastering vast realms of arcane knowledge — and enjoys it. Normal humans are effectively excluded from developing software.
Only a small part of that arcane knowledge is really the programming language. Most of it is in the libraries the programmer needs to use. In most cases the libraries give access to some aspect of the runtime environment. For example you can't use Google's App Engine libraries without a good understanding of the environment they operate in. And sadly it is often hard to use the bits that you want to use without understanding aspects of the environment that are not directly relevant but influence the structure of the library and the meaning of parameters.

It is mostly the availability of libraries that determine what language we choose to work in. For App Engine one is almost constrained to work in Python or Java, maybe Scala or Go. Clojure runs in the Java environment (JVM) and has a clojure style library for App Engine, but that library isn't kept very current. One could conceivably use Haskell by using the Haskell-to-Javascript compiler and running the javascript on the JVM using Rhino. Even if this worked (unlikely) one would find that there is no idiomatic Haskell way to access App Engine and one would have to write lots of horrible syntax to access the Java libraries from javascript, and use the mechanism for calling javascript routines from Haskell. Similarly we see that people doing statistics use R, because it has the libraries and builtin functionality required.

Increasingly everyone in the world will need to do bits of programming at times. That's why we have spreadsheets and statistical packages. R is more than that, but many would say it is too flexible and idiosyncratic for developing large programs safely. We have, in recent memory, seen an Economics paper that was very widely reported, that was subsequently shot down because it had a bug in an Excel spreadsheet.

What we need is for computers to understand a lot more about what we are trying to do, so they can help us more. On the one hand this means that programs should look more like specifications and tests. And researchers are working on this. The other thing is that programming environments just need to have good general knowledge.

And, as it happens, Stephen Wolfram is working on this. For example here is a list of file formats that the new (Mathematica-based) language supports in various ways: [It doesn't seem too much to ask that an interactive environment be able to guess the format of a file and offer you code to access it.]

Mathematics is about thinking clearly, so we expect that good support for it will be the most important thing in facilitating correct programming. The Wolfram Language knows a lot about Mathematics, as we expect from its Mathematica background, but I don't think it is in the best form to be useful. Maybe I just don't understand it yet.

1 comment:

  1. This post illustrates the fact that you shouldn't write when sleep-deprived. It fails to disentangle various threads, and fails to get to a point at all. Perhaps this illustrates the fact that sleep is when we reorganise our mind.