Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Typing for core classes in Ruby 3 #118

Closed
jaredcwhite opened this issue Jul 30, 2020 · 7 comments
Closed

feat: Typing for core classes in Ruby 3 #118

jaredcwhite opened this issue Jul 30, 2020 · 7 comments
Labels
process Improve the development process for the repo ruby3 Enhancements and bugfixes related to Ruby 3 support

Comments

@jaredcwhite
Copy link
Member

Ruby 3 will introduce a form of type checking, using the RBS type signature language.

More info here: https://developer.squareup.com/blog/the-state-of-ruby-3-typing/

I think we have an wonderful opportunity before us to get the core classes of Bridgetown ready for Ruby 3 typing so that folks developing plugins and other extensions to Bridgetown will get code completion and other useful info in their IDEs, and we'll get a small measure of greater confidence in our code quality.

Don't misunderstand me — I am hardly an advocate for strict typing. I absolutely love Ruby's dynamic typing and don't want to do anything to move away from that center. But adding type signatures for things like Site, Document, Renderer, etc. should require minimal (if any) alterations to existing code, while at the same time allowing us to typecheck those classes and provide downstream DX enhancements.

I welcome your thoughts and feedback.

@jaredcwhite jaredcwhite added the process Improve the development process for the repo label Jul 30, 2020
@KonnorRogers
Copy link
Member

I love this idea. I think typing for libraries and frameworks is key to allow new users to grok what's happening without having to dig through source code. It appears it will also leverage Ruby's dynamic nature without being too stringent. I'm in full support 👍

@andrewmcodes
Copy link
Contributor

I tried it and I am not a big fan to my own surprise. I thought Sorbet fell pretty short of what a good type checking solution in Ruby would be but was pretty disappointed with RBS.

In my opinion, don't reach for it until you have a pain so great you can't solve it with tests or some other tool. I think there will be a lot of churn with Ruby types so I worry about the effects it could have on maintainability if introduced here.

@jaredcwhite
Copy link
Member Author

@andrewmcodes The bigger win right now is definitely to add the Yard/Solargraph comments to more classes & methods so that we get good tooltip/autocompletion in IDEs, but I'm looking forward to playing with RBS more down the road. I don't like Sorbet at all, so we're in agreement there. :)

@andrewmcodes
Copy link
Contributor

I vote yard - much wider adoption

@andrewmcodes
Copy link
Contributor

I have come around a bit on this. RBS is becoming more appealing as my disdain for sorbets sig methods grows 😬

@jaredcwhite jaredcwhite added the ruby3 Enhancements and bugfixes related to Ruby 3 support label Dec 10, 2020
@jaredcwhite
Copy link
Member Author

jaredcwhite commented Dec 10, 2020

Just adding a note here that I'm probably going to wait until there's a way to automatically generate the RBS files off of the YARD docs and go that route…I like using YARD comments and there's already an effort to beef that up across the board (#47).

@jaredcwhite
Copy link
Member Author

Closing this issue for the time being – I'm not seeing the YARD > Sord > RBS pipeline moving along very quickly, so it may take some time before the ecosystem becomes more mature. In the meantime, focusing on good YARD docs and improving tests feels like the bigger win.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process Improve the development process for the repo ruby3 Enhancements and bugfixes related to Ruby 3 support
Projects
None yet
Development

No branches or pull requests

3 participants