J (a programming language)

1 - I can do better 2 - Jury's out 3 - Pretty darn good 4 - Splendiferous 5 - Awesometastic by 8 people | Log in to rate

Ranked #1,843 in Tech & Geek, #42,758 overall

A computational notation.

J is usually called a programming language, and so it is.  Yet, J is closer to a way of thinking.  It has a grammatical flow, the clarity of mathematics, and the empirical qualities of execution on computer.  (OK, I'll admit, it also looks like swearing in a comic strip!)

"What the heck is that, and why would anybody want to try to read or write it?"  That's the stereotypical reaction that can be expected on first encounter with J.  Many people familiar with, or even fluent in, various computer languages may have that reaction.  Literacy in J might be as easily gained by somebody who as never programmed before as somebody who has many habits to overcome..  

Why might you wish to know J?  Because what can be succinctly expressed in J is astonishing, that is why.  Here is a thing of beauty.  In the words of Norman Thompson: "J is a computer language which is remarkable for the way in which it allows technical instructions for computing to be expressed with great conciseness using constructs and syntax which closely mirror those of natural language."

This computer language has, for me, restored the sense of "the computer" as a tool in my hands.  I have enjoyed the benefits of computer-as-appliance, the paradigm that has become all but ubiquitous, but I have tired of having rigid interfaces standing between me and the realm of possibility.  True, any programming language could give me access to that wonderland, but tools differ in important ways.

When it comes to such differences, J is really different.  This is not yet another programming language that is more or less like Cobol, Fortran, Basic, Pascal, C, Java, Python, Ruby, etc.

As you approach J, let me assure you of this:

-- It is fun to learn, and some great stuff is very easy.

-- It is hard to learn, in a variety of ways.

-- It is easy to use, to whatever degree you have learned it.

-- It is well worth learning.  Overcoming the hard parts has a big payoff.

The main sources for J programming. 

J Software home page
The main site for J information. J Software makes the only implementation of J at this time. Their J programming environment is available for download and use at no charge!
Getting Started
If you're just getting started looking at J, look here.
Download J for Windows, Linux, or Macintosh
Here is where to actually download the software that lets you do things in J.
J Programming forum
As you get into reading and writing J, this forum is where the best discussion can be found. Top-notch J programmers provide accurate, thoughtful replies to questions at every skill level.
Oleg's J page
Oleg Kobchenko has a particularly useful webpage devoted to J. Lots of good stuff here for J programming at intermediate to advanced levels.

Good, great, and amazing things about J 

  • The J console session provides immediate results from each line entered.
  • Quite often, a single line of code counts as a complete J program.
  • Collections of related data are flexibly managed as arrays.
  • Only rarely do loops need to be specified. Normally, looping is built in to the way functions are applied to arrays.
  • Functions (known as verbs) are first class objects.
  • A number may be represented as bit, integer, fraction, complex, and extended precision integer. Conversion is automatic and dynamic.
  • Producing results with extended precision is easy. For example, the following J code calculates a full hundred digits of the square root of two:
    <.@%: 2x*10x^200
  • Object-oriented programming is easy and straightforward, without being required.
  • Programming may be done in the powerful (but challenging) function level involving tacit definition.
  • Programming may be done in the familiar imperative (von Neumann) programming style, when desired.

Thinking about what matters. 

"If you stick with it, J won't just help the way you code, it'll help the way you think." -- Henry Rich

High-level programming languages are those that allow computation to be specified with little or no reference to the computational equipment. Array programming languages, including J, go further by making it easy to specify computation without referring to the computational processes involved with managing multiple related values. (Database languages have similar power.)

The advantage of high-level programming is that it is far easier to work in terms of broader abstractions. Programming can occur at the conceptual level. Writing good J code is rather like specifying concepts in terms of more basic concepts. Software analysis and design can be rendered much more immediately into code.

The primitives in J are disconcerting in their departure from English. (This may be less annoying to the billions of people who don't speak English, mind you.) It is possible to associate words (English or otherwise) to those primitives, so it is not necessary to work with the core primitives themselves. Some such associations are standard, e.g. "each" is predefined as a synonym for &.> (which can be read "under open").

It turns out, however, that the J primitives, which are mostly two-character combinations (dyads), make for code that is more readable than what occurs if a familiar word is substituted for each. In their native form they are so small that as they occur together their relationships in combination are more easily seen. The symbolic quality of the primitives not only encourages programming to occur in conceptual terms, it provides the terms in which the concepts may be expressed.

J in action 

A guided tour through a mathematical idea.

Dan Bron wrote a little essay on exponentiation that shows how J facilitates solving the same problem at several levels of generalization. Here the J language and the mathematical topic are simultaneously explored. It gives a good sense of how solving problems in J goes hand in hand with thinking through the math.

Coding in J 

An example worth checking out.

To see a fine example of J coding, I suggest a column written by Eugene McDonnell, "Stumping the Rocket Scientist." In it Eugene shows, step by step, how he begins with a description of the problem, moves through writing something that works, then makes refinements that result in completed code.

The way it is written remind me of the calls to "show your work" in math classes. Indeed, as Eugene shows his work you'll see that coding in J and solving math problems can be one and the same.

The math in that article is fairly simple, and one need not even understand most of it to get a good idea of what J programming is like, both as finished product (the code that gets written) and as a process of writing.

Here are some J basics that can be good to know as your read it:

>: greater than or equal to
<: less than or equal to
% divided by (so, one divided by three is 1%3)
* multiplied by (so, six times four is 6*4)
_ negative numbers are prefixed with _ instead of -
+/ sum series (capital sigma, in conventional math)
=. assignment (name on left means value on right)

The article itself appears here:

http://www.jsoftware.com/jwiki/Doc/Articles/Play134

For those who just want to see what some J code looks like, here is the completed program. It is two nouns and a verb:

g =. 4 2 $ _25 83.3333 _12.5 4.16667 0 333.333 39.5833 _416.667
h =. 100r6 * 2.375
Rtg=. [: +/ 0: >. h"_ <. g"_ p. }. % {.


Unless you already are an expert at J, that doesn't count as a spoiler -- does it?

Books of interest 

Array languages, function level programming, etc.

Ranging from popular to advanced, these books are likely to interest those who appreciate J.

Fractals Visualization and J

List Price: $80.00

Network Performance Analysis: Using the J Programming Language

List Price: $99.00

Usually ships in 24 hours

Geometric Programming for Computer Aided Design

List Price: $150.00

Usually ships in 24 hours

Visionary genius in the creation of J. 

Kenneth Iverson and Roger Hui

Kenneth E. Iverson had the idea that we can think more clearly by simplifying the way we make statements about those things. At the time, as a young academic, he was mostly thinking about arrays, but he was thinking along the lines of symbolic representation that characterizes the whole history of mathematical advancement. When he combined his appreciation for clarity in pure math with the technology of the digital computer, the computer became a far better medium in which abstractions can be manipulated. He is justly celebrated for his creation, APL, the influence of which reaches far wider than the use of the language itself.

Roger Hui appreciated the extraordinary qualities of APL, and how starkly it differed from the other ways of accomplishing things with a computer. With his personal combination of mathematical brilliance and utter fixation, he honed his skill at APL into mastery. As Kenneth Iverson was thinking about what language would go beyond the limitations he saw in APL, Roger Hui was there to put those ideas into code. Together they forged a new tool. Mr. Hui continues to refine and extend it, being a full partner in its development.

Other individuals have contributed notably to the creation of J, of course. I'll not attempt (as a complete outsider) to give credit where credit is due. Let me instead emphasize that the products of efforts that are driven by extraordinary vision and aptitude differ from the normal pattern of products from anonymous institutional settings. Yes, IBM produced APL, but it could not have done so without Mr. Iverson's visionary role.

Ilya Prigogine argues that when the work of a scientist or an artist changes how we think of our world, particulars of that personal contribution are integral to the new way of thinking. The notational advancements of J are advancements of abstraction, but they are not disconnected from the individuals who made it real.

Find out more! 

A very short introduction
One page of J examples, and a one-page overview of the language, by Keith Smillie.
Users tell about J in their own words
Among the many good stories here, don't miss the ones by Henry Rich and John Baker.
Hui on J
Roger Hui tells how J came to be. Highly recommended.
Iverson Anecdotes
Ken Iverson -- Quotations and Anecdotes
Learning J
An introductory book, available on the web or as a printable document. (It is also included with the standard J installation.) Roger Stokes is the author.
More Info on J
Last December James Hague wrote a blog entry about J, to which "skipcave" left this reply. It is well written and useful as an introduction.
The symbolic language of math
While not about J directly, consideration of standard mathematical symbolic representation applies to J both for comparison, and contrast.

Tips for the advanced beginner. 

Advice on learning J from John Randall of Rutgers University.

  • Avoid recursion, unless you are memoizing the results.
  • Learn to use the power conjunction, especially in the form f^:g^:_ .
  • Avoid small selections: use #~f whenever possible. I almost never use @. .
  • Rely on the J Phrases: they are both useful and instructive.
  • Begin defining with explicit form, and gradually mix in more tacit.

Why J? 

As a member of the APL family, the benefits of J are much the same.

"Great flexibility and speed is the true commercial foundation for APL. For with APL one can develop in direct contact with the users and involve them from the outset in the continual modification of the object of the development. Afterwards, as it continues to evolve, it is still the speed of development which makes APL a tool especially well adapted to changeable environments." -- Bernard Legrand

"[People choose APL] because it offers a very high level of abstraction, allowing us to very quickly turn ideas involving data manipulation into executable code. It is in the nature of APL to be used as an "executable specification language": APL is often used as much to discover the specification as to implement the system." -- Morten Kromberg, Dyalog Ltd.

"[Array-based programming languages] have several advantages over conventional von Neumann programming languages. [E]ven without use of Iverson's eye-wateringly terse notation, array-based programs are often many times shorter than equivalent programs written in conventional languages. The array-based paradigm and shape polymorphism often allow for radically different and dramatically simpler approaches to solving problems. ... [T]he array-based approach allows for the use of high-level tools not available in other languages, such as a general outer product operator. ... APL and its descendents have a proven track record of being useful to non-programmers." -- Miles Gould, University of Glasgow

Essays and articles 

Extreme Terseness
Stephen Taylor elaborates why J is a natural fit for Agile Programming (XP) approach. PDF file format.

Mathematics 

J is a mathematical notation. Conveniently, it happens to be executable on digital computers.

The roots of J lie in K. E. Iverson's work at Harvard University to improve mathematical notation. He found tensor theory to be particularly inspirational. Here are some extracts from Wikipedia that are suggestive of the connections between that area of math and the computational notation we call J:
________________________________________________________
In mathematics, a tensor is (in an informal sense) a generalized linear 'quantity' or 'geometrical entity' that can be expressed as a multi-dimensional array relative to a choice of basis of the particular space on which it is defined. The intuition underlying the tensor concept is inherently geometrical: as an object in and of itself, a tensor is independent of any chosen frame of reference. However, in the modern treatment, tensor theory is best regarded as a topic in multilinear algebra.
...
The rank of a particular tensor is the number of array indices required to describe such a quantity. For example, mass, temperature, and other scalar quantities are tensors of rank 0; but force, momentum and other vector-like quantities are tensors of rank 1. The novel aspects of tensor theory are seen from rank 2 onwards.

Rapid prototyping and evolutionary application design 

Mike Jenkins sums it up.

"The key aspect that APL, J, K, and Nial have is the ability to achieve a complex result as a sequence of functional transformations on data structures. Programming becomes the task of placing data into initial structures and transforming them by selecting the appropriate functions in the correct order. ... The hard part is to teach students how to solve problems with this functional paradigm. It requires the mental ability to hold the data structure in one's mind and to imagine how particular functions will transform it."

Mike Jenkins
Founder of NIal Systems Limited, designer of Q'Nial, Computer Science professor at Queen's University
May 12, 2008 post to comp.lang.apl

by 23skidoo

I am a student of complex adaptive systems. (more)

Explore related pages

Create a Lens!