A couple of days ago, I started studying J language. It is doing strange things to my mind. I must report to you now, before my thoughts are so alien that we will not be able to communicate at all.
I’m just learning. Five or eight hours so far. So I may have some details wrong. But I’m here to report what the voices in my head are saying. Trust me, but do not trust me. I hope to report further on this exploration. Trust those messages, but do not trust them …
J language is APL for people who do not have a million-key keyboard. It is described in English-language terms: noun, verb, sentence, rather than conventional programming terms. It is incredibly compact: +/ 1 2 3 4 5 means the sum of the elements of the list of the numbers one through five. +/ 1 + i.5 means the same thing. i.5 generates 0 1 2 3 4, while 1 + adds one to each element of the list, and then +/ sums it.
At first, it just seems cryptic. There are about a million verbs, and +, +. and +: mean six different things. That’s right, six. Because x + y means something different from + y, and so on!!
But cryptic isn’t the half of it. J language verbs automatically apply themselves to lists and arrays. We have seen +/ apply itself to the integers from one through five. How about this: you would guess, correctly, that 2 + 3 is 5. However, 1 2 3 + 4 5 6 is 5 7 9. The + operates automatically on the lists, adding corresponding elements and producing a list.
It gets worse. Much worse. Or, much better. There’s <p style="text-align: left; padding-left: 30px;">, or append, so that 1 2 3 , 4 5 6 is 1 2 3 4 5 6</p> <p style="text-align: left; padding-left: 30px;">$ or shape, that turns a list into an array</p> <p style="text-align: left; padding-left: 30px;">|: or transpose, that transposes an array</p> <p style="text-align: left;">Put these all together and , |: 2 2 $ i.4 turns 0 1 2 3 into 0 2 1 3. (This may not be the best way to do that …)</p> <p style="text-align: left;">As you work with J language, you begin to think in terms of operations on whole arrays. And J can uniformly handle arrays of any dimension you might want. Your mind begins to solve problems by folding and mapping and unfolding and lord knows what all. You understand problems differently and you come up with solutions that you would not, could not, do in C. Or in any other language I know, other than APL itself.</p> <p style="text-align: left;">I’m just on the edge right now. My mind is going. I can feel it. I can feel it …</p> <p style="text-align: left;">Daisy, Daisy, give me your answer do …</p>