📜 ⬆️ ⬇️

Programming language J. Amateur look. Part 1. Introduction

Dijkstra: How do you write down 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 languages ​​APL and J)


1. Quick start



Before APL got its name, it was called “Iverson notation”. However, Ken believed that the name should just sound like “Notation”. Indeed, we do not say “the grass of God”, we simply say “grass”.
Paul Berry

')
Distinctive features of the programming language J can be called:

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 introductions and tutorials J:

mean =: +/%# 

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

The expression “+ /% #” literally means the following sequence of actions:


Call this verb as follows:

  mean 1 2 3 4 2.5 

where 2.5 is the result of computing the average on an array of integers from 1 to 4. Note that in the examples with a large indentation, an expression is indicated, with a smaller one, the result of the calculation.

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

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


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

One of the greatest strengths of J is its graphics subsystem. Examples are available at http://www.jsoftware.com/jwiki/Studio/Gallery

The official site of language developers and the most popular (and, concurrently, and only) translator of the J language is http://www.jsoftware.com . The key personalities involved in creating the language are: Kenneth Iverson, died in 2004, and Roger Hui.

In fairness it is necessary to mention jsj - limited in capabilities of the online interpreter J in Javascript. And J & + - a subset of the language J

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

Currently available in both the 6th and 7th versions. The more stable 6th version of the GUI for Linux is made using Java. In the 7th version, the graphical interface is fully cross-platform and based on gtk. However, this version is not yet completely user-friendly, and in beta 8 of the version, the interface has been redone again on Qt

For development on J, you can use both the native development environment and Emacs (the mode for editing source codes on J is located at http://j-mode.sourceforge.net ).

Until recently, J was distributed as a freeware application, and source codes were distributed under a commercial license. Now the source code for version 7 is open under the GPL3 license (see http://www.jsoftware.com/source.htm ). In addition, there are no licensing restrictions on the native implementations of translators J.

2. Past and Present


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


The direct ancestor of J is the APL language (APL stands for “A Programming Language”). Moreover, the author of the one and the other is the same person - Kenneth Iverson (stories from the life of Kenneth (the so-called "kenekdoty")) can be found at http://keiapl.info/anec/ . Epigraphs to this article taken from there). An interesting feature of the APL was the use of special characters in the language that are absent on the keyboards we are used to. Special APL compatible keyboards were also released. And, despite the venerable age (the year of the discovery of the APL - 1964), this language is still being developed and used.

The time of occurrence of the language J is 1990 year. One of the main differences between the new language and APL was the use of standard ASCII characters in the naming of standard constructions.

One of the early (1994) implementations of the language interpreter can be found at http://keiapl.org/archive/j7.tar.gz . Prior to the discovery of the source codes of the modern 7th version of the language, this was the last available version of the source codes of the J language.

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

Modern versions of the J language are changing 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, there is an active development of the next version of the interpreter J-7.0. This version has no conceptual language changes. However, quite significant changes affected the infrastructure of the translator. Note some of them:


It should be noted that, although the beta of the 7th branch was declared stable at the time of writing the article, the author recommends using the 6th branch - in the 7th there are still offensive bugs and regressions (especially in the examples and interactive documentation ).

3. Relatives


In addition to the previously mentioned APL, the closest relatives of J include languages ​​written by Arthur Whitney:


4. Literature


Documentation is available from both the offline distribution and http://jsoftware.com/help/index.htm :


On the page http://www.jsoftware.com/jwiki/Books there are several books devoted to the language J. For example:


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

5. Place in the IT field


Ask the question: “Who benefits from this?”
Kenneth Iverson


At the time of this writing, J is in 5th place in the ranking of the languages ​​of the Euler project http://projecteuler.net/languages .

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

Additional information and assistance is available at:


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


Next article in the Cycle of Programming Language J. Amateur Look. Part 2. Tacit Programming

Source: https://habr.com/ru/post/198052/


All Articles