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
2
u/[deleted] Jan 25 '26 edited Jan 25 '26
What's a basic linear algebra type? Are they based on floats or doubles? Are they register-per-vector (i.e. a vec3 is implemented as a 4d SIMD vector), or are they un-padded so they can easily be shipped off to the GPU? Do they use fast "good enough" math that would be ideal for a game, or do they use precise but potentially slow math that would be ideal for simulations? Are you lowering into the closest arch-available intrinsic and potentially have different behavior on different platforms, or do you guarantee the same behavior on all platforms at the cost of not being able to use bare SIMD intrinsics on some platforms in some cases? Do you provide a struct-of-arrays collection to maximize your SIMD potential?
It doesn't really matter what design you pick, because all of them have niches where they shine. If you don't provide all of them, there will be a proliferation of competing implementations regardless. At best you're blessing one design above the others even when it may be inappropriate, at worst you're providing an implementation nobody will use because it tries to be a jack of all trades instead of doing one thing well.
Unfortunately, you can’t standardize your way out of genuine heterogeneity.