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
320
0
Share
Going Native with FFI
Slides of my Talk given at RubyConf Colombia 2019
Juan Carlos Ruiz González
September 20, 2019
More Decks by Juan Carlos Ruiz González
See All by Juan Carlos Ruiz González
Por qué elegir Rails en 2024
juancrg90
0
13
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
140
Going Native With FFI - Euruko 2021
juancrg90
0
58
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
実践CRDT
tamadeveloper
0
350
Reactive ❤️ Loom: A Forbidden Love Story
franz1981
2
220
ローカルで稼働するAI エージェントを超えて / beyond-local-ai-agents
gawa
2
260
Codex CLIのSubagentsによる並列API実装 / Parallel API Implementation with Codex CLI Subagents
takatty
2
860
Swift Concurrency Type System
inamiy
0
320
L’IA au service des devs : Anatomie d'un assistant de Code Review
toham
0
210
実践ハーネスエンジニアリング #MOSHTech
kajitack
7
6k
Mastering Event Sourcing: Your Parents Holidayed in Yugoslavia
super_marek
0
150
How Swift's Type System Guides AI Agents
koher
0
160
Xdebug と IDE による デバッグ実行の仕組みを見る / Exploring-How-Debugging-Works-with-Xdebug-and-an-IDE
shin1x1
0
340
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
2
150
条件判定に名前、つけてますか? #phperkaigi #c
77web
2
970
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
Skip the Path - Find Your Career Trail
mkilby
1
100
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Producing Creativity
orderedlist
PRO
348
40k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
500
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Building the Perfect Custom Keyboard
takai
2
720
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
240
Being A Developer After 40
akosma
91
590k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
210
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