Slide 1

Slide 1 text

Gradual Typing in Ruby A Three Year Retrospective Ufuk Kayserilioglu & Alexandre Terrasa Ruby and Rails Infrastructure

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Why static gradual typing?

Slide 4

Slide 4 text

Ruby is dynamically typed

Slide 5

Slide 5 text

We love Ruby because it is dynamic

Slide 6

Slide 6 text

Static analysis is fast and powerful

Slide 7

Slide 7 text

Are we turning Ruby into another language?

Slide 8

Slide 8 text

The codebase is HUGE

Slide 9

Slide 9 text

Gradual typing is the best middle-ground

Slide 10

Slide 10 text

Human Challenges

Slide 11

Slide 11 text

How do we make it easy for teams?

Slide 12

Slide 12 text

What benefits do teams get?

Slide 13

Slide 13 text

How can we advertise the benefits?

Slide 14

Slide 14 text

Technical Challenges

Slide 15

Slide 15 text

Ruby is a very dynamic language

Slide 16

Slide 16 text

Classes and methods are created at runtime

Slide 17

Slide 17 text

Dependencies are black boxes ?

Slide 18

Slide 18 text

How we met the challenges?

Slide 19

Slide 19 text

Built experiments to test our hypotheses

Slide 20

Slide 20 text

typed: false no syntax errors no name errors

Slide 21

Slide 21 text

typed: true less no method errors

Slide 22

Slide 22 text

We were convinced it was the right choice

Slide 23

Slide 23 text

Built a lot of tooling to make it happen

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Sorbet Metrics Internal Sorbet Adoption Dashboard

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Made progress visible

Slide 30

Slide 30 text

Sorbet Metrics

Slide 31

Slide 31 text

Show areas of concern

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Track general adoption in projects

Slide 34

Slide 34 text

Track general adoption by users

Slide 35

Slide 35 text

Core-to-true dashboard

Slide 36

Slide 36 text

Use metrics to motivate

Slide 37

Slide 37 text

Treated developers as customers

Slide 38

Slide 38 text

Periodic surveys

Slide 39

Slide 39 text

Internal guides and documentation

Slide 40

Slide 40 text

Always ready to help devs having problems

Slide 41

Slide 41 text

Learnings

Slide 42

Slide 42 text

Build Measure Learn

Slide 43

Slide 43 text

Devs are customers We are building a product for them

Slide 44

Slide 44 text

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 ^^^

Slide 45

Slide 45 text

Keep things up-to-date

Slide 46

Slide 46 text

Enforce stricter typing

Slide 47

Slide 47 text

Enforce up-to-date DSL RBIs

Slide 48

Slide 48 text

Enforce up-to-date gem RBIs

Slide 49

Slide 49 text

Be patient

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

The right tooling is an accelerator

Slide 55

Slide 55 text

Fill the gaps

Slide 56

Slide 56 text

Do NOT get in the way! Ramp up gently

Slide 57

Slide 57 text

Happy Typing! -- The Ruby Infrastructure team