this post was submitted on 24 Aug 2025
283 points (97.6% liked)

Programmer Humor

38087 readers
212 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 6 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] Ephera@lemmy.ml 2 points 1 week ago* (last edited 1 week ago)

Ah, I'm not talking about Ruby, I'm talking about language design in general.

I'm currently mostly doing Rust, so I can only really name that as an example (even though there's very likely other languages that allow this, too), but yeah, here's for example the 64-bit signed integer in Rust: https://doc.rust-lang.org/stable/std/primitive.i64.html

That is a primitive type, not an object, so it is exactly 64-bits in size and stored on the stack, not the heap. But as you can see in the documentation, Rust allows for associated functions anyways, like for example:

let my_number: i64 = -3;
my_number.abs()  //returns the absolute value, so 3

That's because that last call is just syntactic sugar for calling the same function statically on the type:

i64::abs(my_number)