Opentopia Directory Encyclopedia Tools

J programming language

Encyclopedia : J : JP : JPR : 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 functional programming languages created by John Backus (of FORTRAN, ALGOL, and BNF fame).

To avoid the problems faced by the special character set of APL, J requires only the basic ASCII character set, resorting to the use of dot and colon characters to extend the meaning of the basic characters available.

Being an array programming language, J is very terse and powerful, and is often found to be useful for mathematical and statistical programming, especially when performing operations on matrices.

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 hierarchichal namespace scheme (where every name exists in a particular locale) can be effectively used as a framework for both class-based and instance-based object oriented programming.

J is a non-von Neumann programming language that nevertheless allows the programmer to use von Neumann programming style when desired.

Note that the J programming language is not related to J++ (and its new version J#), a version of Java developed by Microsoft.

Examples

J is an extremely powerful language, and its programs can be very terse but even more cryptic.

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 ''
But many accomplished J programmers never resort to such mechanisms.

Here's a J program to calculate the average of a list of numbers:

avg =. +/ % #
avg 1 2 3 4
2.5
'#' - counts the number of elements in the string. '+/' - adds up all the elements in the string. '%' - divides the sum of the elements by the number of elements.

Now let's generate some random numbers and find the average:

a =. ?20$100
a
31 16 60 64 64 71 13 3 76 26 25 77 68 48 42 91 99 97 99 9
avg a
53.95

Here is an implementation of quicksort, from the J Dictionary:

sel=: adverb def 'x. # ['

quicksort=: verb define
if. 1 >: #y. do. y.
else.
(quicksort y. sel e=.y.  [Item Amend • Amend]
 }.  [Behead • Drop]
 }:  [Curtail •]

  

 "  Rank
 ".  [Do • Numbers]
 ":  [Default Format • Format]

 `  [Tie (Gerund)]
  
 `:  [Evoke Gerund]

 @  [Atop]
 @.  [Agenda]
 @:  [At]

 &  [Bond /] [Compose]
 &.  [Under (Dual)]
 &:  [Appose]


&.:  [Under]

 ?  [Roll • Deal]
 ?.  [Roll • Deal (fixed seed)]

  

 a.  [Alphabet]
 a:  [Ace (Boxed Empty)]
 A.  [Anagram Index • Anagram]

 b.  [Boolean /] [Basic]
 c.  [Characteristic Values]
 C.  [Cycle-Direct • Permute]

 d.  [Derivative]
 D.  [Derivative]
 D:  [Secant Slope]

 e.  [Raze In • Member (In)]
 E.  [• Member of Interval]
 f.  [Fix]

  

 H.  [Hypergeometric]
 i.  [Integers • Index Of]
 i:  [Integers • Index Of Last]

 j.  [Imaginary • Complex]
 L.  [Level Of]
 L:  [Level At]

 m. n.  [Explicit Noun Args]
 NB.  [Comment]
 o.  [Pi Times • Circle Function]

 p.  [Polynomial]
 p..  [Poly. Deriv. • Poly. Integral]
 p:  [Primes •]

  

 q:  [Prime Factors • Prime Exponents]
 r.  [Angle • Polar]
 s:  [Symbol]

 S:  [Spread]
 t.  [Taylor Coefficient]
 t:  [Weighted Taylor]

 T.  [Taylor Approximation]
 u. v.  [Explicit Verb Args]
 u:  [Unicode]

 x. y.  [Explicit Arguments]
 x:  [Extended Precision]
 _9:  to  9:  [Constant Functions]

See also

External links

  • [JSoftware]- Creators of J (currently free for all uses)
  • [Cliff Reiter]- Chaos, fractals and mathematical symmetries... in J
  • [Ewart Shaw]- Bayesian inference, medical statistics, and numerical methods, using J
  • [Keith Smillie]- Statistical applications of array programming languages, especially J
  • [John Howland]- Research on parallelization of array programming languages, especially J
  • [J Forum Archives]- Discussion of the language

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.


Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: