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
42
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
57
Creating your startup without Developer
lucianosousa
0
150
Patterns Falacy v2
lucianosousa
0
110
Project Management like Software Developer
lucianosousa
1
100
The Patterns Falacy - Rails Version
lucianosousa
1
94
Sinatra::Ftw
lucianosousa
0
84
Other Decks in Programming
See All in Programming
Swiftコードバトル必勝法
toshi0383
0
170
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
820
Rubyとクリエイティブコーディングの輪の広がり / The Growing Circle of Ruby and Creative Coding
chobishiba
1
270
Google Sign-inの移行から始めるCredential Manager活用
clockvoid
0
410
Crafting Cross-Platform Adventures: Building a Game Engine with Kotlin Multiplatform
dwursteisen
0
210
『ドメイン駆動設計をはじめよう』中核の業務領域
masuda220
PRO
5
1k
LangChainの現在とv0.3にむけて
os1ma
4
940
ドメイン駆動設計を実践するために必要なもの
bikisuke
4
330
Understand the mechanism! Let's do screenshots tests of Compose Previews with various variations / 仕組みから理解する!Composeプレビューを様々なバリエーションでスクリーンショットテストしよう
sumio
3
850
Pythonで改めて考える「クラス(class)」の使いどころ
os1ma
4
980
いまから追い上げる、Jetpack Compose トレーニング
nyafunta9858
0
620
GoのIteratorに詳しくなってしまう
inatonix
1
210
Featured
See All Featured
Statistics for Hackers
jakevdp
794
220k
No one is an island. Learnings from fostering a developers community.
thoeni
18
2.9k
Building Adaptive Systems
keathley
36
2.1k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
158
15k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
28
1.6k
Fontdeck: Realign not Redesign
paulrobertlloyd
80
5.1k
Clear Off the Table
cherdarchuk
91
320k
Unsuck your backbone
ammeep
667
57k
[RailsConf 2023] Rails as a piece of cake
palkan
48
4.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
58k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
230
17k
How to train your dragon (web standard)
notwaldorf
85
5.6k
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!