Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RubyConf AU 2014: http://www.rubyconf.org.au From time to time, when building Ruby apps, you realise there are no libraries available for what you need. Even worse, Ruby doesn't quite perform as quickly as we would expect in certain areas. There are, however, a lot of high performance, mature technologies built in C that can easily be ported to be used with Ruby. By doing this, we get to keep using our favourite language, opening it to a plethora of applications that were not possible before, and still keep things snappy. In this talk, I will walk you through the ins and outs of building Spyglass, an OpenCV binding for Ruby. I will also talk in detail about some gotchas (memory management, lack of threading), good practices (C objects as first class citizens, how to properly test extensions), why mkmf needs to be retired and some great examples of extensions you probably already use and should be looking at.
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
The video titled **Building C Extensions in Ruby**, presented by André Medeiros at RubyConf AU 2014, explores the integration of C extensions to enhance Ruby's performance, particularly for demanding processing tasks. The talk begins with an analogy to aviation to emphasize the iterative process of development and the necessity of C extensions for speeding up Ruby in certain heavy computational contexts. The main points addressed throughout the video include: - **Rationale for C Extensions**: Ruby, while powerful, may not be suitable for high-performance tasks like parsing data or processing images. C extensions allow developers to leverage existing C libraries to enhance functionality and performance without abandoning Ruby. - **Simplicity of Building Extensions**: Medeiros explains that creating C extensions is accessible, encouraging developers with basic C knowledge to participate. A hands-on example, `bundle gem`, showcases initial setup—emphasizing that understanding a few C concepts is sufficient to start. - **Memory Management and Method Definition**: Key considerations for memory allocation and method creation are outlined, including the necessity to inform Ruby about memory usage. Examples of C method declarations are provided, illustrating how to define methods that function similarly to Ruby's methods (like `say_hi`). - **Good Practices**: A set of guidelines for building C extensions is introduced: define the API shape early, return 'self' to allow method chaining, implement bang methods for performance, and recognize the differences in conventions between Ruby and C. - **Debugging and Advanced Topics**: Medeiros discusses debugging using gdb and the advantages of concurrency in C extensions compared to Ruby's Global VM Lock (GVL). He addresses garbage collection strategies and shares insights from his experience transitioning from C to Ruby, particularly when working with OpenCV. In conclusion, using C extensions in Ruby can significantly boost application performance while maintaining Ruby's simplicity and readability. The insights shared by Medeiros, alongside practical examples and a focus on good practices, empower developers to explore the functionalities of C to enhance their Ruby applications.
Suggest modifications
Cancel