Thursday, 15 November 2007

Looking up from Blub

Thanks to Randy I have had a good few days looking up from "Blub".

So, Randy posted a comment about the soloution in J for the bowling game. I read that article a while back also. Except I looked at the J code and went "what a load of crap". And who could blame me? The code looks like crap, from http://www.xprogramming.com/xpmag/dbcBowlingVector.htm , heres the code :-

framex =: 10 {. 0 {~^:a:~ _1 _1 ,~ i.@# >:@:+ 10&~:
scoreifframe =: 3 +^:(9<])`+/@|.\ ,&0 gamescore =: [: +/ framex { scoreifframe why waste your time with anything that looks like that? Well, as it happens, I think its a case of being a Blub programmer and running into "The Blub Paradox" as coined by Paul Graham and written about here http://www.paulgraham.com/avg.html

Basically, when you see a language which is more powerful than the ones you know, you're not going to immediately recognise it.

Anyways, having got Randys comment on my blog I thought I should be a bit thorough and have a look at this J stuff. I winced at the cryptic nature of the code. But even if it was cryptic, the quicksort on wikipedia in J code did impress me as its a single line of code....

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#) Which is a great example of Tacit Programming ( http://en.wikipedia.org/wiki/Tacit_programming )

and J is an example of Function Level Programming ( http://en.wikipedia.org/wiki/Function-level_programming )

and J is also a a non-Von Neumann programming language ( http://en.wikipedia.org/wiki/Von_Neumann_programming_languages )

So, anyways, I downloaded J and started to wade my way through a fantastic tutorial on J at http://www.jsoftware.com/help/learning/contents.htm

Surprisingly quickly the cryptic squiggles started to all make sense and the stuff on hooks and forks in http://www.jsoftware.com/help/learning/03.htm was really quite cool.

Anyways!

All this stuff comes back to a guy called John Backus, which most anyone who's done computer science will know, is responsible for Fortran and BNF ( a notation to define context free grammars ). He wrote a very famous paper where he basically criticises languages and their designers and tells them they are intellectually crippling the world of programming. Pretty much anything in the C C++ Java C# strain of languages is crap. Or at least a crippled way of writing programs.

Anyways, the paper is http://www.stanford.edu/class/cs242/readings/backus.pdf and its from 1977. It is a very good read. Except! I have read this before, really early on in my education. I remember the idea of getting around the von-neumann bottle was pretty cool but I barely paid any attention to it because it meant very little to me. There were more practical things to be doing like trying to write C and hack VGA X mode code.

Having said all that, I'm not sure if J is really *hugely* more powerful than other programming ideas however it provides quite a unique way of thinking about programming. That in itself is very good.

1 comment:

Anonymous said...

A nitpick:

there is an extra space after > in the definition of framex

> : should be >:

Ron may have erred as well, but I did not check that.