Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
When we occasionally reach the limits of Ruby and need the power of native extensions, we no longer have to default to C. It's easier than ever to build production-ready Rust native extensions, bringing the best of both ecosystems together!
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 this talk titled "Building native Ruby extensions in Rust" presented by Guilherme Carreiro at BalticRuby 2024, the speaker explores how leveraging the power of Rust can enhance Ruby applications by creating native extensions. Key Points Discussed: - **Introduction and Background**: Guilherme shares a bit about his upbringing in Brazil, his journey into programming, and his experience at Shopify, emphasizing the performance demand in developer tooling. - **Need for Native Extensions**: The discussion begins with reasons for using native extensions in Ruby, primarily citing performance benefits. He stresses the importance of benchmarking to ascertain whether the overhead of native extensions is justified. - **Performance Comparison**: He compares the performance of pure Ruby, FFI overhead, and Rust native extension implementations. The results illustrate that while Rust can be faster, pure Ruby can also perform commendably in some scenarios. - **Prototyping a YAML Parser**: Guilherme proposes the idea of creating a fast YAML parser in Rust to improve on existing Ruby parsers. He outlines the steps for initializing a Ruby gem and structures the native extension using Rust, highlighting key files like `cargo.toml`, `extconf.rb`, and the Rust source code located in `lib/fast_yaml.rs`. - **Integration Steps**: The talk details how to define methods in Rust that can be called from Ruby, emphasizing how to properly create and link shared objects within Ruby, which allows seamless function calling across languages. - **Handling Errors and Memory Management**: Strategies for error management and memory handling are discussed, including transforming Rust errors into Ruby exceptions and using tools like Valgrind to ensure memory health. - **Making the Gem Production-Ready**: The speaker outlines the steps needed to prepare the gem for public use, such as error handling, memory leak checks, and pre-compiling for user-friendly installation. - **Conclusion and Call to Action**: Guilherme concludes by highlighting the fate of integrating native extensions, emphasizing the balance between performance enhancement and usability improvements. The audience is invited to explore the Fast YAML gem and participate in its development. Main Takeaways: - Native extensions can significantly boost performance but require thoughtful implementation, benchmarking, and error handling. - Proper Rust and Ruby integration can unlock advanced functionalities in Ruby applications. - The speaker encourages community engagement in building and improving such tools, noting that while performance is crucial, usability must also be a priority in the development process.
Suggest modifications
Cancel