$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
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
11
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
130
Going Native With FFI - Euruko 2021
juancrg90
0
56
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
dotfiles 式年遷宮 令和最新版
masawada
1
750
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
120
Integrating WordPress and Symfony
alexandresalome
0
150
JETLS.jl ─ A New Language Server for Julia
abap34
1
340
Cell-Based Architecture
larchanjo
0
110
connect-python: convenient protobuf RPC for Python
anuraaga
0
400
WebRTC と Rust と8K 60fps
tnoho
2
1.9k
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
6
2.1k
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
120
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
500
AWS CDKの推しポイントN選
akihisaikeda
1
240
生成AIを利用するだけでなく、投資できる組織へ
pospome
1
270
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.8k
RailsConf 2023
tenderlove
30
1.3k
[SF Ruby Conf 2025] Rails X
palkan
0
500
Designing for humans not robots
tammielis
254
26k
Visualization
eitanlees
150
16k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
700
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
For a Future-Friendly Web
brad_frost
180
10k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Code Reviewing Like a Champion
maltzj
527
40k
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