RBS, Ruby’s new type signature language
41–50 of 340 posts
Re: RBS, Ruby’s new type signature language
#42At some point it makes more sense to switch to Crystal.
Crystal is amazing (we sponsor it at Fly.io), but the sheer amount of stuff that's already built for Ruby makes it hard to switch to another language. Node has had 10 years and its still not there.
And never will be.
Re: RBS, Ruby’s new type signature language
#43At some point it makes more sense to switch to Crystal.
And then you get stuck in very opaque error loops with the typing where it's expecting eg. a Number. no, not that number, a different type of number. no, not that type either. no, not that type. Most the code i've written has been typecasting.
Crystal does have some significant benefits over Ruby (which is why i'm using it - better memory use, better for scaling for my purpose) but I just spent time rewriting the non-user facing, non-scaling part of the bot in Ruby so I could actually get stuff done instead of fighting the language.
Of course a lot of this might be my inexperience with Crystal, but as a Ruby dev for 13 years, it's not as easy as just switching over from Ruby to Crystal. I've had this bot running 4 years and it hasn't got any easier for me.
Re: RBS, Ruby’s new type signature language
#44How does this compare to the sorbet project? Is it two different implementations for the same goal or is it adding support in ruby so sorbet can also benefit?
The sorbet project has an FAQ about that (I was curious too): https://sorbet.org/docs/faq search for “RBS” (on mobile, no deep links)
Re: RBS, Ruby’s new type signature language
#45Anyone know, or have a guess, what RBS stands for? I'm not finding it in the article or library.
Re: RBS, Ruby’s new type signature language
#46Anyone know, or have a guess, what RBS stands for? I'm not finding it in the article or library.
Re: RBS, Ruby’s new type signature language
#47Earlier quoted context omitted.
But as I mentioned the downside of this is that any mistakes don't become evident until at runtime. While the python way has the same problem (they're not compiled languages after all), by inlining to the existing source there's less changes for divergence to happen.
Remember this is designed by companies that already have existing, large, ruby codebases. For them, it makes a lot of sense to be able to incrementally add typing without having to make changes to the underlying code itself.
Re: RBS, Ruby’s new type signature language
#48Separate files for types with no inline annotations possible? What an embarrassing compromise. This is all because Matz explicitly won't allow type signatures in .rb files. I wonder how long it'll be until a hostile fork if he doesn't change his mind.
Re: RBS, Ruby’s new type signature language
#49I'm not thrilled about the separate files with the type information but I completely understand why they did it, and if it were my choice I might make the same one. I don't like the comparison with TypeScript `.d.ts` files however, because TS still lets you do types inline in the code. I haven't seen it mentioned anywhere that this won't be supported by Ruby 3. Does anybody know if Ruby 3 will also support inline typ…
Re: RBS, Ruby’s new type signature language
#50Can 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.