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

31

u/JeffB1517 Jan 24 '26

MATLAB, Julia, HLSL (Cg, Asymptote. VEX all have 3D vectors built in. Programming languages choose a limited set of primitives for what they consider common use cases. More niche languages have more niche primitives. Same reason most programming languages don't have filenames as a primitive, but shell scripting languages do. Or some 4GL languages like MUMPS have key-value hierarchical database interactions as a primitive.

7

u/shponglespore Jan 24 '26

What shell scripting languages are you thinking of? All the ones I've used (Unix shells and PowesScript) just treat file names as strings. Even build systems like Make, Ninja, and Bazel lack a special data type for file names.

1

u/JeffB1517 Jan 25 '26

No they don't. They treat them as objects with properties

ls d/e is effectively a polymorphic function of d which is then polymorphic on e which is treated as an object i.e. d->e.ls in OO syntax. Note that e is a file ls polymorphism will handle this. Similarly cat d/e now treats e as a file and d->e.cat. It has elegant failure if e is a directory. Etc... that is way more than strings.

More importantly though, than all that power is the fact that they are a default argument type, a primitive, for countless operations that want a file name, not merely a string.

-1

u/shponglespore Jan 25 '26

Umm... arguments to processes are passed as strings, bro. ls and cat are programs, not member functions.

3

u/JeffB1517 Jan 25 '26

Arguments are passed to C as strings. That doesn't mean they are considered strings in the context of the shell language. type is a builtin. The primitives it supports are: ‘alias’, ‘keyword’, ‘function’, ‘builtin’, or ‘file’. String is not there.