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
さっちゃん
March 23, 2017
Programming
1.7k
1
Share
最速で最速の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
15
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.7k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.4k
path 依存型って何?
ne_sachirou
0
800
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
700
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
120
名實一致
ne_sachirou
0
730
まかれるあなとみあ ―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
ハーネスエンジニアリングとは?
kinopeee
13
6.3k
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
170
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
120
Running Swift without an OS
kishikawakatsumi
0
860
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
150
Oxlintとeslint-plugin-react-hooks 明日から始められそう?
t6adev
0
290
GitHubCopilotCLIをはじめよう.pdf
htkym
0
290
AI-DLC Deep Dive
yuukiyo
9
4.9k
TiDBのアーキテクチャから学ぶ分散システム入門 〜MySQL互換のNewSQLは何を解決するのか〜 / tidb-architecture-study
dznbk
1
190
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
150
Programming with a DJ Controller — not vibe coding
m_seki
3
470
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
440
Featured
See All Featured
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
310
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
240
Writing Fast Ruby
sferik
630
63k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
500
The Language of Interfaces
destraynor
162
26k
Ethics towards AI in product and experience design
skipperchong
2
260
HDC tutorial
michielstock
2
640
GitHub's CSS Performance
jonrohan
1032
470k
Become a Pro
speakerdeck
PRO
31
5.9k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
310
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化をマテ!