Array programming: Difference between revisions

Content deleted Content added
Array languages: this was a thesis
Citation bot (talk | contribs)
Alter: url. URLs might have been anonymized. Add: s2cid, authors 1-1. Removed proxy/dead URL that duplicated identifier. Removed access-date with no URL. Removed parameters. Some additions/deletions were parameter name changes. | Use this bot. Report bugs. | Suggested by Abductive | Category:Programming paradigms | #UCB_Category 44/113
Line 2:
In [[computer science]], '''array programming''' refers to solutions which allow the application of operations to an entire set of values at once. Such solutions are commonly used in [[computational science|scientific]] and [[engineering]] settings.
 
Modern programming languages that support array programming (also known as [[vector (computing)|vector]] or '''multidimensional''' languages) have been engineered specifically to generalize operations on [[scalar (computing)|scalar]]s to apply transparently to [[vector (geometric)|vector]]s, [[matrix (mathematics)|matrices]], and higher-dimensional arrays. These include [[APL (programming language)|APL]], [[J (programming language)|J]], [[Fortran 90]], Mata, [[MATLAB]], [[Analytica (software)|Analytica]], [[TK Solver]] (as lists), [[GNU Octave|Octave]], [[R (programming language)|R]], [[Cilk Plus]], [[Julia (programming language)|Julia]], [[Perl Data Language|Perl Data Language (PDL)]], and the [[NumPy]] extension to [[Python (programming language)|Python]]. In these languages, an operation that operates on entire arrays can be called a ''vectorized'' operation,<ref>{{cite journal |title=The NumPy array: a structure for efficient numerical computation |author=Stéfan van der Walt |author2=S. Chris Colbert |author3=Gaël Varoquaux |name-list-style=amp |journal=Computing in Science and Engineering |volume=13 |issue=2 |pages=22–30 |publisher=IEEE |year=2011 |doi=10.1109/mcse.2011.37|bibcode=2011CSE....13b..22V |arxiv=1102.1523 |s2cid=16907816 }}</ref> regardless of whether it is executed on a [[vector processor]], which implements vector instructions. Array programming primitives concisely express broad ideas about data manipulation. The level of concision can be dramatic in certain cases: it is not uncommon to find array programming language [[one-liner program|one-liners]] that require several pages of object-oriented code.
 
==Concepts of array==
The fundamental idea behind array programming is that operations apply at once to an entire set of values. This makes it a [[high-level programming language|high-level programming]] model as it allows the programmer to think and operate on whole aggregates of data, without having to resort to explicit loops of individual scalar operations.
 
[[Kenneth E. Iverson]] described the rationale behind array programming (actually referring to APL) as follows:<ref>{{cite journal |author= Iverson, K. E. |title= Notations as a Tool of Thought. |journal= Communications of the ACM |volume= 23 |issue= 8 |pages= 444–465 |year= 1980 |url= http://www.jsoftware.com/papers/tot.htm |access-date= 2011-03-22 |doi= 10.1145/358896.358899 |archive-url= https://web.archive.org/web/20130920071911/http://www.jsoftware.com/papers/tot.htm |archive-date= 2013-09-20 |url-status= dead |author-link= Kenneth E. Iverson |doi-access= free }}</ref>
{{quote|most programming languages are decidedly inferior to mathematical notation and are little used as tools of thought in ways that would be considered significant by, say, an applied mathematician.
The thesis is that the advantages of executability and universality found in programming languages can be effectively combined, in a single coherent language, with the advantages offered by mathematical notation. it is important to distinguish the difficulty of describing and of learning a piece of notation from the difficulty of mastering its implications. For example, learning the rules for computing a matrix product is easy, but a mastery of its implications (such as its associativity, its distributivity over addition, and its ability to represent linear functions and geometric operations) is a different and much more difficult matter.
Line 48:
In array languages, operations are generalized to apply to both scalars and arrays. Thus, ''a''+''b'' expresses the sum of two scalars if ''a'' and ''b'' are scalars, or the sum of two arrays if they are arrays.
 
An array language simplifies programming but possibly at a cost known as the ''abstraction penalty''.<ref>{{cite thesis|author=Surana P |title=Meta-Compilation of Language Abstractions. |year=2006 |url=https://dl.acm.org/doi/book/10.5555/1195058}}</ref><ref>{{cite web |last= Kuketayev |title= The Data Abstraction Penalty (DAP) Benchmark for Small Objects in Java. |url= http://www.adtmag.com/joop/article.aspx?id=4597 |access-date= 2008-03-17 |archive-url= https://web.archive.org/web/20090111091710/http://www.adtmag.com/joop/article.aspx?id=4597 |archive-date= 2009-01-11 |url-status= dead }}</ref><ref>{{Cite book |lastlast1= Chatzigeorgiou |last2= Stephanides |editor-last= Blieberger |editor2-last= Strohmeier |contribution= Evaluating Performance and Power Of Object-Oriented Vs. Procedural Programming Languages |title= Proceedings - 7th International Conference on Reliable Software Technologies - Ada-Europe'2002 |year= 2002 |pages= 367 |publisher= Springer |url= https://books.google.com/books?id=QMalP1P2kAMC&dqq=%22abstraction+penalty%22 |isbn= 978-3-540-43784-0 }}</ref> Because the additions are performed in isolation from the rest of the coding, they may not produce the optimally most [[algorithmic efficiency|efficient]] code. (For example, additions of other elements of the same array may be subsequently encountered during the same execution, causing unnecessary repeated lookups.) Even the most sophisticated [[optimizing compiler]] would have an extremely hard time amalgamating two or more apparently disparate functions which might appear in different program sections or sub-routines, even though a programmer could do this easily, aggregating sums on the same pass over the array to minimize [[Computational overhead|overhead]]).
 
====Ada====