r/ProgrammingLanguages • u/Luroqa • Jan 24 '26
Discussion Why don't any programming languages have vec3, mat4 or quaternions built in?
Shader languages always do, and they are just heaven to work with. And tasty tasty swizzles, vector.xz = color.rb it's just lovely. Not needing any libraries or operator overloading you know? Are there any big reasons?
110
Upvotes
View all comments
Show parent comment
5
u/WittyStick Jan 24 '26
I don't think it's unreasonably niche to support what the CPU supports: vec2, vec4, vec8 - for doubles and 64-bit integers and for the smaller types: vec16, vec32 and vec64.
A use case besides geometry is to optimize data structures - and the larger the vector the better.
vec64 of
uint8for example can be used to significantly improve the performance of decoding UTF-8, which is used everywhere - far from niche - but most of the software running on your computer is probably decoding one byte at a time because it's dependant on some low-level string APIs which don't use SIMD.