What are some of J's unique features?

I came from the background of C, Fortran, Python, R, Matlab, and some Lisp, and I read a few things on Haskell. What are some neat ideas / examples in J or other languages ​​from the APL family that are unique and not implemented in more common languages? I am always interested to know what I am missing ...

+4
source share
3 answers

J has a very large set of operators that simplify the creation of complex programs without the need for a library search. It has extremely powerful array processing capabilities, as well as iterative constructs that make explicit control structures inconsequential for most purposes - so much so that I prefer to use tensor algebra to declare an explicit loop, because it is more convenient. J works in the interpreter, but a good J script can be as fast as a program written in compiler language. (When you take out explicit loops, the interpreter does not need to compose the contents of the loop each time it is executed.)

Another interesting feature of J is tacit programming. You can create scripts without explicit reference to the input variables, which allows you to express the idea solely in terms of what you intend to do. For example, I could define an average function as “summing terms in a list and dividing them by the number of entries in a list” as follows:

(+/ % #)

or I could make a script that slices into a 2D array and returns only row averages with averages greater than 10:

(10&<#])(+/%#)"1

There are many other neat things you can do with J; it is an executable form of mathematical notation. Ideas are easy to generalize, so you get great benefits from learning any aspect of the language.

+6
source

I think one of the most interesting aspects of J is that it is one of the few languages ​​other than von-neumann that are even remotely popular.

Umm. J mainstream? Well, yes, compared to other non-von Neumann languages! In fact, there are only very few languages ​​other than von-neumann, most of them live only in any candidate dissertation and have never been implemented, and those that were implemented usually have a user base of 1, even if it is. As a rule, they are considered successful if at least one of the users is not sitting on the same floor as the one who invented it.

In comparison, J is the main one. In particular, J is based on John Backus FP from his original Turing lecture, “Can programming be freed from von Neumann's style?” and this is AFAIK - the only working implementation. (I don't think Backus ever actually implemented FP, for example.)

+5
source

This may not be as straightforward as I do, but the main function I can think of for J is implicit typing. This creates a good level of abstraction over execution and memory management in order to focus on the data being processed.

Suppose you need to save a number:

 var1 =: 10 

And that’s all. An array?

 var2 =: 4 8 15 16 23 42 

Done. Oh, but wait, do you need to divide this by 3.7? Don't worry about casting, just go:

 var2 % 3.7 

Being spared the need to throw, manipulate and distribute is a tiny blessing.

+2
source

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


All Articles