text stringlengths 0 2.46k |
|---|
**Jake Zimmerman:** There's also -- yeah, there's a handful of other tools that consume them... It's just that Sorbet kind of doesn't, and maybe that's the biggest point of division, is that we haven't gone into the work to parse these files. |
**Adam Stacoviak:** Is that just the nature of the -- that it's open source, and you've got other things that are more important, obviously? It's not that you don't want to, it's like eventually you might? |
**Jake Zimmerman:** Yup. Yeah, exactly. For example, the sorts of things that we would have to stop working on right now are -- we've made a number of improvements to just the core type system for what you can actually express in the type system. We've made improvements to how fast Sorbet is, all sorts of things like t... |
**Jerod Santo:** I guess why wouldn't it just get built in? That's what I don't understand. And I guess maybe you could say, "Well, Ruby Gems wasn't built in either for a really long time, and eventually, Gem became shipped with Ruby." And so this would be a similar circumstance, maybe; like, they want a bunch of tools... |
**Jake Zimmerman:** Yeah, I guess one of the benefits of having it be this third party gem is you can iterate on it and release new versions independently of Ruby versions. So Ruby kind of famously releases a new version only once a year on Christmas. But if you wanted to add a new revision to the RBS spec, or standard... |
**Jerod Santo:** \[36:17\] Good point. You've obviously thought about this more than I have, Jake... And of course, there's lots of different parties involved in these kinds of decisions. |
**Adam Stacoviak:** It's got the wrong name though, Jerod. |
**Jerod Santo:** What's that? |
**Adam Stacoviak:** That's why it's not being adopted by the core team. It needs to be called Type Ruby, or something like that. |
**Jerod Santo:** Oh, Sorbet? |
**Adam Stacoviak:** Yeah. What do you think? |
**Jerod Santo:** Sorbet is a cool name, man. |
**Adam Stacoviak:** It is a cool name, but I just wonder if it needs to be like TypeScript-like. Like, take a page from the TypeScript book, and it's gotta be TypeRuby, or something. I don't know. I'm not saying it's the wrong name, I'm just making a joke. |
**Jerod Santo:** \[laughs\] |
**Jake Zimmerman:** Again, I think one of the other things that set apart Sorbet and TypeScript is just the amount of evangelism that has been put into each project. I think that Microsoft in general is just really good at building products for developers and evangelizing them... And Stripe as a company does that as we... |
**Jerod Santo:** Right... |
**Jake Zimmerman:** But we're kind of fine with the way things work now. We build the thing, and we ship the thing, and people who want to use what we've built are completely able to do so. And people who we'd prefer to ignore, we can. |
**Jerod Santo:** So let's talk about Sorbet itself, like the implementation, the design... I was reading some of the docs and some of the guides, just trying to see what it was like to use. I did notice pretty decent pure Ruby DSL; you're writing Ruby inside of your Ruby in order to specify a method signature, and that... |
**Jake Zimmerman:** Yeah, absolutely. So gradual type checking is just this idea that you don't have to type-check 100% of your codebase from day one; that you can -- |
**Jerod Santo:** Like opt in, yeah. |
**Jake Zimmerman:** ...opt in at various levels of granularity. That's basically table stakes if you're trying to add a type system to a language that didn't start with a type system. I don't necessarily -- there will definitely be people out there who tell you that this is actually a completely desirable property, eve... |
Control flow-sensitive typing is really interesting, and I actually think that even more traditional languages that don't have backwards compatibility with untyped programming languages could benefit from. And that's just this idea that if you have something that is either nil, or some real type, like maybe an integer,... |
So if you start out with something that's either nil or integer, and then you say, "s this thing nil?" Well, if you use that variable inside of that branch, Sorbet will be able to say "You've already checked that this thing is not nil. Here it's an integer." TypeScript does this; most languages that are gradual type sy... |
**Jerod Santo:** \[40:29\] Okay. What's an example of when that might be useful, or some code that might typically hit up against this? Just not knowing necessarily the value being returned? |
**Jake Zimmerman:** Yeah. So for example, let's say that you are interacting with the database, and you try and load some object with a specific ID; you're going to either get back nil, if that object doesn't exist, or your ORM is going to give you the model class back. And if you are writing kind of good, defensive co... |
So if Sorbet thought throughout the entire method body that this variable that you got back from your ORM was either a nil or a user model, then it's going to say "I don't know whether this -- I can't claim for sure that you calling these methods on this model exists or not." |
**Jerod Santo:** Gotcha. Yeah, I can definitely see a lot of Ruby code out there like that, because there's so many -- like, that nil case is just always the edge... |
**Jake Zimmerman:** Exactly... |
**Jerod Santo:** ...that just causes us to want types in the first place... \[laughs\] |
**Jake Zimmerman:** For example, this was kind of famously -- Java's billion-dollar mistake was conflating that every type could be null. I think that it's obviously very hard to make changes to a language as widely used as Java is now, but it's the sort of thing where if you could solve this problem, and build control... |
**Jerod Santo:** Mm-hm. So you bring up an ORM, which makes me think about Active Record, which makes me think about Active Record Base, as it used to be called; base classes, or... It makes me think about existing Ruby libraries. One of the huge advantages of TypeScript being so wildly evangelicized sized and adopted ... |
**Jake Zimmerman:** Yup, I definitely noticed that in TypeScript. Most libraries that you pull off of npm are already going to work with TypeScript just out of the box. There's kind of nowhere near that level of support for typing in Ruby Gems that you'll encounter most commonly. And there's a number of reasons for thi... |
I think that despite the low investment, people have still done it, and still published gems that have type annotations for them. The biggest ones though, like Rails, don't. And so if you want to be able to use Sorbet in a project that's using like Active Record Base or something like that, you're going to need a diffe... |
\[44:14\] So instead of annotating the source of Active Record itself, you would look how Active Record is being used in your codebase, and generate some annotation files, and rely on those annotation files to figure out what the gem is doing. |
**Jerod Santo:** This seems somewhat fraught. Is that pretty reliable at the end of the day, or is my spidey sense accurate? |
**Jake Zimmerman:** It's somewhat fraught, for sure. It's kind of a question of like how much you're going to push it. If you're using the very common cases, it'll be fine. But if you're trying to do something more complicated, especially if you combine this with heavy use of metaprogramming, then it's going to be a li... |
I think that recently one person in the community - it's actually someone who has been on this podcast before, Justin Searls... |
**Jerod Santo:** Searls, yeah. |
**Jake Zimmerman:** He's actually maintaining this Mocktail library for -- kind of a testing library for Ruby. And he has been posting quite a lot in the Sorbet Slack, just about what it takes to get typing added to a gem. And it's been really interesting, just because it's exposed all of these places that we could mak... |
**Jerod Santo:** That's one of Justin's skills, is communicating. He's always willing to post those comments, whether they're more or less salty, depending on his mood... |
**Jake Zimmerman:** Yeah, he's been quite polite, so... |
**Jerod Santo:** Awesome. \[laughs\] |
**Jake Zimmerman:** Maybe that's gone through your filter, but it's been great seeing what he's been working on. |
**Jerod Santo:** He's usually pretty unfiltered, but he's also a kind person. When you say RBI now, is that the same thing as RBS on the other side, but it's like -- |
**Jake Zimmerman:** Yeah, sorry - that's the name that Sorbet uses for these annotation files. It uses a different syntax, but for the same goal. RBI just stands for Ruby Interface. |
**Jerod Santo:** Okay. So if I was going to provide type annotations for something, I would produce an RBI. Or I guess this is what Justin is trying to figure out with Mocktail, is what do we actually -- what's our output as a library author? |
**Jake Zimmerman:** Yeah. So as a library author, you would either have to have Sorbet read the sources of your gem files, and use that to understand what's defined... But typically, people will not ask the source of the gem via type checks, because obviously, then it's also going to do things like actually read the me... |
**Jerod Santo:** Gotcha. |
**Adam Stacoviak:** Why go RBI and not RBS? Why would you create a whole new world, in a way? |
**Jake Zimmerman:** Well, so it kind of harkens back to the conversation we were having earlier about "What syntax do you want in these files?" Do you want the contents of these annotation files to be the same syntax as Ruby code? Or do you want them to start from this blank slate, where you can design the syntax that ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.