# Vector, a fixed-size array

**URL:** <https://forums.swift.org/t/vector-a-fixed-size-array/75264>\
**Category:** Pitches\
**Tags:** array\
**Created:** [October 10, 2024, 1:18am UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264 "2024-10-10T01:18:30Z")\
**Posts on this page:** 1\
**Showing post:** 221

<div class="post-metadata">

**Author:** ![Andropov](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/andropov/32/35955_2.png) [@Andropov](https://forums.swift.org/u/Andropov)\
**Post date:** [October 29, 2024, 12:28pm UTC](https://forums.swift.org/t/vector-a-fixed-size-array/75264/221 "2024-10-29T12:28:19Z")

</div>

> [@Jon\_Shier](#):
>
> Using `XArray` as the name doesn't imply that it will have all the same properties as an `Array` any more than `StaticString` implies it has all the same properties as `String`. It's a _different name_ so it means something _different_. If the key feature is its fixed-sizedness, then the name seems rather obvious: `FixedArray`.

I think it makes sense to use a derived name when the new type is a slight modification of the concept, without challenging the core properties of the original type. `StaticString` is just a string known at compile time. This type still fits into most people's definition of what a string is. Remove an important enough property of `String`, and you get a completely different name, like `Character` (no longer a collection, but a single extended grapheme cluster) or `ContiguousArray<CChar>` (a collection of UTF8 characters instead of a collection of extended grapheme clusters).

So the question would be, is the ability of `Array`s to grow a foundational part of what an "array" is in Swift? Or is it just a mere detail of the `Array` type in particular?

Several places in the documentation mention "array" (with a lowercase 'a') being a variable-size collection. To me this is a sign that the concept of array in Swift (and not the specific type `Array`) has been tied to it being a growable collection.

Plus, there's a huge pile of documentation that associates specific behaviors to "arrays" (like copy on write, heap allocation...) that wouldn't be true for `FixedArray`, simply because despite the superficial similarity, it's a fundamentally different type. Going beyond the state of the documentation today, one would always have to second-guess any statement of the form _"arrays in Swift do X and Y..."_ (does it refer to arrays in general? or just `Array`?). The naming `Vector` would immediately address that uncertainty: `Vector`s are obviously not arrays. To this point, other languages seem to agree that these are different enough to warrant different names (even though C++/Rust had the names swapped).

> [@Jon\_Shier](#):
>
> `Vector` is too easily confused with existing types and concepts to be a good name. If I have to point to this thread every time some junior engineer asks why it's named that way, it's not a good name. The simple fact that this thread's title had to clarify what `Vector` meant means it's not a good name. It's not a good name.

FWIW, [Rust's official documentation for `array`](https://doc.rust-lang.org/std/primitive.array.html) also has to clarify that it's _a fixed-size array_ on the very first line. Similarly Rust's `Vec` also compares to array [on its documentation](https://doc.rust-lang.org/std/vec/struct.Vec.html) (_A contiguous growable array type [...]_). It's not unreasonable to refer to other similar concepts when introducing a new concept. That doesn't mean that the explanation should be part of the name, otherwise dictionary-definition names would always prevail.

---

_[View the full topic](https://forums.swift.org/t/vector-a-fixed-size-array/75264)._
