Programming, mathematics and 1984

I’ve been spending quite a lot of time in the last few days coding some web applications in the programming language PHP. While writing libraries of reusable code, I realised that some of the design issues have interesting parallels both to the expression of mathematics, and the linguistic aspects of Orwell’s classic novel 1984.

First, for newcomers, some software engineering jargon: classes are collections of code and associated data that are written to behave as coherent objects, which are then”plugged in” to other parts of programs, or indeed each other, to create entire programs. For example, a simple text entry box is an object, that stores whatever is typed in it, along with code to describe how to handle keyboard activity within the box, how to draw the box on the screen, and so on.

Closely related are interfaces, and the subject of abstraction. The idea is that the details of code or data handling are “abstracted” away from the rest of the program, behind carefully-designed interfaces, which describe a very curtailed set of operations which can be performed on the data, and which come with lots of internal error and consistency checking.

Now, to business: the ideal case of good library and class design is to design the interface in such a way that eventual users of the library can accomplish whatever they want to, but nothing that they don’t want to. So in order to use your library, the user should not need to learn an arcane set of commands, which must be used in a particular way or order; rather, it should be obvious what needs to be done to accomplish any particular task, and very hard to write anything that would “break” the library, or give strange side effects.

All of which leads to the overlap with mathematics and 1984: the tension between complexity in the definition of a “language”, versus complecity in the use of that “language”, where “language” includes programming interfaces, and mathematical notation.

There are two approaches to mathematics: the first uses very carefully-designed definitions of concepts and notation, with subtle conditions. This makes the proof of theorems an almost trivial process, because they often follow directly from the definitions. The second uses simple definitions, but then results in very complex proofs. Opinion is divided on the best approach, but the growth of approaches to put mathematics on a simple axiomatic foundation seem to be favouring the former.

Then in Orwell’s 1984, the ruling totalitarian regime is introducing Newspeak, a language with steadily decreasing vocabularly. The language is being carefully designed so that it is impossible to express any subversive concepts. This will supposedly make it impossible for anyone to think about, or perform, rebellion. This is a use of the notion that the scope of thought is determined by what grammatical tools are available to express it; this idea is apparently called the Sapir-Whorf hypothesis, after two linguists, and seems to have some empirical support for weak interpretations thereof (particularly in areas like colour recognition and differentiation), but not for the full hypothesis.

In all three of these cases, how a language is defined affects how it can be used, and vice-versa. Sometimes, however, it is considered desirable to carefully engineer the definitions, in order to give carefully constrained and simple resulting usage; whereas in other cases the last thing we want is a carefully constrained usage.

There’s no real take-home message from this analogy; I just find it interesting how entirely different areas of human endeavour can give rise to the same sorts of trade-offs, but with different ideal outcomes.

Anyway, back to designing those interaces…

2 thoughts on “Programming, mathematics and 1984

  1. Surely you can take this a step further and tell us which programming languages are proles, which are in the inner party, and which one is Winston (that is, a programming language that initially tried to break free of too many constraints but ultimately embraced them).

    I think Java is in the inner party. C is a prole language and possibly subversive, but harmless when used by the masses.

    Like

Comments are closed.