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
290
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
Develop Faster With FrankenPHP
dunglas
1
2.1k
remix + cloudflare workers (DO) docker上でいい感じに開発する
yoshidatomoaki
0
110
体得しよう!RSA暗号の原理と解読
laysakura
3
510
爆速スッキリ! Rspack 移行の成果と道のり - Muddy Web #11
dora1998
0
140
Preact、HooksとSignalsの両立 / Preact: Harmonizing Hooks and Signals
ssssota
1
480
Fluent UI Blazor 5 (alpha)の紹介
tomokusaba
0
130
SLI/SLOの設定を進めるその前に アラート品質の改善に取り組んだ話
tanden
2
670
GDG Super.init(version=6) - From Where to Wear : 모바일 개발자가 워치에서 발견한 인사이트
haeti2
0
540
CTFのWebにおける⾼難易度問題について
hamayanhamayan
1
930
S3静的ホスティング+Next.js静的エクスポート で格安webアプリ構築
iharuoru
0
190
Compose Navigation実装の見通しを良くする
hiroaki404
0
170
PHPer's Guide to Daemon Crafting Taming and Summoning
uzulla
2
920
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
28
2k
Unsuck your backbone
ammeep
669
57k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
4 Signs Your Business is Dying
shpigford
183
22k
A designer walks into a library…
pauljervisheath
205
24k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.5k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
The Cost Of JavaScript in 2023
addyosmani
48
7.6k
Automating Front-end Workflow
addyosmani
1369
200k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.6k
BBQ
matthewcrist
88
9.5k
Docker and Python
trallard
44
3.3k
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