the 'J' Language

Home pages: JEHS | Stats | SCU | WRI | Maths | Warwick

What is J?

J is a concise and powerful language for communicating mathematical ideas unambiguously, not least between humans and computers. Full details and software can be found at http://www.jsoftware.com.

J has the usual built-in operations like +, -, * (multiply), % (divide), and ^ (exponential or power). Some other important mathematical ideas are expressed in J as a character followed by a colon or a full stop. For example, 'not' is represented in J by -., 'matrix inverse' by %., 'root' (including 'square root') by %:, 'log' by ^., 'polynomial' by p., and 'Taylor coefficient' by t..

J really is best thought of as a language - objects are nouns, functions are verbs whose action may be modifed by adverbs like / (see below), etc. While learning J I have sometimes found it helpful to point and read aloud! For example, the following brief dialogue between myself and the computer:

 
   x=. i. 10
   x
0 1 2 3 4 5 6 7 8 9
   +/ x
45
   # x
10
   mean=. +/ % #
   mean x
4.5

may be read as:
ME: x is defined to be a list of the first 10 nonnegative integers
(i. is an inbuilt J verb)
ME: what is x?
(J sentences typed into a computer are either definitions, containing =., or instructions to evaluate something, i.e. implicit questions of the type 'what do you understand by ...?')
PC: <answers>
(note that whatever I type is indented but the computer's replies are not)
ME: sum over x
(more formally, insert a '+' between the items of x, and evaluate the resulting expression)
PC: <answers>
(correctly!)
ME: what is the number of items in x?
(# is another inbuilt J verb)
PC: <answers>
ME: "mean" is defined to be "sum over" divided by "number of items in"
(note that verbs - functions - in J can be defined directly, without reference to dummy arguments etc. This is particularly useful because much of mathematics, such as group theory, studies verbs rather than nouns)
ME: what is the mean of x ?
PC: 4.5
(I have now taught the computer the definition of "mean").
Excellent introductory documentation, including examples of statistical applications in J, can be obtained from Keith Smillie's home page. See also Jack Siler's J page, Jim Weigang's home page (for APL), Vector (journal of the British APL Association), and the J Archives at Waterloo. My own embryonic "Introduction to J" is available as zipped postscript in A4 or US letter sizes. I hope to update and expand it soon. Honest.

Scripts

J code like the above is conveniently stored in text files called (J) scripts. You may like to look at:

Disclaimers

  1. J has a very steep learning curve, and I have only been using J in earnest since November 1995. Please don't treat my J code as necessarily a good example.
  2. The J scripts I have made available on the WWW are somewhat outdated, but I hesitate to disseminate newer test versions. Note in particular that some of the @ symbols ('atop') should be replaced by @: ('at') following changes in J version 3.03.
  3. I have no connection with J's developers and vendors, except as a delighted customer.

My (Current) Top 10 Reasons for Using J

  1. Power
    Like APL (but much more so), J is a powerful language for expressing mathematical concepts, for quickly trying out crazy ideas to see which ones aren't so crazy after all, and for catalysing insights into the underlying maths.
  2. Communicability
    Unlike APL, J uses just standard ASCII.
  3. Coherence
    J is not designed by a committee - it is the brainchild of one person (Ken Iverson), with additional input by Roger Hui and feedback from other users. J didn't have to be downwardly compatible with anything (don't think of it as APL++!)
  4. Programming Environment
    The J development environment makes it easy to split up a huge programming task into manageable chunks. Divide and conquer.
  5. Portability
    The J language is fully portable (in theory to any system with a C compiler).
  6. Flexibility
    The PC implementation for professional developers can be linked to other software by DLLs, OLE etc. (specific user interfaces on the one hand, number-crunching engines on the other).
  7. Windows
    The PC implementation makes MS-Windows programming bearable. Impressive-looking user interfaces can be produced with minimum pain.
  8. Poverty
    A version of J (including all documentation) is freely available from http://www.jsoftware.com. You can try before you buy, and end-users will not have to pay any extras to use software produced in J. Before 1996 I used a commercial APL, whose vendors wanted 1500 per annum from the Statistics Department for continuing support.
  9. Fat-free
    The complete J system takes around 5 Mb disk space. Small is beautiful.
  10. Morale
    This frees my CD-Rom (that I bought with every intention of programming in C++) so that I can listen to music while working late at night. Essential for morale.

Pertinent (& Impertinent) Quotes

In science, each new point of view calls forth a revolution in nomenclature.
Friedrich Engels.

A good notation has a subtlety and suggestiveness which at times make it almost seem like a live teacher.
Bertrand Russell.

It is a profoundly erroneous truism, repeated by all copy books and by eminent people when they are making speeches, that we should cultivate the habit of thinking of what we are doing. The precise opposite is the case. Civilization advances by extending the number of important operations which we can perform without thinking about them.
Alfred North Whitehead, Introduction to Mathematics.

This page is maintained by J.E.H.Shaw@warwick.ac.uk.