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
1.7k
最速で最速のRuby擴張を作る
CrystalでRubyの擴張を書く
https://github.com/ne-sachirou/sample_ruby_extension_in_crystal
さっちゃん
March 23, 2017
Tweet
Share
More Decks by さっちゃん
See All by さっちゃん
みんなのオブザーバビリティプラットフォームを作ってるんだがパフォーマンスがやばい #mackerelio #srenext
ne_sachirou
0
1.6k
作ってよかったgraceful shutdownライブラリ #kyotogo
ne_sachirou
0
1.3k
path 依存型って何?
ne_sachirou
0
730
野生の onbording と onbording 設計 #kyototechtalk
ne_sachirou
0
670
メトリックはいかにして見え續ける樣になったか #devio2022
ne_sachirou
0
110
名實一致
ne_sachirou
0
700
まかれるあなとみあ ―Mackerel のしくみを理解する 30 分― @ Hatena Engineer Seminar #16
ne_sachirou
0
3.2k
tacit programming : Point-free, Concatenatives & J
ne_sachirou
0
1.1k
Monitoring Containerized Elixir
ne_sachirou
1
1k
Other Decks in Programming
See All in Programming
AI前提で考えるiOSアプリのモダナイズ設計
yuukiw00w
0
190
Kotlin Multiplatform Meetup - Compose Multiplatform 외부 의존성 아키텍처 설계부터 운영까지
wisemuji
0
130
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
4k
Basic Architectures
denyspoltorak
0
130
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
120
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
4
1.3k
tparseでgo testの出力を見やすくする
utgwkk
2
290
ゆくKotlin くるRust
exoego
1
160
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.3k
Cap'n Webについて
yusukebe
0
150
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
4.2k
AIエージェントの設計で注意するべきポイント6選
har1101
5
2.4k
Featured
See All Featured
The Curse of the Amulet
leimatthew05
0
4.8k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
270
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
AI: The stuff that nobody shows you
jnunemaker
PRO
1
28
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
410
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
29
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.5k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
74
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化をマテ!