J is my main programming language for Project Euler and for personal use at work. I have never come across the best language for handling arrays, and the silent programming paradigm is useful and makes you think as soon as you hang it. (Useful, because it really makes you think.) It is difficult to achieve the level of knowledge at the initial level in this language, and reading the code of other people is an intellectually disciplined activity, but perseverance has big gains due to language strength, flexibility and conciseness.
However, the reason I reserve it for personal use at work is because (1) no one else uses it at work, (2) the learning curve is steep enough, so it’s not wise for me to ask my colleagues about volume, pick it up and (3) the fact that you can create complex programs in one line of code makes it difficult to read a line of code, especially if you do not write it yourself. (I expect to spend at least half an hour studying a line of code that uses ten or more statements, unless they are used in such a way that I fully understand the fundamental principles.)
Some examples of J functions:
1) Any function defined to work on a single number can be used to work with arrays of arbitrary rank. For example:
totient=: * -.@%@~.&.q: NB. Finding the totient of 10 totient 10 NB. Finding the totient of all numbers from 1 to 10 totient"0 (1+i.10)
This is exactly the same function, just working on the atoms (singleton components) of the 1xN input array. In the same way, you can take a function defined for working with ranks of two arrays (matrices) and apply it to any array of a higher rank, simply using the connection "(rank)".
2) You can take almost any theoretically reversible function in J and invert it by "iterating it backward". For example,
NB. Converts an array of binary digits to a decimal number (
estanford May 2 '10 at 2:06 p.m. 2010-05-02 14:06
source share