Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Going Native with FFI
Search
Juan Carlos Ruiz González
September 20, 2019
Programming
330
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
23
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
150
Going Native With FFI - Euruko 2021
juancrg90
0
68
Ecommerce en Rails con Solidus
juancrg90
0
130
Other Decks in Programming
See All in Programming
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
430
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
880
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
180
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
200
Event is what happens
moro
2
770
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
920
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.9k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.6k
How to Talk to Developers About Accessibility
jct
2
580
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
Skip the Path - Find Your Career Trail
mkilby
1
260
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
600
Between Models and Reality
mayunak
4
500
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
800
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Marketing to machines
jonoalderson
1
5.9k
BBQ
matthewcrist
90
10k
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