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
57
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
95
Sinatra::Ftw
lucianosousa
0
84
Other Decks in Programming
See All in Programming
良いユニットテストを書こう
mototakatsu
8
2.7k
Zoneless Testing
rainerhahnekamp
0
120
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
400
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
220
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
5
720
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
940
Security_for_introducing_eBPF
kentatada
0
110
Spatial Rendering for Apple Vision Pro
warrenm
0
110
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
220
Featured
See All Featured
Docker and Python
trallard
42
3.1k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Optimising Largest Contentful Paint
csswizardry
33
3k
Mobile First: as difficult as doing things right
swwweet
222
9k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
A better future with KSS
kneath
238
17k
Visualization
eitanlees
146
15k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Optimizing for Happiness
mojombo
376
70k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
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!