Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
service
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
Freenet DSL
Who's Online
10 user(s) are online (10 user(s) are browsing encyclopedia)

Members: 0
Guests: 10

more...
partner

APL programming language

APL (for A Programming Language, or sometimes Array Processing Language) is an array programming language based on a notation invented in 1957 by Kenneth E. Iverson while at Harvard University. It originated in an attempt to provide consistent notation for the teaching and analysis of topics related to the application of computers. The notation was later used to describe the IBM System/360 machine architecture, a description much more concise and exact than the existing documentation and revealing several previously unnoticed problems. Then, a IBM_Selectric_typewriter typeball was made to write a linear representation of this notation. In 1964 a subset of the notation was implemented as a programming language.

Dr. Iverson published his notation in , with greatly increased expressive power.

=Overview=

Over a very wide set of problem domains (math, science, engineering, computer design, robotics, data visualization, actuarial science, traditional DP, etc.) APL is an extremely powerful, expressive and concise programming language, typically set in an interactive environment. It was originally created as a way to describe computers, by expressing mathematical notation in a rigorous way that could be interpreted by a computer. It is easy to learn but APL programs can take some time to understand. Unlike traditional structured programming languages, code in APL is typically structured as chains of monadic or dyadic function (programming)s and Operators acting on arrays. Because APL has so many nonstandard primitives (functions, operators, or features built into the language and indicated by a single symbol or a combination of a few symbols), APL does not have function or operator precedence. The original APL did not have control flows (loops, if-then-else), but the array operations it included could simulate structured programming constructs. For example, the iota function (which yields an array from 1 to N) can simulate for-loop Iteration. More recent implementations of APL generally include explicit control structures, so that data structure and control-flow structure can be more clearly separated.

The APL environment is called a workspace . In a workspace the user can define programs and data, i.e. the data values exist also outside the programs, and the user can manipulate the data without the necessity to define a program, for example:

:N leftarrow 4 5 6 7

Assign the Vector (spatial) values 4 5 6 7 to N.

:N+4,!

Add 4 to all values (giving 8 9 10 11) and Print them (absence of the assignment arrow means show )

:+/N,!

Print the sum of N, i.e. 22

The user can save the workspace with all values, programs and execution status. In any case, the programs are usually not compiled language but interpreted language. A commercial compiler was brought to market by STSC (now Manugistics).

APL is well-known for its use of a set of non-ASCII symbols that are an extension of traditional arithmetic and algebraic notation. These cryptic symbols, some have joked, make it possible to construct an entire air traffic control system in two lines of code. Indeed, in some versions of APL, it is theoretically possible to express any computable function in one expression, that is in one line of code. You can use the other line for I/O, or constructing a GUI. Because of its condensed nature and non-standard characters, APL has sometimes been termed a write-only language , and reading an APL program can at first feel like decoding an alien tongue. Because of the unusual character set, many programmers used special APL computer keyboards in the production of APL code. Nowadays there are various ways to write APL code using only ASCII characters. Indeed most if not all modern implementations use the standard keyboard, displaying APL symbols by use of a particular font.

Advocates of APL claim that the examples of write-only code are almost invariably examples of poor programming practice or novice mistakes, which can occur in any language. APL has perhaps had an unusually high percentage of users who are subject-matter experts who know some APL, rather than professional programmers who know something about a subject.

Iverson designed a successor to APL called J programming language which uses ASCII natively . So far there is only a single source of J implementations: http://www.jsoftware.com/ Other programming languages offer functionality similar to APL. [http://www.aplusdev.org/ A+] is an open source programming language with many commands identical to APL.

=Examples=

Here s how you would write a program that would sort a word list stored in matrix X according to word length:

X[X+. ;]

Here s a program that finds all prime numbers from 1 to R:

:left(sim R in R circ . imes R ight)/R leftarrow 1 downarrow iota R

Here s how to read it, from right to left:

#iota,! creates a vector containing integers from 1 to R (if R = 6 at the beginning of the program, iota R,! is 1 2 3 4 5 6) #Drop first element of this vector (downarrow function), i.e. 1. So 1 downarrow iota R is 2 3 4 5 6 #Set R to the vector (leftarrow, assignment primitive) #Generate outer product of R multiplied by R, i.e. a matrix which is the multiplication table of R by R (circ . imesfunction) #Build a vector the same length as R with 1 in each place where the corresponding number in R is in the outer product matrix (in, set inclusion function), i.e. 0 0 1 0 1 #Logically negate the values in the vector (change zeros to ones and ones to zeros) (sim, negation function), i.e. 1 1 0 1 0 #Select the items in R for which the corresponding element is 1 (/,! function), i.e. 2 3 5

=Calculation=

