Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Playing with Sorbet
Search
Luciano Sousa
September 12, 2019
Programming
0
40
Playing with Sorbet
A short presentation about how Sorbet could help your project
Luciano Sousa
September 12, 2019
Tweet
Share
More Decks by Luciano Sousa
See All by Luciano Sousa
Knowing mina deploy
lucianosousa
1
54
Creating your startup without Developer
lucianosousa
0
150
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
96
The Patterns Falacy - Rails Version
lucianosousa
1
91
Sinatra::Ftw
lucianosousa
0
81
Other Decks in Programming
See All in Programming
デフォルトにして至高、RubyMineの大好きな所
ruzia
0
980
Milestoner
bkuhlmann
1
420
見た目から始める生産性向上
ikumatadokoro
10
1.5k
Ruby Function Composition
bkuhlmann
1
340
Deep Dive into React Stream/Serialize
mugi_uno
3
730
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
330
Anthropic Cookbook のおすすめレシピ
schroneko
7
1.3k
Compose-View Interop in Practice (mDevCamp 2024)
stewemetal
0
170
Elm 0.19.0 Changes
bkuhlmann
0
510
Node.js v22 で変わること
yosuke_furukawa
PRO
12
4k
2 週間で Twitter Bot を作ってみた
contour_gara
0
790
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
280
Featured
See All Featured
Making Projects Easy
brettharned
109
5.5k
Designing Experiences People Love
moore
136
23k
What's in a price? How to price your products and services
michaelherold
238
11k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
Happy Clients
brianwarren
92
6.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
17
2.7k
Raft: Consensus for Rubyists
vanstee
133
6.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
20
1.8k
A Modern Web Designer's Workflow
chriscoyier
689
190k
GraphQLの誤解/rethinking-graphql
sonatard
56
9.3k
Agile that works and the tools we love
rasmusluckow
325
20k
Automating Front-end Workflow
addyosmani
1357
200k
Transcript
Playing with Sorbet
What
Sorbet is a fast, powerful type checker designed for Ruby.
Why
Once upon a time
We expose a public API
Expecting params = { user: { first_name: "Luciano", last_name: "Sousa"
} }
We got a
params = { user: "a" }
TypeError (no implicit conversion of Symbol into Integer)
None
NoMethodError (undefined method `where' for nil:NilClass)
Let’s talk about Java
None
Let’s talk about dynamic vs static typed languages
• •
• • •
String javaString = new String(“I am a Java string”) ruby_string
= “I am a Ruby string”
Dynamic languages
Ruby
Examples
begin do_something rescue StandardErro do_something_else end
Tests
Let's talk about Shopify
~1500 devs
~40 deploys/day
~5 million req/min
~83k req/sec ~170k req/sec peak
Sorbet at Shopify
~36 issues fixed
~17 dead code never hit
~16 name error
~3 wrong args
Maybe some millions
Examples
“I hate type annotations.”
class UserHelper def name_length(name) name.length end end
# typed: true class UserHelper def name_length(name) name.length end end
# typed: true class UserHelper extend T::Sig def name_length(name) name.length
end end
# typed: true class UserHelper extend T::Sig sig { params(name:
String).returns(Integer) } def name_length(name) name.length end end
How it works
Disclaimer
None
# typed: true
None
extend T::Sig
sig { params(name: String).returns(Integer) }
sig { params(name: String).returns(Integer) }
Resources •
Resources •
Resources •
Resources •
Thanks!