<p>Different languages have different names for the same thing. Off the top of my head, there's:</p>
<ul>
<li><a href="https://en.cppreference.com/w/cpp/container/vector" rel="nofollow noreferrer">C++ <code>vector</code></a> and <a href="https://doc.rust-lang.org/std/vec/struct.Vec.html" rel="nofollow noreferrer">Rust <code>Vec</code></a></li>
<li><a href="https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html" rel="nofollow noreferrer">Java <code>ArrayList</code></a></li>
<li><a href="https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=net-7.0" rel="nofollow noreferrer">C# <code>List</code></a>
<ul>
<li>This is bridged to F# as <code>ResizeArray</code>, since in F# <code>List</code> already refers to a linked list</li>
</ul>
</li>
<li><a href="https://developer.apple.com/documentation/swift/array" rel="nofollow noreferrer">Swift <code>Array</code></a>
<ul>
<li>and also <a href="https://developer.apple.com/documentation/swift/contiguousarray" rel="nofollow noreferrer"><code>ContiguousArray</code></a> if you really want to be sure</li>
</ul>
</li>
</ul>
<p>Some of these names are overloaded (&quot;vector&quot; could mean a SIMD register, for example). However, no single one seems to have &quot;won out&quot; for this specific use case.</p>
<p>What are some arguments for and against each one?</p>

<types><arrays>
What should a variable-size contiguous collection be called?
CC BY-SA 4.0
2023-05-17T01:43:16.017Z
VtCing as opinion-based for now, this could easily be reworded to be more objective tho
rydwolf
<p>C++ uses <code>std::vector</code> for contiguous variable-size containers to distinguish from <code>std::array</code> (fixed size) and <code>std::list</code> (non-contiguous). It's instructive to see how they gave unique names based on the container's properties. Whatever naming scheme you use, make sure the users know what to expect!</p>
<p>A side note: array programming languages like APL and its offspring (j,k,q) expect vector containers to come with vector <em>operations</em>. I.e., users know they can operate directly on a collection without using loops. So again, make sure to play to your users' expectations.</p>

CC BY-SA 4.0
2023-05-17T01:18:50.593Z
2023-05-17T01:18:50.593Z
chrisaycock
<p>For what it's worth, <a href="https://en.wikipedia.org/wiki/Dynamic_array" rel="nofollow noreferrer">the Wikipedia page about this data structure</a> calls it a</p>
<blockquote>
<p>dynamic array, growable array, resizable array, dynamic table, mutable array, or array list</p>
</blockquote>
<p>I prefer the term &quot;array list&quot; but that's probably just because of my background, and it's hard to give any objective argument for why one name should be preferred over others, beyond popularity or appeal to authority.</p>
<p>That said, it may be called simply a &quot;list&quot; in contexts where what matters is not the underlying <strong>data structure</strong>, but the <a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)" rel="nofollow noreferrer">abstract <strong>data type</strong></a> it implements. The contrast is between naming things by what they're made of (in this case, an &quot;array list&quot; is a list made from an array) vs. what they're used for. This isn't to imply that the word &quot;list&quot; actually <em>means</em> an array list, only that sometimes the fact that it's a list matters more than the fact that it's an array list.</p>
<p>Lower-level languages will tend to use names which describe the <strong>data structure</strong>, since programmers want control over which data structures are used; higher-level languages will tend to use names which describe the <strong>data type</strong>, since the programmers want a general-purpose way of solving problems without having to make choices about such implementation details. So it makes sense that e.g. Python has &quot;lists&quot; and &quot;dictionaries&quot; instead of &quot;dynamic arrays&quot; and &quot;hashtables&quot;.</p>
<p>So I'd suggest calling it an &quot;array list&quot; or &quot;dynamic array&quot; if your language is making the programmer choose which data structures to use, or just &quot;list&quot; if your language is trying to make a sensible default choice so the programmer doesn't have to think about it. Put another way, if it's the only kind of list your language has first-class support for, then just call it a list.</p>

