Dijkstra said I am mentally mutilated — story about BASIC, Haskell and Communism

Posted on April 17, 2019

It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.

Dijkstra, Edsger (1982)

BASIC, Cats and Communism

It was one of the last days, both of summer and communismThe People’s Republic of Bulgaria existed from 1946 to 1990 and it was ruled by the Bulgarian Communist Party

in Bugaria. I was just 6 years old and mental mutilation was waiting for me to get to school.

My mother enrolled me in a pre-school math class, for which I had to pass a simple math exam. This placed me in the hands of Atanas Badjakov - my first math teacher, who also happened to be teaching a programming course for children. So take a breath and let me tell you about how crazy, impossible and awesome this seemed for me at the time.

I was living in a relativly small city, in a country undergoing a period of energy crisis, where everyone had to light candles at night. The communist dream was starting to turn into a nightmareLine of people waiting for bread People waiting to buy bread in line. Somewhere in Bulgaria.

, my father managed to escape to Canada, but he never called back. Ah, and almost nobody had a PC, had used one, or knew what it was.

So let’s go back to the room full of PravetzPravetz 8c Pravetz 8M computer . Most of the Pravetz line of computers were Apple 2 clones, but not the 8M

computers that shaped pretty much the rest of my life.

I remember being mesmerized when our teacher showed us animated cat moving its tail on a screen. The trouble is that 30 years later I am still staring at screens and drawing cats. And my mother, god rest her soul, said I was a man of irregular life…

So let’s get back to business. I happened to find some of my old BASIC textbooks at the attic that brought sweet memories. Reading the BASIC Cat code 30 years later reminded me of Edsger’s quote…

From Boyan Yankov and Mishel Avramov , Basic for microcomputers, page 56 - 57. Basic for microcomputers

In a feeble attempt to prove Dijkstra wrong, I will rewrite the BASIC code shown above in HaskellHaskell An advanced, purely functional programming language

— one of the favorite programming languages of both Edsger and me.

I am not going to throw a full blown monadic rewrite here. Instead I will keep the code close to the original so we can see how they were solving basic animation problems back then.

The most difficult part of porting the BASIC to Haskell was setting up OpenGL under NixOS. But the net result looks exactly like 30 years ago:

Render of the cat made with gloss and Haskell Render of the cat made with gloss & and Haskell

You can find the code on github.

Still… I keep asking myself - am I really mentally mutilated? Should I go with type recursion with functors and catamorphisms, in the spirit of The Evolution of a Haskell Programmer, to prove Dijkstra wrong ?

I will leave that for another blog post. Wish you all a happy and productive day!