Most active commenters
  • baweaver(3)

←back to thread

511 points mootrichard | 11 comments | | HN request time: 1.683s | source | bottom
Show context
muglug ◴[] No.23990520[source]
Can someone explain why the types cannot live in Ruby code itself (after an appropriate version bump)?

Python 3 incorporated types into the language itself, in a similar way (though non-reified) to PHP. This seems much easier to deal with than requiring two files (.rb and .rbs) to describe a single data structure.

replies(4): >>23990918 #>>23990947 #>>23991201 #>>23991455 #
1. skywhopper ◴[] No.23991201[source]
Based on the relative smoothness of Ruby version transitions versus Python, I trust Matz’s preference on this implicitly. One good thing about it being external is that you can optionally and experimentally annotate existing code without munging up your source files. At least so long as this is a bleeding edge feature, that separation makes a lot of sense to me. It’ll be a while before anyone can be confident in a particular model for how this should work, until it’s been in use for a good long while.
replies(2): >>23991245 #>>24004577 #
2. baweaver ◴[] No.23991245[source]
Pretty much. Matz is very sensitive to breaking the language in any way with the Ruby 3 upgrade, which brought up the true keyword argument hard-break and [likely got that pushed back](https://discuss.rubyonrails.org/t/new-2-7-3-0-keyword-argume...).

RBS and type files on the side were really hotly debated for a while and the core team settled on this as a way to not break the existing parser among other reasons.

While I don't 100% agree with them I have faith that Matz and the team make the decisions they do based on impact and what they see in the community.

replies(1): >>23991273 #
3. Jabbles ◴[] No.23991273[source]
His view is probably informed by the Python 2->3 experience.
replies(3): >>23991315 #>>23992113 #>>23992181 #
4. baweaver ◴[] No.23991315{3}[source]
It was, and I was around during one of his discussions on that at RubyConf last year. It's a very valid concern and Matz is very sensitive to it. There are a lot of things he's joked about removing or changing but won't because of those reasons.

If you take a look at his keynote video he says quite a bit on this too.

5. jrochkind1 ◴[] No.23992113{3}[source]
Ruby 1.8 to 1.9 was very painful, I am not sure why it was more succesful than Python 2->3, I'm not sure it "deserved" to be or was any less painful on it's face. It easily could have been just as disastrous. So also informed by that; ruby hasn't done anything nearly as painful since.

But that applies to making it so old code does not work in the new version of the language. Nobody expects all new code to work in the old version of the language. Ruby adds new features including syntax that won't properly parse in old interpreters all the time. It's not clear to me why inline type definitions couldn't be such.

replies(2): >>23992193 #>>23993107 #
6. dragonwriter ◴[] No.23992181{3}[source]
And also the Ruby 1.8->1.9 experience.
7. dragonwriter ◴[] No.23992193{4}[source]
> I am not sure why it was more succesful than Python 2->3

Probably because Ruby had a much narrower area where it was heavily used, with fewer “finished” but critical libraries.

replies(2): >>23992679 #>>23994986 #
8. Polylactic_acid ◴[] No.23992679{5}[source]
I expect most ruby projects only have rails as its core dependency with all other gems being small utility libraries that can be easily updated and replaced. Python gets used for such a wide variety of things.
9. baweaver ◴[] No.23993107{4}[source]
That's definitely fair, and probably a large reason why they're so paranoid about repeating that.
10. riffraff ◴[] No.23994986{5}[source]
Matz often cited the "carrot" of much better performance on 1.9 as a reason for the successful transition.

Python3 didn't offer much over python2, so people just saw the downsides, while ruby pushed people to upgrade with the promise that their efforts would gain them better performance and/or save money.

11. yawaramin ◴[] No.24004577[source]
> It’ll be a while before anyone can be confident in a particular model for how this should work, until it’s been in use for a good long while.

Check out the OCaml community, interface files have been use there since basically day one, and are generally well-liked for how clean they allow the implementations to be.