This is in reply to Why Why Functional Programming Matters Matters by Reg Braithwaite and is a more in depth discussion of what I think is right and wrong about his measure of programming language power which I started over on Reddit.
Rather than try to address the side issues to do with C++ and his example all here I want to address his central thesis in a bit of depth and relegate the other issues to another page.
Reg Braithwaite makes an excellent argument about the importance of how well a given programming language supports us in our ability to factor our code. Factor here is used in a sense close to its mathematical meaning to do with the de-composition of numbers. For a language to be programmer friendly it must allow us to craft and re-craft our solutions into a form that is not only correct but stays that way whilst we chase our notions of elegance and improve the efficiency of the code.
To equate this ability of a language with its power I think is close to what our normal notion of power is in a language, but I don't think it quite hits the nail on the head. The reason is that to get to the stage where we can feel this aspect of the power of a language we must have been able to express our solution in it. I think that the notion of the power of a language comes earlier in our programming effort — it's about the ability of the language to allow us to express our idea in the form that we've thought of it no matter what form that is.
In other words, Reg wishes to measure the power of a language by how much transformation can be done to a program written in the language where I would wish to measure the power by how few transformations I need to do in order to express my idea in the language.
One of the things that I often come to is that programming is situational in both the sense that the code must work in a given situation but also in the sense that our thinking and solutions are driven by the context and situation that we as developers find ourselves in. This exposes a second, and I think deeper problem with Reg's metric.
If we take program transformation as the basis of our metric—how much we can factor our solution—then we find that our measure of language power is driven largely by syntax analysis. This feels wrong for two reasons.
The first is that although language syntax is important to our ideas of language power we also know that we must include the libraries in there too. The second reason is that we know that how powerful a language feels depend on the problem that we're tackling and how we propose to solve it. This second is the most important.
The reason why we all learn so many different languages isn't because we recognise the one true most powerful language and then use others to torture ourselves. It isn't because of what we can do once we've got a working program, but because different languages meet us in different places when we're trying to get the program working in the first place.
SQL is a powerful language for a certain class of problem and Java is a powerful language for another class of problem. To try to decide which is the most powerful is a mug's game though. There isn't a single measure that we can use because the power depends on too many factors external to the language.
Try calling a colleague on the telephone and explaining what we want as succinctly as possible. Do you say “We want a loop inside a loop and inside of that an if, and…”? Or do you say “We want to count the number of employees that have been with the company longer than their departments have existed.”
Reg proposes a test for the power of a language, how easy is it to describe our solution in that language. Of course this metric has nothing to do with how much a solution can be factored once we've written it, but everything to do with how well the language supports our proposed solution in the first place.
Which language we choose to employ to solve a particular problem depends on the strategy we have decided upon and this is why different languages feel to be the most powerful in different situations. In one language the libraries and language combine into a powerhouse that has already done the heavy lifting involved in getting our solution working. What heavy lifting features we need depends on the problem, our proposed solution and no less critically also on our abilities as developers.
Given all of this, why does Reg's measure resonate so strongly with developers? The reason is that a language allows us to express our ideas in the form that we think of them because it has the ability to factor solutions. The two notions of the language's power are very closely related and in a way are measuring the same thing from different directions.
Reg's test is a good one, but it doesn't directly measure the thing that he proposes as the metric for a power of a language. It is though the important test because until we can express our idea in a language we have nothing but an idea. It doesn't yet matter what we can do with the program because that program doesn't yet exist.