CC BY-SA 4.0
2023-05-17T01:24:28.803Z
2024-12-21T13:45:28.030Z
2024-12-21T13:45:28.030Z
kaya3
CC BY-SA 4.0
2024-12-21T17:55:54.613Z
In compounds like ‘array list’, the first part isn't necessarily what the list is made from — just a description to distinguish it from other implementations.  The data structure often makes a good descriptor, but even in the Java standard library `CopyOnWriteArrayList` is more about behaviour than structure, while third-party libraries include behaviour-related names such as `GlueList`, `CartesianList`, `ForwardingList`, `RegularImmutableList`, `CursorableLinkedList`, `FixedSizeList`, `GrowthList`, `LazyList`, `NodeCachingLinkedList`, `PredicatedList`, `SetUniqueList`, `TransformedList`…
gidds
CC BY-SA 4.0
2024-12-21T18:07:36.770Z
@gidds That's a fair point, but "copy on write" is still an implementation detail, where the data type would be "concurrent list" or "immutable list", those being descriptors of what the object is used for rather than how it works. A copy-on-write array is a thing you can make a concurrent or immutable list out of. I don't claim that this binary distinction is followed universally, let alone in third-party libraries.
kaya3
CC BY-SA 4.0
2023-05-30T16:27:33.693Z
I really dislike the term "array list". I guess that comes from thinking of lists as "linked lists - implemented by pointers" and "arrays as a heterogeneous 'list' of values usually stored in contiguous memory". The name array list only makes sense coming from a place like Java where the "list" interface is shared between them. In C++ we consider the complexity part of the interface so a vector is not a list because it has O(1) access time for example.
The prejudice against the name is so strong I almost downvoted your perfectly correct answer.
Bruce Adams
CC BY-SA 4.0
2023-05-30T16:37:41.663Z
@BruceAdams That's an interesting point about considering complexity part of the interface. But in that case the array-list's O(1) time for random access is within the O(n) bound for that operation on what C++ calls a list. If it's considered important for a C++ list to have O(1) insertion/removal at the start of the sequence then an array-list doesn't fulfil that part of the interface; but it's strange to me that you consider it not to be a list because random access is too *fast*.
kaya3
CC BY-SA 4.0
2023-05-30T16:41:01.687Z
That was *inelegant grammar* on my part. I meant a list is not a vector because a vector has O(1) access time where a list has O(n) access time using an index. A list has fast insertion and deletion instead. Both lists and vectors can be used as stacks. In C++ we also have a deque which offers fast insertion and both the front and the back in exchange for losing the guarantee of contiguous memory.
Bruce Adams
CC BY-SA 4.0
2023-05-30T16:43:25.783Z
@BruceAdams Ah, sure. Yes, I would say that "vector" is the name of a data structure, not an abstract data type, so any other list data structure is not a vector. Actually I'm somewhat surprised that Wikipedia doesn't list "vector" among the names for this data structure.
kaya3
# What should a variable-size contiguous collection be called?
Posted by: username_0 on 2023-05-17
Different languages have different names for the same thing. Off the top of my head, there's:

