Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gradual Typing in Ruby - A Three Year Retrospective

Gradual Typing in Ruby - A Three Year Retrospective

Presented at RubyConf 2021

We began adopting gradual typing on Shopify's giant monolith almost 3 years ago. Today, we are running the monolith with great type coverage and even see some internal teams commit to stricter typing in their components.

The road to get here was not easy, though. We had to work with our developers to solve the right problems at the right levels of abstraction to ensure the adoption was healthy. This talk will go over some of the challenges and some of our wins along the way. It will also help you decide if gradual typing might work for your codebase and your team, as well.

Ufuk Kayserilioglu
Ufuk is the Engineering Manager of the Ruby Infrastructure and Ruby Types teams at Shopify and brings over 20 years of industry experience to the company for the adoption of better Ruby tooling and practices. He currently works remotely from Cyprus where he lives with his beloved wife and wonderful daughter.

Alexandre Terrasa
Alexandre has a PhD in computer science and specializes in typing specifications and implementations. He currently works as a Staff Engineer on the Ruby and Rails Infrastructure team at Shopify. He uses his expertise for the adoption of better Ruby tooling and practices including Sorbet and gradual typing to make the Shopify platform better for everyone. He previously worked as a core developer on the Nit language for which he implemented parts of the compiler, libraries and tools.

Ufuk Kayserilioglu

November 09, 2021

More Decks by Ufuk Kayserilioglu

Other Decks in Programming


  1. Gradual Typing in Ruby A Three Year Retrospective Ufuk Kayserilioglu

    & Alexandre Terrasa Ruby and Rails Infrastructure
  2. None
  3. Why static gradual typing?

  4. Ruby is dynamically typed

  5. We love Ruby because it is dynamic

  6. Static analysis is fast and powerful

  7. Are we turning Ruby into another language?

  8. The codebase is HUGE

  9. Gradual typing is the best middle-ground

  10. Human Challenges

  11. How do we make it easy for teams?

  12. What benefits do teams get?

  13. How can we advertise the benefits?

  14. Technical Challenges

  15. Ruby is a very dynamic language

  16. Classes and methods are created at runtime

  17. Dependencies are black boxes ?

  18. How we met the challenges?

  19. Built experiments to test our hypotheses

  20. typed: false no syntax errors no name errors

  21. typed: true less no method errors

  22. We were convinced it was the right choice

  23. Built a lot of tooling to make it happen

  24. RuboCop-Sorbet Rules for Sorbet adoption https://github.com/Shopify/rubocop-sorbet

  25. Tapioca The swiss army knife of RBI generation https://github.com/Shopify/tapioca

  26. RBI RBI generation framework https://github.com/Shopify/rbi .rbi

  27. Sorbet Metrics Internal Sorbet Adoption Dashboard

  28. Spoom Useful tools for Sorbet enthusiasts https://github.com/Shopify/spoom

  29. Made progress visible

  30. Sorbet Metrics

  31. Show areas of concern

  32. None
  33. Track general adoption in projects

  34. Track general adoption by users

  35. Core-to-true dashboard

  36. Use metrics to motivate

  37. Treated developers as customers

  38. Periodic surveys

  39. Internal guides and documentation

  40. Always ready to help devs having problems

  41. Learnings

  42. Build Measure Learn

  43. Devs are customers We are building a product for them

  44. typed: ignore = typed: debt # -- foo.rb -- #

    typed: ignore class Foo end # -- bar.rb -- # typed: false class Bar < Foo end $ dev tc bar.rb:4: Unable to resolve constant Foo 3 | class Bar < Foo ^^^
  45. Keep things up-to-date

  46. Enforce stricter typing

  47. Enforce up-to-date DSL RBIs

  48. Enforce up-to-date gem RBIs

  49. Be patient

  50. None
  51. None
  52. None
  53. None
  54. The right tooling is an accelerator

  55. Fill the gaps

  56. Do NOT get in the way! Ramp up gently

  57. Happy Typing! -- The Ruby Infrastructure team