# Software Engineers Handbook/Language Dictionary/J
## J

J is not Java. It is an ASCII decendant of APL. Here is the wikipedia entry.
The software is free as of this writing, and available at the J software page

### Type

J is an array oriented functional language.

### Execution Entry Point

The concept of an entry point doesn't really apply in J. The program itself is the entry point.

### General Syntax

Statements in J
J statements are terminated by the newline character. For example

### Comments

J comments are introduced by the psuedo-token NB. and continue until the end of line. Block comments are not provided, but textual literals may be used in that role. For example:
Note that a single right parenthesis on a line by itself ends a multi-line definition.

### Variable Declarations

Variables are declared by specifying their definition. Literal numeric arrays may be introduced by placing spaces between the numbers. Literal character arrays may be introduced by placing multiple characters between single quotes
3 4 6 8
Hello World!

### Method Declaration/Implementation

There are two definition words in J.
implements a definition with global scope.
implements a definition with local scope.
However, note that in the context of classes and objects, global scope really means class scope or object scope. The general term for "a class or object" in J is "locale" (note the slight spelling difference from "local"). Most methods are implemented as J verbs, which have their arguments made available in implicitly defined array named y. (the period is a part of the name). This can be unpacked into a sequence of local variables by using a character array literal naming those variables as the left argument of =.

### Scope

See Variable Declarations

### Conditional Statements

Because J is an array oriented language, most J programmers use data selection to implement conditional logic. While this is not a traditional feature of most languages, SQL programmers quite often use similar techniques.
However, J also offers more traditional if. statements within the body of defined verbs.
These conditional words are not themselves part of the statement syntax, and so may be spread across multiple lines.

### Looping Statements

Because J is an array oriented language, every operation is capable of looping over an arbitrarily dimensioned arrays. Thus, looping can happen implicitly within any expression.
will loop over all appropriate values, as long as the definitions of x and y conform.
12 103 1004
This mechanism may be configured by specifying the rank of an operation, and the double quote character is used in this role (the double quote character does not delimit a string in J, and in general double quotes are used singly, not in pairs).
However, within the body of defined verbs, more traditional control words are available much in the fashion of conditional statements
In most cases you should use J's implicit looping. The exception is when not all data is knowable at one time, for example while servicing IO. However, even there, it might be wise to use J's event handling rather than an explicit loop.

### Output Statements

For many purposes, no explicit output statements are needed. J is usually used in a calculator mode where results are displayed implicitly.
However, file output is also possible, using the notation 1!:2 (This may be thought of as library 1, entry point 2). Typically, this will be assigned a mnemonic name:
J uses its own numbering system output descriptors, and standard output is descriptor 2. (Likwise, file read is 1!:1 and standard input is descriptor 1.)
In the general context of file io, newlines must be specified explicitly, but with standard output always includes an implicit newline at the end. Under unix, write to /dev/tty to avoid implicit newlines.
Note that the left caret does not represent redirection and instead represents treating the entire array '/dev/tty' as a single item rather than as a sequence of characters.

### Containers

All J nouns (data) are arrays with some number of dimensions (at least 0). The left caret is used to encapsulate one of these arrays. This operation is called boxing, which reflects the way these results are displayed.

### Algorithms

Some rudimentary algorithms are posted at http://www.jsoftware.com/books/help/phrases/contents.htm
As a general rule, algorithms are what people implement using this language (or, indeed, any language), so this is an open-ended topic

### Garbage collection

Garbage collection is automatic.

### Physical Structure

J programs typically use the .ijs extension. Class definitions usually use .ijc. Dynamically linked libraries use whatever the operating system uses. Other extensions are possible.

### Tips

* Start small, and try a few things out. Don't study too much
without trying things out. Don't try too many things without spending some time studying. Make sure you spend plenty of time doing other things.
* Keep the list of operations with you as you start programming.

### Web References

* The J software page
* The wikipedia entry contains the list of operations.

### Books and Articles

A number of books are available at the J software publications page.
These range in coverage from beginner through advanced. Many are free downloads. Some must be purchased (for example, with a link to the book at amazon.com).