* [C++ `vector`](https://en.cppreference.com/w/cpp/container/vector) and [Rust `Vec`](https://doc.rust-lang.org/std/vec/struct.Vec.html)
* [Java `ArrayList`](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html)
* [C# `List`](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=net-7.0)
  + This is bridged to F# as `ResizeArray`, since in F# `List` already refers to a linked list
* [Swift `Array`](https://developer.apple.com/documentation/swift/array)
  + and also [`ContiguousArray`](https://developer.apple.com/documentation/swift/contiguousarray) if you really want to be sure

Some of these names are overloaded ("vector" could mean a SIMD register, for example). However, no single one seems to have "won out" for this specific use case.

What are some arguments for and against each one?
**Tags:** types arrays
> **Comments:**
> **username_1**: VtCing as opinion-based for now, this could easily be reworded to be more objective tho  
---
## 2 answers
### Answer by username_3 on 2023-05-17. Score: 10 | Accepted answer
For what it's worth, [the Wikipedia page about this data structure](https://en.wikipedia.org/wiki/Dynamic_array) calls it a

> dynamic array, growable array, resizable array, dynamic table, mutable array, or array list

I prefer the term "array list" but that's probably just because of my background, and it's hard to give any objective argument for why one name should be preferred over others, beyond popularity or appeal to authority.

That said, it may be called simply a "list" in contexts where what matters is not the underlying **data structure**, but the [abstract **data type**](https://en.wikipedia.org/wiki/List_(abstract_data_type)) it implements. The contrast is between naming things by what they're made of (in this case, an "array list" is a list made from an array) vs. what they're used for. This isn't to imply that the word "list" actually *means* an array list, only that sometimes the fact that it's a list matters more than the fact that it's an array list.

Lower-level languages will tend to use names which describe the **data structure**, since programmers want control over which data structures are used; higher-level languages will tend to use names which describe the **data type**, since the programmers want a general-purpose way of solving problems without having to make choices about such implementation details. So it makes sense that e.g. Python has "lists" and "dictionaries" instead of "dynamic arrays" and "hashtables".

So I'd suggest calling it an "array list" or "dynamic array" if your language is making the programmer choose which data structures to use, or just "list" if your language is trying to make a sensible default choice so the programmer doesn't have to think about it. Put another way, if it's the only kind of list your language has first-class support for, then just call it a list.
> **Comments:**
> **username_5** (2023-05-30): I really dislike the term "array list". I guess that comes from thinking of lists as "linked lists - implemented by pointers" and "arrays as a heterogeneous 'list' of values usually stored in contiguous memory". The name array list only makes sense coming from a place like Java where the "list" interface is shared between them. In C++ we consider the complexity part of the interface so a vector is not a list because it has O(1) access time for example.
The prejudice against the name is so strong I almost downvoted your perfectly correct answer.  
> **username_3** (2023-05-30): @BruceAdams That's an interesting point about considering complexity part of the interface. But in that case the array-list's O(1) time for random access is within the O(n) bound for that operation on what C++ calls a list. If it's considered important for a C++ list to have O(1) insertion/removal at the start of the sequence then an array-list doesn't fulfil that part of the interface; but it's strange to me that you consider it not to be a list because random access is too *fast*.  
> **username_5** (2023-05-30): That was *inelegant grammar* on my part. I meant a list is not a vector because a vector has O(1) access time where a list has O(n) access time using an index. A list has fast insertion and deletion instead. Both lists and vectors can be used as stacks. In C++ we also have a deque which offers fast insertion and both the front and the back in exchange for losing the guarantee of contiguous memory.  
> **username_3** (2023-05-30): @BruceAdams Ah, sure. Yes, I would say that "vector" is the name of a data structure, not an abstract data type, so any other list data structure is not a vector. Actually I'm somewhat surprised that Wikipedia doesn't list "vector" among the names for this data structure.  
> **username_4** (2024-12-21): In compounds like ‘array list’, the first part isn't necessarily what the list is made from — just a description to distinguish it from other implementations.  The data structure often makes a good descriptor, but even in the Java standard library `CopyOnWriteArrayList` is more about behaviour than structure, while third-party libraries include behaviour-related names such as `GlueList`, `CartesianList`, `ForwardingList`, `RegularImmutableList`, `CursorableLinkedList`, `FixedSizeList`, `GrowthList`, `LazyList`, `NodeCachingLinkedList`, `PredicatedList`, `SetUniqueList`, `TransformedList`…  
> **username_3** (2024-12-21): @gidds That's a fair point, but "copy on write" is still an implementation detail, where the data type would be "concurrent list" or "immutable list", those being descriptors of what the object is used for rather than how it works. A copy-on-write array is a thing you can make a concurrent or immutable list out of. I don't claim that this binary distinction is followed universally, let alone in third-party libraries.  
---
### Answer by username_2 on 2023-05-17. Score: 5
C++ uses `std::vector` for contiguous variable-size containers to distinguish from `std::array` (fixed size) and `std::list` (non-contiguous). It's instructive to see how they gave unique names based on the container's properties. Whatever naming scheme you use, make sure the users know what to expect!

A side note: array programming languages like APL and its offspring (j,k,q) expect vector containers to come with vector *operations*. I.e., users know they can operate directly on a collection without using loops. So again, make sure to play to your users' expectations.
---
