r/ProgrammingLanguages • • 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

132 comments sorted by

View all comments

Show parent comment

1

u/slicxx Jan 24 '26

I see where you're going, but more often than not, things are semi-built-in. The title asks why it's not built-in. I assume my definition of built-in is too literal, meaning usable without import. But standard libs (or standardized libs) do often exist and have big functionality.

I think a great example is the C language here. They want to stay minimal and portable, and of course stay close to the machine, only one hop away from ASM. No dynamic vectors exist, because growth handling, memory and error management, performance and so on do matter but in different ways for different use cases. But a simple "type" is one makro or a few lines of header files.

And for the n-D types? Different types (int, float32/64..) can be easily implemented but they would at least need different paddings inside to be efficient in cache.. A Vector3 is used in a widespread use, but in no way are they universal. They are highly domain specific, so let's just keep it in the math library, game engine or shading language which will hopefully be "optimally" compiled for the use case. And these environments all come with the type.

All about hitting the sweet spot between implementing nothing and delivering it all.

3

u/Kaisha001 Jan 24 '26

I assume my definition of built-in is too literal, meaning usable without import.

Fair enough, it was rather ambiguous. I assumed standard library type stuff.

And for the n-D types? Different types (int, float32/64..) can be easily implemented but they would at least need different paddings inside to be efficient in cache.. A Vector3 is used in a widespread use, but in no way are they universal.

There are SSE/AVX types on near every platform now. It's not an impossible task.

2

u/slicxx Jan 24 '26

You got a very strong point with SSE/AVX, so the reason might just be legacy for many languages nowadays, but it still makes sense for some hard typed languages to focus on the minimum.

Interesting discussion, now i wonder where the limits are and why we aren't pushing further in this direction, especially since a lot of things can be hidden from the user anyways or rather aggressive, maybe be compiled out if it isn't necessary.

1

u/Kaisha001 Jan 24 '26

TBH I'd prefer we just had better compute drivers, so HLSL/GLSL could become generic parallel languages, that could be run on the CPU, or GPU, or some combination.

1

u/slicxx Jan 24 '26

Yeah no way i'd like to touch GLSL when i had other options. In university, we coded our own operating system. This was painful for an average of 7.5 hours a day for about 5 months straight. But it was almost peaceful compared to the time we were forced to learn what is happening behind CUDAs curtains in my masters program. It was then and there, i decided to only do games engineering as a minor instead of my masters subject and just stick with Intelligent Systems because i didn't want to ruin my brain. A friend from uni started to work as a firmware developer for one of nvidias vendor companies... He will retire after roughly 7 years of experience but is about to get his second burnout diagnosis, i can see it in his eyes.

All of that, and we still have no real platform that crosses GPU and CPU universally outside of big data and gaming.

2

u/Kaisha001 Jan 24 '26

All of that, and we still have no real platform that crosses GPU and CPU universally outside of big data and gaming.

It is something I would love to see.