Programming language J. Look amateur. Part 1. Introduction

Dijkstra: How do you write a more complex expression? For example, the sum of all matrix elements that are equal to the sum of the indices of the corresponding rows and columns.
Iverson: + + / (M =? 1 ^ (o) +? 1) M //
(Kenneth Iverson - creator of the APL and J languages)

1. Quick start

Before the APL got its name, it was called the Iverson Notation. However, Ken believed that the name should just sound like “Notation.” And in fact, we do not say "grass of God," we just say "grass."
Paul berry

Distinctive features of the programming language J can be called:
  • vector arithmetic
  • extreme brevity
  • Extensive standard library designed specifically for statistical data processing
  • the presence in the standard library of functions for drawing 2d graphs and 3d surfaces, as well as primitives for creating a graphical interface
  • detailed and varied documentation and examples

We can say that J is in the same niche as Matlab and R. But there is one “but” - the syntax of the language.
Here is one of the most common educational examples of all the introductions and tutorials J:

	mean =: +/%#

In this example, a new function is defined (in J it is called a “verb”) “mean”, which calculates the average value in an array of numbers.

The very expression "+ /% #" literally means the following sequence of actions:
  • Take the sum of all elements of the array ("+ /" is responsible for this).
  • Calculate the length of the array (expression "#").
  • Divide the first by the second (“%” in J means division).

You can invoke this verb as follows:

	mean 1 2 3 4

where 2.5 is the result of calculating the average on an array of integers from 1 to 4. Note that in examples with a large indent, the expression is indicated, with less - the result of the calculation.

Add colors to our description of J. Here, for example, is an expression that implements quick sorting (Hoar sorting):

	quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)
	quicksort 3 4 1 2 4.1 _0.1
_0.1 1 2 3 4 4.1

In the above example, the quick sort function is defined on the first line, the array of numbers is sorted on the second, and the sort result is displayed on the third.

One of the strengths of J is its graphical subsystem. Examples can be found at

The official site for developers of the language and the most popular (and, concurrently, the only) J language translator is . The key personalities who took part in creating the language are: Kenneth Iverson (Kenneth Iverson, passed away in 2004) and Roger Hui (Roger Hui).

For the sake of justice, it is necessary to mention jsj - the limited-in-line J-interpreter in Javascript. And also J & +- a subset of the J language

Translator J is portable both between operating systems and between processor architectures. So, on the official website versions for Linux (32 and 64 bits), Windows (32 and 64 bits), Mac (32 bits and beta for 64 bits) and PocketPC are available.

At the moment, both the 6th and 7th versions are provided. In a more stable version 6, the GUI for Linux is made using Java. In the 7th version, the graphical interface is completely cross-platform and is based on gtk. However, this version is still not quite user-friendly, and in beta version 8 the interface has been redone already on Qt.

For development on J, you can use both the “native” development environment and Emacs (the mode for editing source codes in J is located at http : //

Until recently, J was distributed as a freeware application, and the source code was distributed under a commercial license. Now the source code for the 7th version is open under the GPL3 license (see ). In addition, there are no licensing restrictions on J.'s own translator implementations.

2. Past and present

You will forget about quality much later than you forget about cost.
Kenneth Iverson

J's direct ancestor is the APL language (APL stands for "A Programming Language"). Moreover, the author of one and the other is the same person - Kenneth Iverson (stories from Kenneth’s life (the so-called “kenecdotes”) can be found at . Epigraphs to this article taken from there). An interesting feature of APL was the use of special characters in the language that were not on the keyboards we were used to. Special APL-compatible keyboards were also produced. And, despite the venerable age (the year the APL was opened - 1964), this language is developing and is still used.

The time of the appearance of the language J is considered to be 1990. One of the main differences between the new language and APL was the use of only ASCII characters in the naming of standard constructs.

One of the earliest (1994) implementations of the language interpreter can be found at . Prior to the discovery of the source code of the modern 7th version of the language, this was the last available version of the source code of the J language.

Translator J is written in C with the widespread (“aggressive” one might even say) using a preprocessor. And, as the authors of the language themselves say, the interpreter J is written in J. Or rather, on that subset of the language J that can be obtained using the C preprocessor. In this regard, for strangers, the source code J looks almost unreadable. In addition, the source codes are “successfully” decomposed into separate files with speaking names such as ac, bc, etc.

Modern versions of the J language change quite slowly and the changes have not looked revolutionary lately. Although the latest version of the 5th branch and the current stable version 6.02 are not fully compatible. One of the interesting innovations in version 6.02 is the expression “M.”, which adds automatic memoization of the specified function.

At the moment, the next version of the J-7.0 interpreter is actively developing. There are no conceptual language changes in this version. However, quite significant changes have affected the translator infrastructure. Note some of them:
  • The GUI, as already mentioned, is now written for both Windows and Linux using the Gtk library.
  • Now J has his own package manager. For example, the graphical shell of the interpreter is not included in the standard package and is installed using the package manager.
  • An HTTP server written in J appeared in the standard delivery.

It should be noted that despite the fact that even at the time of writing, the beta version of the 7th branch was declared stable, the author recommends using the 6th branch - offensive bugs and regressions are still present in the 7th branch (especially regarding examples and interactive documentation )

3. Relatives

In addition to the APL mentioned earlier, the closest relatives of J include languages ​​attributed to Arthur Whitney:

4. Literature

The documentation is available both from the offline distribution, and at :
  • Primer (Pri). The book by Eric Iverson (son of Kenneth Iverson), in which, with the help of small examples, the possibilities of the language are gradually revealed.
  • J for C Programmers (JfC). The book outlines all the basic and interesting features of the language. Examples in the first chapters are given with source code in C. One of the must-read books.
  • Learning J (LJ). Good introduction to the language.
  • Phrases (Phr). A collection of recipe phrases on a variety of topics authored by Kenneth Iverson, Roger Hui and others.
  • Dictionary (Dic). A small, consistent introduction to J. More formal than LJ, but also more concise. Translated into Russian by Konstantin Metlov. ( ).
  • Vocabulary (Voc). Dictionary J. Description of standard language functions with examples and comments. Translated into Russian by Konstantin Metlov. ( )

There are several books on the J. language at . For example:
  • Exploring Math. Posted by Kenneth Iverson. 135 pp. Introduction to mathematics and J. Recommended after reading the basics of the language.
  • Concrete Math Companion. Posted by Kenneth Iverson. 98 pages. The book deals with examples, arranged in chapters according to the book "Concrete Mathematics" by Knut, Graham and Potashnik.

In addition, the standard delivery has the so-called laboratory and demo examples - annotated examples of the main features of the language and its libraries. Among them are, for example, a laboratory for writing fuzzy logic operators in J, several introductory courses in the language, the game "life" and much more.

5. Place in the IT field

Ask the question: “Who benefits?”
Kenneth Iverson

At the time of writing, J occupies an honorable 5th place in the Euler project language ranking .

J is used in the most serious software companies. The list is available at We will name only a few of them: Hewlett Packard, Intel, Korea Telecom, Microsoft, Novell, SAP.

Further information and assistance is available at:

There is much less information in Russian, but there is still something:

The next article in the programming language J. The look of an amateur. Part 2. Tacit programming

Also popular now: