This programming language may be used to instruct a computer to perform a task.
|Type strength:||Strong (but regular)|
If you know J, please write code for some of the tasks not implemented in J.
 the J language
J is a notational programming language designed for interactive use.
It is an array language; data is universally structured as rectangular arrays.
It is a functional language; creation and composition of functions is emphasized.
Object-module and imperative techniques are supported, but not required.
The J programming language was designed and developed by Ken Iverson and Roger Hui. It is a closely related successor to APL, also by Iverson which itself was a successor to the notation Ken Iverson used to teach his classes about computers in the 1950s.
 Reading J
J is meant to be read with the aid of a computer. J sentences are single lines and trying variations and simplifications of an expression is common practice. The first step in understanding any J sentence is to understand the data you started with and the data which resulted. When learning how a J sentence works, you can also try simpler sentences with the same data or perhaps related data.
Unless you attend an institution which has made a J interpreter available to you through your web browser (or preinstalled on your machine), if you want to see how J works you should probably install a copy of J -- or you can try one of the "try me" links, below. If you want to understand how to experiment with alternative expressions you should probably also be studying some of its documentation.
For example, the phrase
(+/ % #) finds the average of a list of numbers.
(+/ % #) 1 2 3
To understand how this works, you might try working with simpler sentences and their variations.
+/ 1 2 3
+/4 5 6
# 1 2 3
# 2 3 4
6 % 3
15 % 3
(+/ % #) 4 5 6
By themselves, these experiments mean nothing, but if you know that +/ was finding the sum of a list and # was finding the length of a list and that % was dividing the two quantities (and looks almost like one of the classical division symbols) then these experiments might help confirm that you have understood things properly.
 Some Perspective
If you wish to use J you will also have to learn a few grammatical rules (J's parser has 9 reduction rules and "shift" and "accept" - the above examples use four of those rules). J verbs have two definitions - a single argument "monadic" definition and a two argument "dyadic" definition. These terms are borrowed from music and are distinct from Haskell's use of the word "monad". The dyadic definitions are in some sense related to LISP's "cons cell" but are implemented as grammar rather than data structure, and are a pervasive part of the language.
Another pervasive feature of the language is rank.
The language represents capabilities of hardware. For example, if language did not have an internal stack, a word's definition could not be used during the execution of that word. All current J implementations support recursion, but in some sense this is a convenience, and it's reasonable to imagine J implementations which do not (perhaps in a "compile to silicon" implementation).