Comparison of programming languages (array)


This comparison of programming languages compares the features of array data structures or matrix processing for over 48 various computer programming languages.

Syntax

Array dimensions

The following list contains syntax examples of how to determine the dimensions.
Note particularly that some languages index from zero while others index from one. At least since Dijkstra's famous essay, zero-based indexing has been seen as superior, and new languages tend to use it.
LanguagesSizeFirstLast
Ada
ALGOL 68

etc.


etc.



etc.
APL
AWK
C#, Visual Basic.NET, Windows PowerShell, F#
CFML
Ch
Common Lisp
D
Fortran
Go
Haskell
ISLISP
Cobra, D, Haxe, Java, JavaScript, Scala
J
Julia
Lingo
LiveCode

Lua
Mathematica

MATLAB, GNU Octave
Nim
Oberon
Object Pascal

Objective-C
OCaml
Perl
PHP$$
Python
R
Raku@
Red
Ruby


Rust
S-Lang
Scheme
Smalltalk

Swift
Visual Basic
Wolfram Language

Xojo
XPath/XQuery

Indexing

The following list contains syntax examples of how to access a single element of an array.
FormatLanguages
ALGOL 58, ALGOL 60, ALGOL 68, AWK, Modula, Pascal, Object Pascal, C#, S-Lang
APL
ActionScript, C, CFML, Ch, Cobra, C++, D, Go, Haxe, Java, JavaScript, Julia, Lingo, Lua, Nim, Objective-C, Perl, Python, R, Ruby, Rust, Swift
Perl, PHP, Windows PowerShell, XPath/XQuery
Raku
Ada, ALGOL W, BASIC, COBOL, Fortran, RPG, GNU Octave, MATLAB, PL/I, Scala, Visual Basic, Visual Basic.NET, Xojo
XPath/XQuery
OCaml
F#
Red
Haskell
XPath/XQuery
Scheme
Common Lisp
ISLISP
Mathematica, Wolfram Language
Smalltalk
Objective-C

Slicing

The following list contains syntax examples of how a range of element of an array can be accessed.
In the following table:
  • - the index of the first element in the slice
  • - the index of the last element in the slice
  • - one more than the index of last element in the slice
  • - the length of the slice
  • - the number of array elements in each
FormatLanguages
ALGOL 68, Julia
APL
Python, Go
Pascal, Object Pascal, Delphi, Nim
Windows PowerShell
Perl
Ruby
Red
Ada
Fortran, GNU Octave, MATLAB
Mathematica, Wolfram Language
S-Lang
F#
Haxe, JavaScript, Scala
CFML
PHP
Common Lisp
ISLISP
OCaml
Objective-C

Array system cross-reference list

Programming languageDefault base indexSpecifiable index typeSpecifiable base indexBound checkMultidimensionalDynamically-sizedVectorized operations
Adaindex typeyesyescheckedyesinitsome, others definable
ALGOL 681noyesvariesyesyesuser definable
APL1?0 or 1checkedyesyesyes
AWK1yes, implicitlynouncheckedyes, as delimited stringyes, rehashedno
BASIC0?nocheckednoinit?
C0nonouncheckedpartiallyinit, heapno
Ch0nonocheckedyes, also array of arrayinit, heapyes
C++0nonouncheckedyes, also array of arrayheapno
C#0nopartialcheckedyesheapyes
CFML1nonocheckedyes, also array of arrayyesno
COBOL1nonocheckedarray of arraynosome intrinsics
Cobra0nonocheckedarray of arrayheap?
Common Lisp0?nocheckedyesyesyes
D0yesnovariesyesyes?
F#0nopartialcheckedyesheapyes
FreeBASIC0noyescheckedyesinit, init?
Fortran1yesyesvariesyesyesyes
FoxPro1?nocheckedyesyes?
Go0nonocheckedarray of arraynono
Hack0yesyescheckedyesyesyes
Haskell0yesyescheckedyes, also array of arrayinit?
IDL0?nocheckedyesyesyes
ISLISP0?nocheckedyesinityes
J0?nocheckedyesyesyes
Java0nonocheckedarray of arrayinit?
JavaScript0nonocheckedarray of arrayyesyes
Julia1yesyescheckedyesyesyes
Lingo1??uncheckedyesyesyes
Ring1?partialcheckedarray of arrayyes?
Lua1?partialcheckedarray of arrayyes?
Mathematica1nonocheckedyesyesyes
MATLAB1?nocheckedyesyesyes
Nim0yesyesoptionalarray of arrayyesyes
Oberon0?nocheckedyesno?
Oberon-20?nocheckedyesyes?
Objective-C0nonocheckedarray of arrayyesno
OCaml0nonochecked by defaultarray of arrayinit?
Pascal, Object Pascalindex typeyesyesvariesyesvariessome
Perl0noyes checkedarray of arrayyesno
Raku0nonocheckedyesyesyes
PHP0yesyescheckedyesyesyes
PL/I1?yescheckedyesno?
Python0nonocheckedarray of arrayyesno
RPG1nono?nono?
R1??????
Ruby0nonocheckedarray of arrayyes?
Sass1nonocheckedarray of arrayinit?
S-Lang0?nocheckedyesyesyes
Scala0nonocheckedarray of arrayinityes
Scheme0?nocheckedarray of arrayinityes
Smalltalk1?nocheckedarray of arrayyes?
Swift0nonocheckedarray of arrayyes?
Visual Basic0noyescheckedyesyes?
Visual Basic.NET0nopartialcheckedyesyesyes
Wolfram Language1nonocheckedyesyesyes
Windows PowerShell0nonocheckedyesheap?
Xojo0nonocheckedyesyesno
XPath/XQuery1nonocheckedarray of arrayyesyes
Programming languageDefault base indexSpecifiable index typeSpecifiable base indexBound checkMultidimensionalDynamically-sizedVectorized operations

Vectorized array operations

Some compiled languages such as Ada and Fortran, and some scripting languages such as IDL, MATLAB, and S-Lang, have native support for vectorized operations on arrays. For example, to perform an element by element sum of two arrays, and to produce a third, it is only necessary to write
c = a + b
In addition to support for vectorized arithmetic and relational operations, these languages also vectorize common mathematical functions such as sine. For example, if is an array, then
y = sin
will result in an array whose elements are sine of the corresponding elements of the array.
Vectorized index operations are also supported. As an example,

even = x;
odd = x;

is how one would use Fortran to create arrays from the even and odd entries of an array. Another common use of vectorized indices is a filtering operation. Consider a clipping operation of a sine wave where amplitudes larger than 0.5 are to be set to 0.5. Using S-Lang, this can be done by
y = sin;
y = 0.5;

Mathematical matrix operations

,...
OWIKI.org. Text is available under the Creative Commons Attribution-ShareAlike License.