`DynamicVector`, the name
Why is it not called
DynamicArray
? I find dynamic vector a bit tautological, given the vector terminology (likely) comes from C++, which literally means "dynamic sized array"[ref].35 Replies
Yeah I agree. Also,
Vector
is a questionable term to use, because it doesn't match either of the existing meanings of "vector" in engineering and computing:
- a mathematical vector
- a SIMD vector (which is inspired by mathematical vectors)
The idea of being "resizable" and being a mathematical "vector" are orthogonal. C++ decided to use the term "vector" to mean "resizable array" which was a super weird idea. Even the guy who invented the name agrees:
The name vector in STL was taken from the earlier programming languages Scheme and Common Lisp. Unfortunately, this was inconsistent with the much older meaning of the term in mathematics and violates Rule 3; this data structure should have been called array. Sadly, if you make a mistake and violate these principles, the result might stay around for a long time. (source)
@sora maybe it will be reaspnable to create feature request to keep track this idea?
Yes. I’m just not sure if that counts as bike shedding or not. Thus, I think gathering some community responses/consensus here can really help.
For me
Array
also looks better. Even if it is bikeshedding, proper and consistent identifiers are important and mess here could be painful in future due to cmpatibility
Even more, I remember discussion somewhere, that Tensor
is also not valid name for such structureThat was also me 😂
So, you can put it at once xD
100% agree with DynamicVector and Tensor needing a rename
Feel free to file a GH issue. We plan on renaming it at some point as I don't think we love the existing name either. Better to do these sort of things earlier than later before even more code starts using the stdlib. There's other issues with the API that we need to resolve. For example, it's a bit silly to have both append and push_back do the same thing. It's a weird mix of Python and C++ naming since its origin.
Naming and getting these things consistent is important, but hasn't been a high priority in the short term yet. It's all easy to change though.
Congrats @Joe Loser, you just advanced to level 1!
@Joe Loser so when you are up to adjust names? I reported other issue related to consistency and I really hope that it will be solved sooner than later due to compatibility 😉
I'll bring it up with the team next week and circle back.
Thank you 🙂
FWIW the name
List
might be ideal, if I am correct in assuming that DynamicVector
is meant to serve the same role as Python's list
type. And you could use a term like CappedList
to refer to a capacity-limited list, instead of InlinedFixedVector
. (IMO the term "inlined" is misleading for that struct, because the data isn't actually guaranteed to be stored inline.)The best will be to rename all members from
Vector
family and pick name which conforms to all of them. I mean here: DynamicVector
, InlinedFixedVector
and whole module: vector.mojo
Pro: It's what Python uses,
list
is backed by an array;
Cons: Just like vector
, it's not what the type is. List is usually reserved to linked list etc. In system programming language like Mojo, it's a bad, because people will make different assumptions about the complexity of it's methods.
"Capped something" sounds horrible, and feels like to much of a novelty, at least for me. Also, what do you mean the data is not gauaranteed to be stored inline?