J is a general-purpose programming language available on
a wide variety of computers. Although it has a simple structure
and is readily learned by anyone familiar with mathematical
notions and notation, its distinctive features may make it difficult
for anyone familiar with more conventional programming languages.
This introduction is designed to present J in a manner that makes
it easily accessible to programmers, by emphasizing those aspects that
distinguish it from other languages. These include:
|1.||A mnemonic one- or two-character spelling for primitives.
|2.||No order-of-execution hierarchy among functions.|
|3.||The systematic use of ambivalent functions that,
like the minus sign in arithmetic, can denote one function when
used with two arguments (subtraction in the case
of -), and another when used with one argument
(negation in the case of -).
|4.||The adoption of terms from English grammar that better fit
the grammar of J than do the terms commonly used in mathematics
and in programming languages. Thus, a function such as addition is
also called a verb (because it performs an action),
and an entity that modifies a verb (not available in most
programming languages) is accordingly called an adverb.
|5.||The systematic use of adverbs and conjunctions to modify verbs,
so as to provide a rich set of operations based upon a rather
small set of verbs. For example, +/a denotes the sum
over a list a , */a denotes the product
over a , a */ b is the
multiplication table of a and b .
|6.||The treatment of vectors, matrices, and other arrays
as single entities.
|7.||The use of functional or tacit programming that
requires no explicit mention of the arguments of a function (program)
being defined, and the use of assignment to assign names to functions
(as in sum=:+/ and mean=:sum % #).
The following sections are records of actual J sessions,
accompanied by commentary that should be read only after studying
the corresponding session (and perhaps experimenting with variations
on the computer). The sections should be studied with the J
system and dictionary at hand, and the exercises should be attempted.
The reckless reader may go directly to the sample topics.