$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Going Native with FFI
Search
Juan Carlos Ruiz González
September 20, 2019
Programming
0
300
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
10
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
130
Going Native With FFI - Euruko 2021
juancrg90
0
53
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
5
14k
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
500
20 years of Symfony, what's next?
fabpot
2
220
connect-python: convenient protobuf RPC for Python
anuraaga
0
330
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
340
「文字列→日付」の落とし穴 〜Ruby Date.parseの意外な挙動〜
sg4k0
0
330
スタートアップを支える技術戦略と組織づくり
pospome
8
14k
jakarta-security-jjug-ccc-2025-fall
tnagao7
0
100
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
130
Google Antigravity and Vibe Coding: Agentic Development Guide
mickey_kubo
2
110
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
160
Web エンジニアが JavaScript で AI Agent を作る / JSConf JP 2025 sponsor session
izumin5210
4
2.1k
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Typedesign – Prime Four
hannesfritz
42
2.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Rails Girls Zürich Keynote
gr2m
95
14k
Designing Experiences People Love
moore
142
24k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Making Projects Easy
brettharned
120
6.5k
Embracing the Ebb and Flow
colly
88
4.9k
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