APL was unique in the apparent speed with which it could perform complex matrix operations. For example, a very large matrix multiplication would appear to take only a few seconds on a machine which was much less powerful than those today. There were some technical and other economic reasons for this advantage:

  • Commercial interpreters delivered highly-tuned linear algebra library routines.
  • Very low interpretive overhead was incurred per-array—not per-element.
  • APL response time compared favorably to the runtimes of early optimizing compilers.
  • A widely cited paper The APL Machine perpetuated the myth that APL made pervasive use of execution became commercially available, APL programs ported with little extra effort spent re-optimizing low level details.

    =Terminology=

    APL makes a clear distinction between functions and operators . Functions take values (variables or constants or expressions) as arguments, and return values as results. Operators take functions as arguments, and return related, derived, functions as results. For example the sum function is derived by applying the reduction operator to the addition function. Applying the same reduction operator to the ceiling function (which returns the larger of two values) creates a derived maximum function, which returns the largest of a group (vector) of values. In the J language, Iverson substituted the terms verb and adverb for function and operator .

    APL also identifies those features built into the language, and represented by a symbol, or a fixed combination of symbols, as primitives . Most primitives are either functions or operators. Coding APL is largely a process of writing non-primitive functions and (in some dialects of APL) operators. However a few primitives are considered to be neither functions nor operators, most noticeably assignment.

    =Character set=

    APL has always been criticized for its choice of a unique, non-standard character set. The fact that those who learn it usually become ardent adherents shows that there is some weight behind Iverson s idea that the notation used does make a difference. In the beginning, there were few terminal devices which could reproduce the APL character set — the most popular ones employing the IBM Selectric print mechanism along with a custom type element. With the popularization of the Unicode standard, which contains an APL character set, the eternal problem of obtaining the required particular fonts seems poised to go away.

    = APL symbols and keyboard layout=

    Note the mnemonics associating an APL character with a letter: question mark on Q , power on P , rho on R , base value on B , eNcode on N , modulus on M and so on. This makes it easier for an English-language speaker to type APL on a non-APL keyboard providing one has visual feedback on your screen.

    All APL symbols are present in Unicode: It may be required to significantly reconfigure your browser in order to display Unicode fonts.

  • See also IBM 3270 Computer keyboard layout for APL[http://publib.boulder.ibm.com/infocenter/pcomhelp/topic/com.ibm.pcomm.doc/kbd_reference05.htm#FIGTYPE1]
  • =Usage=

    APL has long had a small but fervent user base. It has been particularly popular in financial and insurance applications, in simulations, and in some mathematical applications. But APL has been used in a wide variety of contexts and for many and varied purposes.

    =Standardization=

    APL has been standardized by the American National Standards Institute working group X3J10 and International Organization for Standardization/International Electrotechnical Commission Joint Technical Committee 1 Subcommittee 22 Working Group 3. The Core APL language is specified in ISO 8485:1989, and the Extended APL language is specified in ISO/IEC 13751:2001.

    =Quotes=

  • APL, in which you can write a program to simulate shuffling a deck of cards and then dealing them out to several players in four characters, none of which appear on a standard keyboard.
  • David Given
  • APL is a mistake, carried through to perfection. It is the language of the future for the programming techniques of the past: it creates a new generation of coding bums.
  • Edsger Dijkstra, 1968
  • By the time the practical people found out what had happened; APL was so important a part of how IBM ran its business that it could not possibly be uprooted.
  • Micheal S. Montalbano 1982 (see [http://ed-thelen.org/comp-hist/APL-hist.html A Personal History of APL])
  • =Awards=

    There is an annual award for contributions to APL, the Iverson Award named after the language s creator.

    = See also=

  • IBM 1130: APL 1130 was an early implementation (circa 1970) of APL on the IBM 1130
  • K programming language: an alternative APL successor, by Arthur Whitney
  • Nial
  • = References =

  • A Programming Language (1962), by Kenneth E. Iverson
  • A formal description of SYSTEM/360 , IBM Systems Journal 3:3, New York: 1964
  • History of Programming Languages , chapter 14
  • = External links to articles =

    *[http://www.research.ibm.com/journal/sj/032/falkoff.pdf A Formal Description of SYSTEM/360 ] (1964 article by Adin D. Falkoff, Kenneth E. Iverson, Edward H. Sussenguth) *[http://www.slac.stanford.edu/pubs/slacreports/slac-r-114.html An APL Machine ] (1970 Stanford doctoral dissertation by Philip Abrams) *[http://www.research.ibm.com/journal/rd/174/ibmrd1704F.pdf The Design of APL ] (1973 article by Adin D. Falkoff and Kenneth E. Iverson) *[http://www.research.ibm.com/journal/sj/304/ibmsj3004C.pdf The IBM Family of APL Systems ] (1991 article by Adin D. Falkoff) *[http://elliscave.com/APL_J/IversonAPL.htm A Personal view of APL ] by Kenneth E. Iverson

    = External links =

    *[http://www-306.ibm.com/software/awdtools/apl/ APL2 available from IBM] *[http://www.users.cloud9.net/~bradmcc/APL.html APL - A Programming Language] *[http://www.rexswain.com/aplinfo.html Rex Swain s APL info] *[http://www.acm.org/sigs/sigapl/ SIGAPL Home Page] *[http://www.apl2c.de/home/ APL2C Compiler] *Sam Sirlin s [http://home.earthlink.net/~swsirlin/apl.faq.html APL FAQ] (Frequently Asked Questions list) *[http://www.classiccmp.org/bitsavers/pdf/ibm/apl/ Scanned manuals for early APL implementations] (APL 360 and APL 1130) *[http://ed-thelen.org/comp-hist/APL-hist.html A Personal History Of APL] by Micheal S. Montalbano

    =Special characters=