Soul arrays vs vectors

Is there some circumstances where holding primitive types in an array has some advantages over using a vector?

It seems that everything that can be done with an array can be done with a vector, correct?
the ‘only’ difference between the 2 is that the vector supports arithmetics operation?
I’m not sure why we are given the choice between float[] array and float<> vector

We spent a lot of time debating whether we should merge the two types, and decided they had different enough semantics that it works better if we keep them separate.

There are a few differences - vectors can’t be dynamically indexed, and can’t be as big as arrays. These restrictions mean we can use LLVM’s vector intrinsics which generates better code (but that’s not in itself a reason for doing it this way). And we’ll provide shuffle intrinsics for vectors that probably aren’t useful for arrays.

But mainly it just works better when you’re writing code to distinguish the concept of vectors from arrays - especially when you start creating arrays of vectors for audio data, it’s less confusing than an array-of-array would be.

1 Like