Google Summer of Code 2018: Chapter 1: The One Constant in Life
First published on my old blog, The Silent Monk’s Retreat.
Before you move any further, make sure that you have read the preceding post here.
There is a single constant in life and that constant is change.
It has been 14 days since the Summer of code Programme commenced and my project has changed considerably.
Initially, I planned to create a plotting library from the scratch. We divided the plotting project into two sub-projects. A dynamic plotting library that was written in pure Ruby and a static plotting library whose backend layer would be written in C++, I chose the latter.
Upon a lot of discussion with the community, I decided to start creating the backend in GR Framework, which is an excellent plotting library, still in early stages of its development. And since it is in the early stages, I was not able to find a lot of examples for the same.
So in the interest of time, I decided to start creating the backend with Cairo as a renderer (which was a renderer that I was familiar with), while I explored GR Framework.
GR framework turned out to be a fully fledged plotting library than a Raster graphic renderer, using it as a framework would be similar to using matplotlib as a renderer.
Upon discussion with my mentors and email exchanges with the developer of GR Framework, I realized that GR framework is the cross-language library that I was striving to create.
So we decided that my project would be to extend the C API of GR framework to Ruby. This meant that I would have to ditch weeks of my research and start anew, but I guess that is the kind of adaptability that I can expect in real-world projects. I had to gain my footing fast and quick.
I quickly went through a lot of online resources about creating a Ruby wrapper for a C library. There were 3 options:
- Ruby Inline
- Fiddle/FFI
- C extensions
Ruby Inline seemed to be a good option to have a small C module in a Ruby code but did not seem feasible to create a wrapper.
Fiddle and FFI are packages in Ruby to create Ruby wrappers around C code. Although FFI has been in use for a longer time, Fiddle is a module from the standard library of Ruby, whereas FFI is an external module
Work with Fiddle hit a dead end because of the lack of online examples and sparse documentation. So I started working with FFI which was well documented, but certain examples in my code caused the interpreter to crash. I needed to work with the Ruby Interpreter on a more fundamental level.
So with the valuable advice of my mentors, I finally decided to create C Extensions to GR Framework.


The details to the same are discussed in this blog post which I have written in a generalized way so that it can be relevant to someone looking for help with C extensions in the future.
You can expect the next blog post to drop around 10 June 2018.