Functional programming is not about lack of side effects. Functional programming is about manipulating code (really, computations/functions/algorithms) instead of, or at least as much as, data. Lack of side effects in functions makes it easier to think about them, but that’s all. Here’s a good example of what thinking functionally looks like.

For a much worse example, here is a quick and brain-dead version of “apply” I just wrote that allows you to do things like


dataparser = [ stripped, split(','), (str, int, capitalized) ]
for line in datafile:
    print apply(dataparser, line)

The important lines are the last three; once you have your basic functions (and leaving aside questions of arity, debugging, types, and such), you shouldn’t need to write scaffolding code in order to compose them in simple ways. In this example, the dataparser = [ stripped, split(','), (str, int, capitalized) ] line simply says “this is the function that applies stripped, then split(‘,’), and then str, int, and capitalized to each of the three elements of the result tuple.” There’s a large number of simple scripts that use this sort of process a lot, and I feel that even if it’s not really that much of an issue to explicitly define the composed function, it compounds over a large number of tasks, and subtly discourages reuse of components and strategies and, most importantly, makes it subtly harder to work over the process.

[Very simple abstract setup, describing an ensemble of physical systems through a probability distribution over phase space, and dynamics by a differential equation.] Then, the well-known Liouville equation describes the dynamics of this distribution. For this type of evolution the Kullback-Leibler information measure provides a convenient way to measure the distance between two distinct probability distributions P1 and P2 because, remarkably, it is invariant under dynamical changes prescribed by the Liouville equation.

I’m not a physicist, but I feel compelled to annotate that — in the style of chess games — with a (!) (although I don’t think this is really a physics result). The Kullback-Leibler is a well-known (if not the) information distance between distributions, but I had no idea that it was preserved by such a wide range of dynamic systems.

Classical No-Cloning Theorem

Quoth the master:

As I have now said many times and written in many places: program testing can be quite effective for showing the presence of bugs, but is hopelessly inadequate for showing their absence.

— Dijkstra, A Discipline of Programming

This is much less powerful than it should be when taken out of context. Clearly, test suites no more “prove” that a program is valid than a predicate is “proved” by manually checking a few cases. Test suites are actually an improvement over customary practices, but only because customary practices are abysmally primitive. I’m not talking about pre-Internet primitive. I’m talking about pre-Russell, not to say pre-Descartes primitive.

Dijkstra’s writings are still among the most clear and solid examples of reasoning I’ve read, let alone reasoning about computer programming, and the fact that one can make a living as a “programmer” without thinking formally about anything ever, is as damning an indictment of the industry as I can imagine.

Not a very new one, but (as most of what Baez writes), quite interesting. The most enlightening bit for me:

Many of the puzzling features of quantum theory come from the noncartesianness of the usual tensor product in Hilb.

Physics, Topology, Logic and Computation: A Rosetta Stone