Comparison of programming languages (associative array): Difference between revisions

Content deleted Content added
add box
Line 3:
{{Expand|date=January 2007}}
 
The following is a comparison of associative arrays (also "mapping", "hash", and "dictionary") in various programming languages. For more details, see [[Associative array]].
Associative arrays can be implemented in any programming language as a package and many language systems provide them as part of their standard library. In some languages, they are not only built into the standard system, but have special syntax, often array-like subscripting.
 
In many more languages, they are available as library functions without special syntax.
 
Associative arrays have a variety of names. In [[Smalltalk programming language|Smalltalk]], [[Objective-C programming language|Objective-C]] and [[Python (programming language)|Python]] they are called ''dictionaries''; in [[Perl]] and [[Ruby programming language|Ruby]] they are called ''hashes''; in [[C++]] and [[Java (programming language)|Java]] they are called ''maps'' (see {{Javadoc:SE|java/util|Map}}) and in [[Common Lisp]] and [[Windows PowerShell]] they are called ''hashtables'' (since both typically use this implementation). In [[PHP]] all arrays can be associative, except that the keys are limited to integers and strings and can only be a single level of subscripts.
 
In the scripting language [[Lua programming language|Lua]], associative arrays, called ''tables'', are used as the primitive building block for all data structures, even arrays. Likewise, in [[JavaScript]], all objects are associative arrays. In MUMPS, the associative arrays are typically stored as [[B-trees]].
 
=== Awk ===