APL, J, and Gunnar Shuffle

Ten daysago, Gunnar Kudrjavetsposed a really tricky algorithm challenge. I spent some time trying to solve it, and then jumped into the comments section to see how others were doing. I noticed that some people were using a programming language called ‘J‘, which is based on APL. Now, I highly doubt that the solutions in ‘J’ have the desired memory or CPU characteristics, butthey fitin a single cryptic line of code.


So I downloaded J, and went through the 200pp tutorial. I’m now a dangerous amateur. The language reminds me of a mix between lisp and awk. Doing math is a joy. One nice feature is the way that everything is multidemensional; atoms, items, lists, tables, and so on. The other interesting (strange?) feature is tacit definitions. Between those two concepts, you can so really amazing things. Here are some strange things I noticed:



  • 5 * 3 + 1 = 20

  • while. and whilst. have different semantics

  • namespaces are called ‘locales’

Anyway, I was standing in line at the Cafe today, and I noticed a person with ?Gunnar Kudrjavets? on his badge. I went over and introduced myself, ?hey, I have now learned to program in ‘J’ because of your blog!?. He knew immediately what I was talking about, and we had a nice conversation about the shuffle problem. Getting people interested in APL was probably not his intent in posting the original challenge, but it was serendipitous to bump into the person responsible for prompting me to learn yet another arcane language.

Leave a Reply