I should begin by admitting that I am neither a mathematician nor an expert on APL or J. On the other hand, I am interested in learning about new ways of thinking about programming, and these languages seem to offer some possibilities in that regard.
I first encountered a variant of APL on an experimental machine at the University of California, Santa Barbara, about two decades ago. I liked the natural access to arrays, but the somewhat arcane character set was a bit of a challenge. In fact, the main reason I have not used APL in the interim probably has to do with most vendors' lack of support for the APL character set, along with some unwillingness on my part to stick labels onto my keycaps.
In any event, Ken Iverson and Roger Hui have now written a new language, J, that can be accessed naturally from an ASCII keyboard and display. It is freely available via FTP, along with several varieties of APL (none, unfortunately, for UNIX). The APL/J archive can be found under ftp://watserv1.uwaterloo.ca/languages/j/
Start by picking up the announcement, archivist, and index files. Lee Dickey, the archivist, is quite congenial. In fact, he assembled a J source package for UNIX, at my request. Look for it as j/j_6.2_src_pkg.tar.Z. Dickey is quite willing to answer archive-related questions, but says that comp.lang.apl is really the place to go for most APL/J questions. For printed documentation on APL and J, you should contact Dr. Iverson's company (see References section).
Dr. Iverson sees J as a way to introduce both mathematics and programming. He has published several small books which use J in this way. Don't get the books expecting to read them; instead, get them as interactive workbooks to guide your initial J sessions.
Be prepared to learn some new ideas and terminology; J certainly isn't C! Also be ready to think, rather than just absorb. Dr. Iverson doesn't explain much; instead, he presents interesting exercises and lets the student figure out what the program is doing, and why.
I retrieved and built the J source package without difficulty. The makefile asks for gcc, but everything built under SunOS 4.1.3 cc without complaint. My only complaint in running J is that it is fairly easy to dump core by entering a bogus command.
On the other hand, restarting J is trivial, and an experienced user probably wouldn't type in crud very often. Nonetheless, I feel that the error-checking should be made a bit more robust.
J is an interactive interpreter. In its simpler forms, it acts a lot like bc:
3+4 7 2^3 8
Unlike bc, however, J is perfectly willing to deal with lists, strings, and other common data types. Here, we generate the first five natural numbers, followed by the first five powers of two:
i. 5 0 1 2 3 4 2^i. 5 1 2 4 8 16
String manipulation is also short and sweet, if a bit confusing at times:
'foo', 'bar' foobar ~. 'mississippi' misp = 'mississippi' 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0
Dr. Iverson doesn't explain these bits of magic; he simply lets the user try them out, think, and learn. Some explanation, or at least a few hints, may be appropriate, however, in this forum. The first example shows string concatenation. The second extracts unique characters from a string. I will leave explaining the last command as an exercise for the reader. Hint: compare the positions of 1 in the second line with the positions of i in the mississippi.
I hope I have whetted your appetite, rather than appalled you, with these examples. Regardless, I think we should all be happy that a few adventurous souls like Dr. Iverson are willing to chart paths off into areas untouched by more conventional language designers. I didn't get into this field to get bored; with language designers like Dr. Iverson around, I won't...
Iverson Software publishes the following books:
For more information, contact Iverson Software Inc., 33 Major Street, Toronto, Ontario, Canada M5S 2K9. Tel.: (416) 925 6096, Fax: (416) 488 7559