As noted above, J is a derivative of APL which restricts its character set to ASCII for the sake of portability. That is, it is an array-based dynamically-typed language in which one can do highly impressive things with extremely cryptic syntax. In fact, I would say that it goes above and beyond the call of duty as far as being compact and powerful, blowing by the likes of Perl in that department.

Now, many will claim, ``This is not a good thing; it's hard enough to read the languages we already have...how on earth are we going to deal with this?'' However, I think that J (as designed by Ken Iverson and company) really delivers on its promise of being a useful pedagogical tool, especially for mathematics.

For the skeptics among us, consider the following C-language snippet:

int a[] = { 1, 2, 3 }, b[] = { 3, 2, 1 }, c[], i;
for(i = 0; i < 3; ++i)
    c[i] = a[i] + b[i];
and compare it to the following J:
a=. 1 2 3
b=. 3 2 1
c=. a + b
I think there will be few arguments about which is clearer in intent.

However, that is not to say that J is always going to be transparent to anyone who reads it; consider 4 ({: > >./@}:)\ v. To the unitiated, this looks like gobbledygook, like line noise. However, using the rules set forth in The J Dictionary, this can be decoded rather cleanly:

  • Reading from the outside in, we see that it applies a monadic (one-argument) operator to successive values of a sliding window of size 4 over v and returns the results. (This comes from the pattern 4 f\ v.)
  • Looking deeper, we see that it compares (>) the tail or last element ({:) of the window to something else.
  • Finally, we see that the other operand is the maximum (>./) of the result of (@) ``curtailing'' the window (}:).

Putting that all together, we see that, for each window, it tells us if the last element is greater than the other three; the equivalent in C:

for(i=3; i < length_of_v; ++i)
   result[i-3] = v[i] > v[i-1] && v[i] > v[i-2] && v[i] > v[i-3];

If one puts the time and effort into learning the symbols behind the language, there is a lot to be gained here. For further information, see http://www.jsoftware.com/, where free copies of the software and HTML versions of the documentation are available.