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
Going Native with FFI
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Juan Carlos Ruiz González
September 20, 2019
Programming
0
310
Going Native with FFI
Slides of my Talk given at RubyConf Colombia 2019
Juan Carlos Ruiz González
September 20, 2019
Tweet
Share
More Decks by Juan Carlos Ruiz González
See All by Juan Carlos Ruiz González
Por qué elegir Rails en 2024
juancrg90
0
12
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
130
Going Native With FFI - Euruko 2021
juancrg90
0
57
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
150
How to stabilize UI tests using XCTest
akkeylab
0
130
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
140
nilとは何か 〜interfaceの構造とnil!=nilから理解する〜
kuro_kurorrr
3
1.9k
ふつうの Rubyist、ちいさなデバイス、大きな一年
bash0c7
0
940
20260315 AWSなんもわからん🥲
chiilog
2
150
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.3k
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
2
750
AIコードレビューの導入・運用と AI駆動開発における「AI4QA」の取り組みについて
hagevvashi
0
460
AIとペアプロして処理時間を97%削減した話 #pyconshizu
kashewnuts
1
230
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
180
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
170
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
380
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
150
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
680
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Practical Orchestrator
shlominoach
191
11k
Designing for Performance
lara
611
70k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
3.7k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Transcript
GOING NATIVE WITH FFI Juan C. Ruiz
❏ Former software engineer @ MagmaLabs ❏ Remote work advocate
❏ RubyMe Q2 mentor ❏ I ❤ Open source @JuanCrg90
@JuanCrg90 Heroes' Causeway Arch Leon Guanajuato Photo By @marianozka
@JuanCrg90
@JuanCrg90
What are the options that we have to manage native
code on Ruby? @JuanCrg90
MKMF @JuanCrg90
@JuanCrg90 mkmf.rb is used by Ruby C extensions to generate
a Makefile which will correctly compile and link the C extension to Ruby and a third-party library.
library.h library.c @JuanCrg90
my_ruby_ext.c @JuanCrg90
extconf.rb @JuanCrg90
@JuanCrg90
@JuanCrg90
Pros: - We can use C functions in our Ruby
Code - We take advantage of the existing ruby.h library to create the extension Cons: - We need to add extra C code to create the bindings - This solution only works in MRI @JuanCrg90
FFI @JuanCrg90
A foreign function interface (FFI) is a mechanism by which
a program written in one programming language can call routines or make use of services written in another. @JuanCrg90
@JuanCrg90
Pros: - We don’t need to add additional C code
- An FFI extension is multi-platform and multi-implementation Cons: - Complex macros are difficult to maintain - Same for callback functions @JuanCrg90
PGM IMAGES @JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
@JuanCrg90
Conclusion @JuanCrg90
- https://github.com/JuanCrg90/my_ruby_ext - https://github.com/JuanCrg90/pgm_ffi @JuanCrg90
THANKS @JuanCrg90