In machine code, all load/store instructions just work on 1,2,4,8, or maybe 16 or 32 bytes. It's the compiler's responsibility to make sure, e.g., an int doesn't get used as a float, and that doesn't have to be done at runtime.
In languages where it is always done at runtime, like Python, you're going to be wasting a lot of bits on identifiers, and a lot of instructions on inspecting them, so the bit-conscious wouldn't be using that language in the first place.
I don't know how many languages there are that fully compile all the way to machine code and then still use type tags all the time, since it's easy for a compiler to resolve most or all of the function overloads ahead of time, but lots of languages need type tags sometimes.
For example, C++ will attach type tags to objects when that type has inheritance relationships. (Those are actually pointer-sized, 64 bits, so that they can directly point to the set of identifiers for that object's correct virtual functions).
View all comments
Show parent comment
6
u/Great-Powerful-Talia Oct 07 '26 edited Oct 07 '26
In machine code, all load/store instructions just work on 1,2,4,8, or maybe 16 or 32 bytes. It's the compiler's responsibility to make sure, e.g., an int doesn't get used as a float, and that doesn't have to be done at runtime.
In languages where it is always done at runtime, like Python, you're going to be wasting a lot of bits on identifiers, and a lot of instructions on inspecting them, so the bit-conscious wouldn't be using that language in the first place.
I don't know how many languages there are that fully compile all the way to machine code and then still use type tags all the time, since it's easy for a compiler to resolve most or all of the function overloads ahead of time, but lots of languages need type tags sometimes.
For example, C++ will attach type tags to objects when that type has inheritance relationships. (Those are actually pointer-sized, 64 bits, so that they can directly point to the set of identifiers for that object's correct virtual functions).