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
43
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
58
Creating your startup without Developer
lucianosousa
0
160
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
100
The Patterns Falacy - Rails Version
lucianosousa
1
97
Sinatra::Ftw
lucianosousa
0
85
Other Decks in Programming
See All in Programming
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
9
1.8k
Introduction to kotlinx.rpc
arawn
0
700
SwiftUIで単方向アーキテクチャを導入して得られた成果
takuyaosawa
0
270
データベースのオペレーターであるCloudNativePGがStatefulSetを使わない理由に迫る
nnaka2992
0
170
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
110
Immutable ActiveRecord
megane42
0
140
GitHub Actions × RAGでコードレビューの検証の結果
sho_000
0
270
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
530
Honoとフロントエンドの 型安全性について
yodaka
7
1.3k
GAEログのコスト削減
mot_techtalk
0
120
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
7
680
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
140
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.1k
Fireside Chat
paigeccino
34
3.2k
Code Reviewing Like a Champion
maltzj
521
39k
Automating Front-end Workflow
addyosmani
1368
200k
Music & Morning Musume
bryan
46
6.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Done Done
chrislema
182
16k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
A Philosophy of Restraint
colly
203
16k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
It's Worth the Effort
3n
184
28k
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!