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/slicxx Jan 24 '26
I see two very clear problems, first is minor but the second one is i think of more importance.
When we implement vec3 everywhere, people are going to ask for more niche things. I used vec4 and vec5 too in my job, but somewhere is a limit in terms of what a language/library should support.
But what do these types actually do? Exactly nothing. It all boils down to the functions we want to apply to those types. Add? Substract? Easy in 17 dimensions, but how about complex vector funktions? Do we want to do this inplace or return a copy? Will the memory layout be efficient for operation XYZ? Once you put your hands on a vec3/mat type, i bet efficiency is of importance, so it's best to have all the tooling for your use case in one place, without bursting the scope of standard lib.
Some languages offer more, some offer literally nothing and just provide base tooling, because you can build anything anyways with it. Of course it's also design philosophy, but types with 3 or more dimensions are more likely than not an overkill for built-ins