Why do we strive for short type names in programming languages?
Like most developers I am not coding just a single programming language and I do keep up to date on new programming languages.
Lately however, I have seen a trend I do not really like in static typed programming languages that I do not like and it is in particular present in Rust and Zig.
So what is this trend? Well really short unreadable type names!
Below I first have a C++ example of a simple sum function (ignore the overflow issue) and then the same function implemented in rust.
For C++ we have the type uint64_t
and for Rust u64
.
Now let us assume I am newcomer from Java, C#, or C, in C++ I know its and int
I would also argue that I could guess its 64 bit.
Additionally, if you play around with enough programming languages u
is often used as a short hand for unsigned
so you might be able to guess what that part.
The _t
has always bugged me, but I can deal with.
However, with rust all you have to go by is u64
so you know it is 64 bit and like with C++ you could problem resonance yourself to the conclusion that it is an unsigned variable.
But unsigned what? float, integer, something third? You literally cannot tell.
With time of course you will remember it, but if you (like me) have to switch between multiple language during a single day, it is sometimes difficult to instantly remember what the different types hiding behind u<INSERT NUMBER>
, i<INSERT NUMBER>
, and so on. I am at a stage now where I can but it took a long time, but it was one of the reason I originally gave up on learning Rust, because I found it to convoluted and like it was intentionally gate keeping with is type names.
uint64_t sum(uint64_t start)
{
uint64_t res = 0;
for (uint64_t i = start; i > 0; --i)
{
res = res + 1;
}
return res;
}
fn sum(start: u64) -> u64 {
let mut res: u64 = 0;
for i in (0..start).rev() {
res = res + i;
}
return res;
}
I do not understand this design decision was made in Rust and I honestly think that it scares some people away. Why have this been chosen? Please stop.
./Lars