Thursday, January 29, 2015

Of Walking and Halking

Stand up and take a few steps worth of a walk. Then by all means, resume reading this article!

So, your short walk was easy, right? Of course, you can walk unless you are one of the few unfortunate ones who cannot walk due to accidents or disease. You were walking now for nearly all of your life.

Imagine, now some people come up with a theory of walking. Walking without a profound mathematical theory behind it is...random at best, after all. They come up with step calculus, a formal proof that steps lead you from A to B for A,B being a transitive, reflective set of location kinds and all other sorts of stuff.

Others teach their babies no longer to walk. They first teach them the theory of walking. And then, they assume that their babies will eventually walk better. Of course, you cannot teach a baby something as complicated as the theory of steps at the age of one. So, walking has become rather a post-graduate skill... Those people are forthwith not called Walkers, but Halkers. By definition.

Now, you as a Walker by childhood, imagine you meet a Halker and you talk.
After a while, the Halker stares at you with disbelieving, disgusted eyes. You have not even the faintest idea about walking! You do not even know the basic theorems and lemmas of walking theory. You insist, that you can walk as you did so obviously for all your life. But the Halker simply shakes their head and declares you an utter idiot.

What a great story! But so many questions come to mind now!

Halkers - what is that - that word does not even exist!
Is it not obvious that someone who learned walking at the age of 1 or 2 would walk better than someone who learned it after mastering the theory of walking at the age of 22?
Would all that walking done between the age of 2 and 22 not outweigh the benefits of being able to excel in walking calculus?
Since Halkers became more prominent in the population, demand has risen to ban stairs and other similarly accident prone impure walking contexts.
And indeed it is quite amusing to see Halkers stumble along and falling over in the most clumsy ways more often than not!

Blogger! Will you tell us finally how you came up with the word Halker?

Answer1: I took at the look at the C-code in GHC run time of course!
Answer2: I visited the C-- web sites and did a bit of reading. Did it ever occur to you guys, that with C-- you cut yourself off from all the benefits of stable, existing cross platform compilers and that you basically start from scratch? Why in all categories name did you not write a new front end in llvm and use all the clang/llvm backends? Maybe with a few back-end extensions, if something cannot be expressed in intermediate language terms? Halkers!











Friday, January 16, 2015

Dysfunctional programming

Someone on youtube talking about why clojure is terrible stated:
Functional programming is terrible but the alternative is worse. He also said, that the ONLY alternative is the "status quo". 
So, for a moment let us assume, anything else he said about both functional programming and status quo were true.

Let us focus on his theory, that there are 2 and only 2 alternatives. Is that truly so?

Let us have a look at the implications of that theory.


  • Functional programming is "The end of the line". If there are only 2 alternatives, one being the "status quo", the other being functional programming, there will NEVER EVER emerge a new paradigm for programming. A daring theory indeed!
  • Anyone who predicts, that functional programming is NOT the end of the line is either a radical "status quo" programming acolyte or someone who simply does not understand what category theory and monads and higher kinded types are. An unworthy one! A revolutionary! An ignorant! A troll! Throw those stones already.
And those brainwashed kids who just passed their "category theory" class are swift if it comes to casting stones! Believe it or not, stating the obvious in the haskell irc group got me kicked. What again was the obvious? Right, the obvious was, that there are not only 2 alternatives as well as that functional programming is not the end of the line.

Does anyone really think, that 100 years from now, people will still write code in haskell or another functional language? Or that they will bother with artificial constructs like Monads? I don't - cast your stones already!

You need proof for the counter theorem, that there are more than 2 alternatives? Here we go. Turing machines are an alternative to lambda calculus. Anyone knows of that paper which shows that lambda calculus is as turing complete as turing machines. No need to come up with something new and lofty. It is already there. Who knows? Maybe in 30 years from now, someone finds a cool way to make turing-style programming work and it becomes the new mainstream. Probably not, but that is beside the point. Speaking of point: Case and point.

Yet, in an effort to de-brainwash and inspire free thought, let us just go funny and invent some new paradigm right on the spot. 

Let us call it... dysfunctional programming. And as anything needs a theory behind it (so we can create some classes and exams and so we can torture students with it and waste their time), the theoretical underpinning is F-calculus. Yes, my young apprentice - you will hear of it a lot in a distant future, probably in a parallel universe. F-calculus stands for Failure calculus. The theory of failures.

You might ask: Where is the beef? 

Look at how those ancient functional programmers still try to say what a program shall do! They pride themselves to be more "declarative" compared to their ancestors who were so terribly imperative! But at the end of the day, the difference is academic. We reach for the long shot here! Whenever you try to state, what a program shall do, you run the risk of forgetting something or you run the risk of being too vague or - even worse - to be too narrow.

Exit talking about solution space. Enter talking about failure space.
In "status quo" - functional programming, what does an empty program do? Nothing!
In contrast, in dysfunctional programming, an empty program can do anything! Because we did not tell it what it shall not do, it is free to do anything. Is that not wonderful? You can come up with anything from nothing! Is that not like the godly act of creation itself?

By now, I hope, you start to be all fired up. Let me help you with your getting fired up.

What is the workflow in dysfunctional programming? 
You create an empty file and run the program, compiled from it. It does something totally nonsensical, such as print a number. So, you start to refine your program by telling it that printing numbers is a failure. Compile and run again. This time, your program downloads half the internet and waits for three hours, then terminates, not printing anything. Obviously, you need no internet, so you refine your program by stating, that accessing the internet is a failure. Also, you add, that not printing anything is a failure. And so on and so on.
You are done, when the program has no other option but to do what you want. Instead of adding functionality, you took away failure from your program.

Still not fired up? Well, you have to believe

Stay tuned! Maybe, in a future blog of mine, I will introduce you to F-calculus and its various notations, which guarantee, by the way, that you will not be able to read the clever F-calculus proof of your fellow researcher because you are used to notation X, while he was fond of notation Y!