Programming Languages Oddity
Programming languages can be (and should be) clear to write and read, and no doubt that some of them, especially the new generations of languages, are just that. But we can’t escape the fact that a programming language is still an artificial, human made product, and so it sometimes looks and behaves quite, well, strange.
In this post I’ll show some of the most strange and bizarre programming languages constructs, structures or syntax. Things that always make me wonder — what were they thinking of? Let’s be honest — we’re not writing things like that anymore –
mov dptr, #10hmovx a, @dptrinc dptr
Those days are over, thanks god, but still, sometimes the code we write can look as bad. Here are some examples that form, in my opinion, some of the worst constructs in programming languages. Enjoy!
Compilers have this annoying thing — they must know when a block of code begins and when it ends. Before the clever invention of curly brackets entered, each language found its own way. Remembered for good is the Pascal’s way with its “begin” and “end” keywords. But why use English words when we can invent some? How do you end a while loop in VB6? Well, it’s called “wend” meaning “while end”. And the python “elif” word for “else if”. I don’t know about you, but every time I read and write it I have a vision of Lord of the Rings with its elves.
But the prize for the most gruesome invented words go to the “Cool” programming language — I know, I know, it’s not a “real” language but it’s quite real for those who learn compilers theory. In this language there is a nice way of ending a block. The keyword for ending a block is the keyword that begun it, in reverse. “if” ends with “fi”, “case” ends with “esac”, “loop” ends with “pool”. Oh my.
Sometimes a language must express certain ideas, and those ideas must be different from another, that should be yet different and so on. That makes the code very, very verbose and oh so strange. C++ is the definite queen of defining things with all possible ways. Look at this –
const int*const myFunction(const int*const&)const;
Say “const” one more time!
Speaking of signs — sometimes the language designers forgot that we are human beings and make us write all kind of encrypted-like code that looks like a monkey hit randomly on the keyboard. I just love the C pointers and addresses:
**p = &(*q)
int **a = (int*)(malloc(sizeof(int)*10);
and all kind of weird mutations like
&a[i], *(a+1), *a, &&a
Ok, the last one is a compilation error but you must admit it looks just as rational as the rest.
So, what is your worst code list? Which languages win the most unreadable? Tell me in the comments :)