Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
APL (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Design === Unlike traditionally structured programming languages, APL code is typically structured as chains of [[Unary operation|monadic]] or [[Binary operation|dyadic]] [[Function (computer programming)|functions]], and [[Higher-order function|operators]]<ref name="MicroAOL_Operators">{{cite web|last1=MicroAPL|title=Operators|url=http://www.microapl.co.uk/apl/apl_concepts_chapter5.html|website=www.microapl.co.uk|publisher=MicroAPL|access-date=January 12, 2015}}</ref> acting on [[array data type|arrays]].<ref>{{cite web|last1=Primitive Functions|title=Primitive Functions|url=http://www.microapl.co.uk/apl_help/ch_020_010_140.htm|website=www.microapl.co.uk/|access-date=January 1, 2015}}</ref> APL has many nonstandard ''primitives'' (functions and operators) that are indicated by a single symbol or a combination of a few symbols. All primitives are defined to have the same [[operator precedence|precedence]], and always associate to the right. Thus, APL is ''read'' or best understood from [[APL syntax and symbols#Syntax rules|right-to-left]]. Early APL implementations ({{circa|1970}} or so) had no programming loop [[control flow]] structures, such as <code>do</code> or <code>while</code> loops, and <code>if-then-else</code> constructs. Instead, they used array operations, and use of [[structured programming]] constructs was often unneeded, since an operation could be performed on a full array in one statement. For example, the <code>iota</code> function (<code>ΞΉ</code>) can replace for-loop [[iteration]]: ΞΉN when applied to a scalar positive integer yields a one-dimensional array (vector), 1 2 3 ... N. Later APL implementations generally include comprehensive control structures, so that data structure and program control flow can be clearly and cleanly 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 also manipulate the data without having to define a program.<ref>{{cite web|last1=Workspace|title=The Workspace|url=http://www.microapl.co.uk/apl/apl_concepts_chapter2.html|website=www.microapl.co.uk|access-date=January 1, 2015}}</ref> In the examples below, the APL interpreter first types six spaces before awaiting the user's input. Its own output starts in column one. {| class="wikitable" |- | width="240pt" | <syntaxhighlight lang="apl"> n β 4 5 6 7</syntaxhighlight> | Assigns [[coordinate vector|vector]] of values, {4 5 6 7}, to variable <code>n</code>, an array create operation. An equivalent yet more concise APL expression would be <syntaxhighlight lang="apl" inline>n β 3 + β³4</syntaxhighlight>. Multiple values are stored in array <code>n</code>, the operation performed ''without formal loops or control flow language''. |- | <syntaxhighlight lang="apl"> n 4 5 6 7</syntaxhighlight> | Display the contents of <code>n</code>, currently an array or vector. |- | <syntaxhighlight lang="apl"> n+4 8 9 10 11</syntaxhighlight> | 4 is now added to all elements of vector <code>n</code>, creating a 4-element vector {8 9 10 11}.<br/> As above, APL's interpreter displays the result because the expression's value was not assigned to a variable (with a <code>β</code>). |- | <syntaxhighlight lang="apl"> +/n 22</syntaxhighlight> | APL displays the sum of components of the vector <code>n</code>, i.e., <code>22 (= 4 + 5 + 6 + 7)</code> using a very compact notation: read +/ as "plus, over..." and a slight change would be "multiply, over..." |- | <syntaxhighlight lang="apl"> m β +/3+β³4 m 22</syntaxhighlight> | These operations can be combined into one statement, remembering that APL evaluates expressions right to left: first <syntaxhighlight lang="apl" inline>β³4</syntaxhighlight> creates an array, <syntaxhighlight lang="apl" inline>[1,2,3,4]</syntaxhighlight>, then 3 is added to each component, which are summed together and the result stored in variable <code>m</code>, finally displayed. In normal mathematical notation, it is equivalent to: <math>\displaystyle m= \sum\limits_{i=1}^4 (i+3)</math>. Recall that mathematical expressions are not read or evaluated from right-to-left. |} The user can save the workspace with all values, programs, and execution status. APL uses a set of non-[[ASCII]] symbols, which are an extension of traditional arithmetic and algebraic notation. Having single character names for single instruction, multiple data ([[Single instruction, multiple data|SIMD]]) vector functions is one way that APL enables compact formulation of algorithms for data transformation such as computing [[Conway's Game of Life]] in one line of code.<ref>{{cite web |url=http://catpad.net/michael/apl |title=example |publisher=Catpad.net |access-date=June 17, 2013 |url-status=dead |archive-url=https://web.archive.org/web/20130708114840/http://catpad.net/michael/apl/ |archive-date=July 8, 2013}}</ref> In nearly all versions of APL, it is theoretically possible to express any computable function in one expression, that is, in one line of code.{{citation needed|date=May 2021}} Due to the unusual [[character set]], many programmers use special [[computer keyboard|keyboards]] with APL keytops to write APL code.<ref>{{cite web|title=Entering APL Symbols |url=http://www.microapl.co.uk/apl/introduction_chapter2.html |website=www.microapl.co.uk|access-date=January 1, 2015}}</ref> Although there are various ways to write APL code using only ASCII characters,<ref>{{cite web |last1=Dickey |first1=Lee |url= http://www.math.uwaterloo.ca/apl_archives/apl/translit.schemes |title=A list of APL Transliteration Schemes |archive-url=https://web.archive.org/web/20060929174125/http://www.math.uwaterloo.ca/apl_archives/apl/translit.schemes |archive-date=2006-09-29 |date=1993}}</ref> in practice it is almost never done. (This may be thought to support Iverson's thesis about [[Linguistic relativity|notation as a tool of thought]].<ref>{{cite journal |url=http://www.jsoftware.com/papers/tot.htm |last1=Iverson |first1=K.E. |title=Notation as a Tool of Thought |archive-url=https://web.archive.org/web/20130920071911/http://www.jsoftware.com/papers/tot.htm |archive-date=2013-09-20 |journal=Communications of the ACM |volume=23 |pages=444β465 |date=August 1980|issue=8 |doi=10.1145/358896.358899}}</ref>) Most if not all modern implementations use standard keyboard layouts, with special mappings or [[input method editor]]s to access non-ASCII characters. Historically, the APL font has been distinctive, with uppercase italic alphabetic characters and upright numerals and symbols. Most vendors continue to display the APL character set in a custom font. Advocates of APL{{Who|date=March 2015}} claim that the examples of so-called ''write-only code'' (badly written and almost incomprehensible code) are almost invariably examples of poor programming practice or novice mistakes, which can occur in any language. Advocates also claim that they are far more productive with APL than with more conventional computer languages, and that working software can be implemented in far less time and with far fewer programmers than using other technology.{{citation needed|date=December 2019}} They also may claim that because it is compact and terse, APL lends itself well to larger-scale software development and complexity, because the number of lines of code can be reduced greatly. Many APL advocates and practitioners also view standard programming languages such as [[COBOL]] and [[Java (programming language)|Java]] as being comparatively tedious. APL is often found where time-to-market is important, such as with trading systems.<ref>{{cite web |last1=Batenburg |title=APL Efficiency |url=http://www.ekevanbatenburg.nl/PRVAPL.HTML |website=www.ekevanbatenburg.nl |access-date=January 1, 2015}}</ref><ref>{{cite web |last1=Vaxman |title=APL Great Programming |url=http://www.vaxman.de/publications/apl_slides.pdf |archive-url=https://ghostarchive.org/archive/20221009/http://www.vaxman.de/publications/apl_slides.pdf |archive-date=2022-10-09 |url-status=live |website=www.vaxman.de |access-date=January 1, 2015}}</ref><ref>{{cite journal |last1=Janko |first1=Wolfgang |title=Investigation into the efficiency of using APL for the programming of an inference machine |journal= ACM SIGAPL APL Quote Quad|date=May 1987 |volume=17 |issue=4 |pages=450β456 |doi=10.1145/384282.28372}}</ref><ref>{{cite web |last1=Borealis |title=Why APL? |url=http://www.aplborealis.com/whyapl.html |website=www.aplborealis.com |access-date=January 1, 2015}}</ref>
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
APL (programming language)
(section)
Add topic