Ruby Learning by Reversing: Series 1 - Native Gems

In this series of posts, I want to look at how to create a native gem for Ruby in C. Actually, it would be more accurate to say – I want to look at how a native gem has been created in C for Ruby. So, I will look at one native gem and we will reverse back and understand what has been done and what it means.

The series is broken up into multiple smaller posts and this post will be updated with the links to the posts as they get done.

  • Part 1: Introductions and Background to the gem that we will look at in this series. It covers the environment, unpacking the gem, getting the source, and changing, rebuilding and installing the gem.
  • Part 2: This goes into the details of how the native gem and extension is loaded.
  • Part 3: This examines how the bits work together and set things up so the native extension is built during gem installation.
  • Part 4: This covers the development Makefile (including for Windows).
  • Part 5: This part looks at how the C code interfaces with Ruby.
  • Part 6: Creating and running a benchmark to compare the original and optimised versions.
  • Part 7: Documenting native code.

Future parts will cover topics such as:

  • How the specs are run and what they test

Finally, we look at enhancing the gem:

  • Providing an executable
  • A gem that also works on JRuby
  • Making the gem ractor friendly
  • Patching an existing gem rather than adding a new module

So, stay tuned! I will add links and references later, possibly in the last post of the series. If you have any comments, please feel free to leave them below. You can also connect with me on Twitter or Mastodon

comments powered by Disqus