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
300
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
9
Surviving to third-party integrations - Ruby Peru Meetup
juancrg90
0
130
Going Native With FFI - Euruko 2021
juancrg90
0
52
Ecommerce en Rails con Solidus
juancrg90
0
120
Other Decks in Programming
See All in Programming
請來的 AI Agent 同事們在寫程式時,怎麼用 pytest 去除各種幻想與盲點
keitheis
0
120
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
510
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
5
2.3k
はじめてのMaterial3 Expressive
ym223
2
300
Laravel Boost 超入門
fire_arlo
3
210
ソフトウェアテスト徹底指南書の紹介
goyoki
1
150
Improving my own Ruby thereafter
sisshiki1969
1
160
今だからこそ入門する Server-Sent Events (SSE)
nearme_tech
PRO
3
180
Introducing ReActionView: A new ActionView-compatible ERB Engine @ Rails World 2025, Amsterdam
marcoroth
0
690
Processing Gem ベースの、2D レトロゲームエンジンの開発
tokujiros
2
130
「待たせ上手」なスケルトンスクリーン、 そのUXの裏側
teamlab
PRO
0
510
Featured
See All Featured
How GitHub (no longer) Works
holman
315
140k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
112
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
268
13k
Making Projects Easy
brettharned
117
6.4k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Building Adaptive Systems
keathley
43
2.7k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Documentation Writing (for coders)
carmenintech
74
5k
Context Engineering - Making Every Token Count
addyosmani
2
41
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.6k
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