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
280
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
良いユニットテストを書こう
mototakatsu
11
3.5k
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
340
Jaspr Dart Web Framework 박제창 @Devfest 2024
itsmedreamwalker
0
140
Оптимизируем производительность блока Казначейство
lamodatech
0
880
テストケースの名前はどうつけるべきか?
orgachem
PRO
1
180
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
210
KubeCon NA 2024の全DB関連セッションを紹介
nnaka2992
0
110
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
260
CloudflareStack でRAGに入門
asahiiwm
0
150
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
210
サーバーゆる勉強会 DBMS の仕組み編
kj455
1
200
テストコード書いてみませんか?
onopon
2
290
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.5k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
171
50k
Side Projects
sachag
452
42k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
2
160
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
940
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Embracing the Ebb and Flow
colly
84
4.5k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
BBQ
matthewcrist
85
9.4k
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