this post was submitted on 24 Aug 2025
282 points (97.6% liked)
Programmer Humor
38016 readers
85 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
That's not quite right, the language has defined Int#days and 10 is actually Int(10). 10.days calls the instance method days on an instance of an Int (it has been years since I've used ruby so not sure if the stdlib class is actually Int)
days
is a method on theNumeric
class in Rails, and it creates an instance ofActiveSupport::Duration
withself
passed to the constructor (this is a bit of a simplification, because it actually calls the class methoddays
onDuration
which converts the number of days into seconds before creating theDuration
instance).Oh god good ol ActiveSupport. I'm having flashbacks of so many ruby projects trying not to bring it in and basically reinventing it but poorly documented.
I still would say it was the language I've most enjoyed (professionally used most all higher level languages over 20+ years) but it might be nostalgia for a time early 2010s when rails was just freaking magic compared to the ways we used to build web apps.
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:
That's because that last call is just syntactic sugar for calling the same function statically on the type: