Yeah its a rails only thing. Rubys biggest issue is its much too intelligent for its own good. Its implicit rather than pythons explicit. Most of the time. That and it’s hard to find out where Ruby starts and rails ends.
That being said I made a ton of good money on rails back about 15 or so years ago. Still excellent for starting out.
Rails, ActiveSupport I believe, adds this to integers.
But I think one of the interesting things about it is the open nature of classes in ruby.
The thing that makes it possible is that you can open classes in user space and just add stuff to them. It’s a neat feature that few languages have.
The feature, like most features, has pros and cons. On the pro side it makes making DSLs and helpers like this pretty trivial. You can make really expressive ideas and apis because you can change how things you didn’t write work.
On the con side, it’s harder to discover and the methods of an object being the result of runtime mixins can make things hard to reason about.
Having worked in both python and ruby and now elixir for the past couple of years, it’s interesting to see how the languages are similar and different.
There’s an elegant beauty to ruby’s everything is an object and all method calls are messages concept. Python has always struck me as less elegant but the upside is that it can model different ideas in different ways and doesn’t have to try to make them all look like the one central idea.
Even though I find the model behind ruby more pleasing to think about, I tend to enjoy python more due to it being more explicit and easier to reason about. Although that’s pretty subjective.
In any case I think the language feature of open classes is a fascinating one and one of the really different parts of ruby that really distinguishes it from python, for better or worse.
LLM is saying this is a feature of Rails and not particularly Ruby.
I was surprised Python didn’t have a years parameter but learned about
Yeah its a rails only thing. Rubys biggest issue is its much too intelligent for its own good. Its implicit rather than pythons explicit. Most of the time. That and it’s hard to find out where Ruby starts and rails ends.
That being said I made a ton of good money on rails back about 15 or so years ago. Still excellent for starting out.
Rails, ActiveSupport I believe, adds this to integers.
But I think one of the interesting things about it is the open nature of classes in ruby.
The thing that makes it possible is that you can open classes in user space and just add stuff to them. It’s a neat feature that few languages have.
The feature, like most features, has pros and cons. On the pro side it makes making DSLs and helpers like this pretty trivial. You can make really expressive ideas and apis because you can change how things you didn’t write work.
On the con side, it’s harder to discover and the methods of an object being the result of runtime mixins can make things hard to reason about.
Having worked in both python and ruby and now elixir for the past couple of years, it’s interesting to see how the languages are similar and different.
There’s an elegant beauty to ruby’s everything is an object and all method calls are messages concept. Python has always struck me as less elegant but the upside is that it can model different ideas in different ways and doesn’t have to try to make them all look like the one central idea.
Even though I find the model behind ruby more pleasing to think about, I tend to enjoy python more due to it being more explicit and easier to reason about. Although that’s pretty subjective.
In any case I think the language feature of open classes is a fascinating one and one of the really different parts of ruby that really distinguishes it from python, for better or worse.
Yeah that feels like the kind of smartass thing Python would do.
You can add activesupport (I think that’s it) to get it if you don’t want to use all of rails.
That’s what I end up seeing for most ruby only scripts. It works!