In good representations, similar things will look alike and distinct things will look different. In great representations, good representations combine with metaphor to create meaning. The metaphor used in J is the array. If you are not sure of J’s approach to rank, shape, or item then take a look at the previous post, otherwise let’s dive right into the spot that the J text representation breaks down. If we have an array with rank 1 and shape 1, it would look like this:
A1=: 1 $ 4 A1 4
And if we had an array with rank 2 and shape 1 1:
A11=: 1 1 $ 4 A11 4
And if we had an array with rank 3 and shape 1 1 1, it would look like this:
A111=: 1 1 1 $ 4 A111 4
Now using the “Shape Of” monadic verb ($) it is easy to get the shape information we want:
$ A1 1 $ A11 1 1 $ A111 1 1 1
But if we only consider the representation, we find that things that are different look the same, which is a problem. Taking it one step further, let’s look at an atom. This particular atom is an integer:
A=: 4 A 4 $ A
Atoms are arrays with an empty shape, and in this representation they look like other singleton arrays. The empty line represents the atom’s empty shape, but as innovative as this approach is, we still can’t discern single value arrays from atoms or one another.
To be fair, it is not only the J representation that has this problem. Looking at the block representation:
We notice that a single block could be a list of shape 1, or a table of shape 1 1, or a brick of shape 1 1 1. In fact, we are even at a bigger disadvantage with the block representation because an atom such as A would look like this:
Or maybe perhaps the atom would be colour without the block, since the block has an empty shape. At least J can show us the value of the atom.
The second area where the J representation breaks down is how it shows empty arrays. An empty array is an array that has a zero (sometimes more than one) within its shape. If we create an empty array of shape 0 we’ll see the challenge of representation:
A0=: 0 $ 2 A0 $ A0 0
which means that A0 displays as an empty line (a list with 0 length), and the shape of A0 is 0. This is a good representation as far as it goes, but it gets complicated with rank 2 arrays:
A00=: 0 0 $ 2 A00 $ A00 0 0
Here, the shape 0 0 means no lists of length 0 and the empty line disappears. This suggests a difference between arrays of shape 0 and shape 0 0 which is good, but when we look at an array of shape 1 0, our one empty line returns:
A10=: 1 0 $ 2 A10 $ A10 1 0
But an array of shape 0 1 looks identical to an array of shape 0 0:
A01=: 0 1 $ 2 A01 $ A01 0 1
And if we think the problem is with J’s text limitations, with physical objects, representing empty arrays becomes quite impossible. We could make a zen koan about showing the shapes of things that are not there, but it would still not make the representation any clearer.
In the last two blog posts we have developed language to describe arrays, and used that language to show the problems with both J’s text representation and a block representation. The next post will be about a visualization method which solves some of these array representation problems. In the meantime, any response that you have is welcome; either about the presentation style for these ideas or regarding the ideas themselves.