-

Your Ad Here
Your Ad Here

JOIN NOW

Friday, June 11, 2010

J programming language

The J programming language, developed in the early 1990s by Ken Iverson and Roger Hui, is a synthesis of APL (also by Iverson) and the FP and FL function-level languages created by John Backus.

To avoid repeating the APL special character problem, J requires only the basic ASCII character set, resorting to the use of digraphs formed using the dot or colon characters to extend the meaning of the basic characters available. Additionally, to keep parsing and the language simple, and to compensate for the lack of character variation in ASCII, many characters which might need to be balanced in other languages (such as [] {} "" `` or <>) are treated by J as stand alone tokens or (with digraphs) as part of a multi-character token.

Being an array programming language, J is very terse and powerful, and is most suited to mathematical and statistical programming, especially when performing operations on matrices. J is a MIMD language.

Like the original FP/FL languages, J supports function-level programming (also known as higher-order functional programming), via its tacit programming features (note that function-level programming is not the same as functional programming).

Unlike most languages that support object-oriented programming, J's flexible hierarchical namespace scheme (where every name exists in a particular locale) can be effectively used as a framework for both class-based and prototype-based object oriented programming.

J is not a von Neumann programming language, however, it is possible to use the von Neumann programming style.

J is a closed source albeit free-to-use software, available for Windows, GNU Linux and Mac OS X.


J permits point-free style and function composition. Thus, its programs can be very terse and are prone to code obfuscation.

The hello world program in J is

  'Hello, world!'

This implementation of hello world reflects the traditional use of J – programs are entered into a J interpreter session, and the results of expressions are displayed. It's also possible to arrange for J scripts to be executed as standalone programs, but the mechanisms for associating a script with the interpreter are system dependent. Here's how this might look on a unix system:

  #!/bin/jc
echo 'Hello, world!'
exit ''

Historically, APL used / to indicate the fold, so +/1 2 3 was equivalent to 1+2+3. Meanwhile, division was represented with the classic mathematical division symbol (the obelus, ÷), which was implemented by overstriking a minus sign and a colon (on both EBCDIC and ASCII paper terminals). Because ASCII in general does not support overstrikes in a device-independent way, and does not include a division symbol per se, J uses % to represent division, as a visual approximation or reminder. (This illustrates something of the mnemonic character of J's tokens, and some of the quandaries imposed by the use of ASCII.)

The following is a J program to calculate the average of a list of numbers:

No comments:

Post a Comment

free counters