When we write computer programs we are telling the computer to do something. It then makes sense, on some level, to understand how computers actually work.

When you want to add two numbers together there are a number of ways to do it. If you want to add one to a number, in C you would write something like “i++”. This translates directly to the assembly language instruction “inc {register}” where register is eax or whatever. This is how computers work.

When you write programs in a FP language you are not allowed to do this or to think like this. You are intended to think in a type of abstraction where the answer is not stored as a variable. In other words, you are living in some sort of fantasy abstraction where, despite the computer giving you the exact same answer, it is not actually doing so. Observe:

ghci> succ 5

6

What just happened? Technically, “i++”. This is what the computer is actually doing. But you are living in a fantasy world — a complete construct — in which this did not happen. Now here’s the problem. Here’s where the retardation happens. Because the language itself relies on the fantasy world being real, it has to escape the fact of what actually happens in machine language in surprisingly obtuse ways.

This is the first level of retardation. You define a function, add(x, y) to return the value x + y.

So that every time you want to add x + y, you don’t simply type x + y. You type add(x,y) (or add x y).

Do you see what just happened there? You’ve not only introduced a function call, you’ve introduced at least a stack push and pop for variables and results.

Why?

Because you’re making the computer think like a human instead of bothering to understand how the computer actually works.

And the absolute best thing that you can say about such a mockery is that it is pointless, because writing “add x y ” or “x + y” does the exact same thing, and it is the compiler who decides how to implement it. At this level, functional programming is simply people living in a dream world and the computer doing things in an un-natural way for no particular reason.

Retardation Level 2

In “So you want to be a functional programmer” part 2, we are introduced to this:

and by the end of the section we get the following quote (which FP is intended to “solve”): “If only we could pass a function as a parameter…”

What the actual firetruck? You just did. What is the difference between func(regex, phone num) and regex.(phone num)? Ruby made it’s life out of examples of the first kind.

Why FP is Considered Harmful

FP in general is considered harmful because it overabstracts arbitrary machine code into functions, based on arbitrary rules that have no basis in the physical reality of how a computer operates. Based entirely on theories such as, we are too stupid to keep track of named variables or even registers (I assure you, the computer has no such trouble). Thus needlessly adding complexity. Basically, for every function such that func x = operation x, func x simply becomes a macro for operation x. There is never any reason not to just write an imperative language via operation x. And whatever you gain via lazy execution you will lose vs speed even if only because the compiler is forced to do a check for existence on every variable, and the more minute the variable the heavier the check becomes, especially for large loops (like rightTriangles in learnyouhaskell).

In the end you get harmed because your code runs slower than it has to, and you didn’t learn anything about how the machine works. All you learned was some abstraction somebody made up with no connection to the physical reality. By slower I mean a thousand times slower and worse. We’re not talking a little bit. It’s never acceptable to be a thousand times or more less efficient than C code. When this happens it means you are a bad programmer, either because you cannot, or will not (have chosen not to be able to) write effective code.

FP has become something of a social virus. No one actually uses it for anything real but a small number of people are obsesses with it (like LISP) despite it simply being bad, not the right way to do things, they drink the koolaid and start making friends within the FP community and shunning outsiders as a way of self-validation. The worst of these cults can take generations to die out.

By Serena

Leave a Reply

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