Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
New runtimes, technologies and languages keep popping up, and there is a need for libraries that work across language, and across runtimes. This talk will contrast some of the ways to build a native (usually C/C++) extension, and integrate them with your application. We'll look at how to build a native extension, while staying within the paradigm of the language. We will be covering (in some detail): * Native C extensions using MRI/Rbx APIs (and contrasting it with the python API possibly) * SWIG to automatically generate wrapper code * FFI to build libraries that work across multiple implementations of ruby Help us caption & translate this video! http://amara.org/v/FG4P/
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the talk 'Native Extensions Served Three Ways' by Tejas Deinkar at Garden City Ruby 2014, the focus is on building native extensions in Ruby and how to integrate them effectively within applications. The presentation primarily covers three methods: C extensions, Foreign Function Interface (FFI), and SWIG (Simplified Wrapper and Interface Generator). Key Points Discussed: - **Introduction to Native Extensions**: Tejas highlights the importance of building native extensions to interact with new libraries, enhance performance, and leverage existing C/C++ libraries within Ruby applications. - **C Extensions**: The talk emphasizes the straightforward nature of creating Ruby C extensions using the 'ruby.h' header. It discusses the significance of memory management and the use of macros for handling memory correctly, given Ruby's garbage collection system. - **FFI**: FFI allows Ruby to interact with C libraries easily, without the complexity of C extensions. Tejas explains how FFI offers automatic conversion between Ruby types and C primitives, which facilitates the integration of native libraries across various Ruby implementations. - **SWIG**: SWIG is introduced as a tool that automates the process of generating wrapper code for C and C++ libraries. By annotating header files, developers can produce bindings for multiple languages, including Ruby and Python. Tejas mentions the initial overhead of setup but stresses the long-term advantages it provides for cross-language integrations. - **Performance Considerations**: The speaker addresses the need to manage the Global Interpreter Lock (GIL) when writing native extensions for Ruby, especially during long-running tasks, to ensure thread safety. - **Testing Native Extensions**: Tejas discusses the varying methods to test native extensions based on their functionality, with a recommendation for mocking external dependencies for database connections while using integration tests for simpler functionalities. In conclusion, Tejas Deinkar emphasizes that native extensions can be built effectively with C extensions, FFI, and SWIG. For those not maintaining a library, FFI is often the simplest choice. For developers involved in multiple language support, SWIG presents a compelling option. This talk equips developers with the foundational knowledge and practical tools needed to integrate native extensions within their Ruby applications.
Suggest modifications
Cancel