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
最速で最速のRuby擴張を作る
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
さっちゃん
March 23, 2017
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
最速で最速のRuby擴張を作る
CrystalでRubyの擴張を書く
https://github.com/ne-sachirou/sample_ruby_extension_in_crystal
さっちゃん
March 23, 2017
More Decks by さっちゃん
See All by さっちゃん
火星曆
ne_sachirou
0
26
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.7k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.4k
path 依存型って何?
ne_sachirou
0
830
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
730
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
130
名實一致
ne_sachirou
0
740
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3.3k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
1.1k
Other Decks in Programming
See All in Programming
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
2
620
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
140
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
540
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
110
Lessons from Spec-Driven Development
simas
PRO
0
180
AIで効率化できた業務・日常
ochtum
0
130
RTSPクライアントを自作してみた話
simotin13
0
600
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
400
ふつうのFeature Flag実践入門
irof
7
3.8k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
740
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
270
A2UI という光を覗いてみる
satohjohn
1
130
Featured
See All Featured
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
sira's awesome portfolio website redesign presentation
elsirapls
0
280
The agentic SEO stack - context over prompts
schlessera
0
820
We Have a Design System, Now What?
morganepeng
55
8.2k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
210
Documentation Writing (for coders)
carmenintech
77
5.4k
From π to Pie charts
rasagy
0
210
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
590
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.3k
Transcript
最速で最速の Ruby擴張を作る
.。oO(さっちゃんですよヾ(〃l _ l)ノ゙☆)
Ruby
Ruby 最速で開發出來る⾔語
None
Crystal
Crystal LLVMでcompile出來るRuby-likeな⾔語
Crystal LLVMでcompile出來るRuby-likeな⾔語 Ruby-likeなsyntax 型推論 macroによるDSL Cのlibをそのまま使へる → 最速の開發
Crystal LLVMでcompile出來るRuby-likeな⾔語 型による最適化 LLVMによる最適化 macroによるcompile時計算 Cのlibをover head無く使へる → 最速の實⾏
Rubyの實⾏速度が遅い
Rubyの實⾏速度が遅い ↓ Cで擴張を作る
Rubyの實⾏速度が遅い ↓ Cで擴張を作る ↓ 實⾏速度は速く成ったが 開發速度が遅く成った
Rubyのeco systemに頼りながら 開發速度を落とさず 遲い部分をCrystalで速く出來ないだらうか
既存の試み manastech/crystal_ruby 頑張る前に放棄されてゐる 全然使へない 動かない phoffer/crystalized_ruby 頑張った跡 rb_define_module_function等を⼿動で呼ばなければならない もう動かない
♥ Ruby meets Crystal ♥ ne-sachirou/sample_ruby_extension_in_crystal
ne-sachirou/sample_ruby_extension_in_crystal ruby hello_cr, def hello_cr : Nil puts "Hello, World!”
end hello_cr
ne-sachirou/sample_ruby_extension_in_crystal ruby Fib, module Fib def self.fib_cr(n : Int32) :
Int32 (1..n-1).reduce([1,1]){|ns|[ns[1],ns[0]+ns[1]]}[1] end end p Fib.fib_cr
ne-sachirou/sample_ruby_extension_in_crystal Benchmark 同じalgorithmで、fibonacci數列の31番⽬を100万回計算する def self.fib_rb(n) ns = [1, 1] i
= 1 while i < n ns0 = ns[0] ns[0] = ns[1] ns[1] = ns0 + ns[1] i += 1 end ns[1] end
ne-sachirou/sample_ruby_extension_in_crystal Benchmark 同じalgorithmで、fibonacci數列の31番⽬を100万回計算する C 0.1秒
ne-sachirou/sample_ruby_extension_in_crystal Benchmark 同じalgorithmで、fibonacci數列の31番⽬を100万回計算する C 0.1秒 Ruby 3.0秒
ne-sachirou/sample_ruby_extension_in_crystal Benchmark 同じalgorithmで、fibonacci數列の31番⽬を100万回計算する C 0.1秒 Ruby 3.0秒 Crystal 0.2秒
ne-sachirou/sample_ruby_extension_in_crystal macro ruby(name, code) {{ code }} {% if code.class_name
== "Def" %} Ruby.ruby_def {{ name }}, {{ code }} {% elsif code.class_name == "ModuleDef" %} Ruby.ruby_module_def {{ name }}, {{ code }} {% end %} end LLVMで速いbinaryを作る ⾃動でRubyにmodule/methodを登録する `rake compile`
ne-sachirou/sample_ruby_extension_in_crystal gem化をマテ!