Friday, June 10, 2005

Random thoughts on programming languages.

'A thing of beauty is a joy for ever' - John Keats
No, I am not talking about the close encounters with the 'other' kind (girls) which don't usually happen to dungeon monkeys like me who only get to bang their keyboards. This article is regards to atavism in modern computer programming languages. Well, by modern programming languages I mean those which are worth the hacker's salt, and not those that are designed by behemoth organizations which pander to the needs of profitability and business rather than competent and good design.

It is a very common notion that scientists live in the world of surreal and are not bothered by the non-idealism pervading in reality which are of constant concern to engineers. And thus engineers are considered as those who design skills are to be of any practical use. Usually a scientist's (henceforth called dreamers) obsession with beauty and cleanliness avoids any sense of pragmatism is a much prevailing misconception. However, their obsession with beauty and elegance has the quality to lead and steer than an engineer's (realist's) flirtations with 'ground' reality. If you are still thinking what all these philosophical musings which are often sources of intense debate among the academia, has to do with programming languages then here is what I will be talking about further in this post.

I've always been interested by programming ever since the days of my childhood and I am an active programmer. I currently am proficient in many of the langagues that have come to be the mainstay of modern software engineering such as C/C++, Java etc.. The first language which I ever learnt was called LOGO a simple programing language which launched me into programming, later i accumulated BASIC, Pascal, C, C++ , Java, Perl, Python to my repertoire of programming languages. Inspite of the fact that I've qouted more than half a dozen languages most of my programming is either done in Java or in C. Only lately I've been looking at LISP. Inspite of its alien looking syntax proliferated with paranthesis which can make anyone recoil in disgust, the language hides subtle beauty and immense power which even modern programming languages can't compare. Infact the most amazing fact is that this language is the second oldest programming language to be still in use (McArthy 1965). This is simply a post on my feelings on two of my current favourites in the programming language menagerie - C and LISP.


C - A realist's design : Modelling the machine

The C Programming Language, originally concieved by Dennis Ritchie far back in the 1980's is one of the most popular languages around. This is still one of the most popular language around and much of the bulk of code written is written in C. What served as a low level assembler to bridge the semantic gap has grown into an immensely powerful language. But still it, in its heart is a realistic design. Its imperative style, insistence on the how's rather than the whats has made it close to the machine.. which is in itself a system which concentrates on the how's more than the whats.

Also, one of the most pleasing aspects of C is its bare minimalistic design which belies the power and expressiveness it can unleash which comes from the entire language design being built upon a few but relevant metaphors which form the what you might call the 'C line of thought'. These metaphors are those that model the underlying machine. Infact it was the expedetious choice of such metaphors that make C, a language that was designed on the Dell PDP minicomputers which are long obsolete still relevant to this day.

But, even C has its own shortcommings, The metaphors it models form only a thin layer of abstraction around the actual machine leaving the rest to the ingenuity of the programmer. This freedom, as any other freedom is and has been severly abused by those who don't understand it. Though many modern languages such as C++ and Java were built upon the foundations of C, none of them are as elegant as one would had hoped and are either extremely overcomplicated (C++), or simply too restrictive (Java).


LISP - A dreamer's design : Modelling the math

LISP which stands for LISt Processing was orignally an academic paper by McArthy in the late 50's and early 60's. It was later implemented by Steve Russell on the IBM-704 a machine the size of refrigirator and this was the time when IBM was playing "The Empire" (Now being played by Microsoft and actively competed for by Google - another post on this). It was designed as an alternative model for computation and LISP in itself was just the bare mathematical notation that McArthy incidently developed. As an aside, Steve Russell is incidently the 'father' of computer games which has spanned the multi-billion dollar computer gaming industry

One of the best things about lisp, comes directly from its mathematical roots. Elegance. LISP is elegance defined. Its as simple as that. Being a model of computation and as a system for symbolic processing it wields amazing power in terms of expressiveness. Infact most of the ideas which have become 'de facto' standards in modern programming languages was implemented first in LISP. And strangely all this power of lisp comes from a set of operators as minimal as that of C or even more so.

Being the lingua franca of the AI research community has given LISP the image of being arcane, hard to learn and difficult to understand. But this is exactly the image that has been attributed to math, but many fail to remember that math is the expression of absolute truth. The beauty of math stems not from complicated equations or intricate inferences, but from the fact that every mathematical statement is a statement of truth.
(the sense of the word 'truth' is not entirely in the sense associated gandhiji's teachings, but in the sense that 1+ 1 =2 is undeniable and wholly true).

Again, as in C, LISP has fundamental metaphors, but LISP's metaphors are intrinsically more powerful because of the fact that they model computation itself rather than computers. Also the LISP line of thought focusses primarily on the "whats" and only incidentally on the hows, and one of its fundamental metaphors - 'The Partial Recursive Function' serves to highlight this spirit.

LISP's shortcommings is only the fact that it requires initiation and the fact that it recieves much less media attention these days. Infact most modern languages borrow heavily from LISP. for example Java and the .NET series of languages which talk about garbage collection and 'Managed' code has been in LISP for the past 35 years! but, yet these languages haven't caught up with LISP, and slowly the gap is bridging. And history shall come a full circle. It is also interesting to note that LOGO, the first language I learnt was derived from LISP, life has come a full circle, i guess.


The Language of the future : Modelling what ?

I am not really sure what the future beholds, but what will the next new language be? Looking at the geneaology of programming languages, It started out with modelling computation and led to LISP and all its derivatives, but back then when computers weren't powerful enough people started modelling computers to pump out as much performance as required. As computers have grown more and more powerful modern programming language designs have been trying hard to find the correct middle ground between an effective model of computation and a model of the computer. Infact even I am designing a language which searches for this holy grail.

As machines get more powerful, The languages that will become the mainstay of programming will not be those that model computation or computers, but those that model the mind.

Signing off,
Vishnu

4 comments:

shakuni said...

I should have trademarked "dungeon monkeys" when I had the chance da. Copycats like you have now stolen it. :)

Vishnu Vyas said...

sorry for not giving you due credit da..

"dungeon monkeys" (c) 2005, Jayakanthan. Aka, Shakuni.

All registered trademarks are properties of their respective owners.

Vivek said...

isnt this supposed to go into the techy/artsy blog?

and what is the status of the comic strip?

Vishnu Vyas said...

Well, my tech/artsy blog right now contains updates of UBASIC 2, And i currently use it as a journal for development and plan to continue to do so.. (untill i get enough php /dhtml skills to do that on my hdd using mysql ).

As far as the comic strips go, Fuzzy Logic is in the cryogenic chamber. I'vent got too much time, but I am thinking of a small not too 'art intensive' comic.. using at the max stick figures or crudely drawn charecters... Will probably post that once a few strips are done..