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
Juan Carlos Ruiz González
September 20, 2019
Programming
0
270
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
6
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
110
Going Native With FFI - Euruko 2021
juancrg90
0
49
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
Amazon Qを使ってIaCを触ろう!
maruto
0
420
CSC509 Lecture 11
javiergs
PRO
0
180
CSC509 Lecture 12
javiergs
PRO
0
160
Jakarta EE meets AI
ivargrimstad
0
210
Click-free releases & the making of a CLI app
oheyadam
2
120
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
RubyLSPのマルチバイト文字対応
notfounds
0
120
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
710
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2k
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
Statistics for Hackers
jakevdp
796
220k
A better future with KSS
kneath
238
17k
How GitHub (no longer) Works
holman
310
140k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
4 Signs Your Business is Dying
shpigford
180
21k
Gamification - CAS2011
davidbonilla
80
5k
What's in a price? How to price your products and services
michaelherold
243
12k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Side Projects
sachag
452
42k
Producing Creativity
orderedlist
PRO
341
39k
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