Native Extensions
Extending languages with C. In Python: https://docs.python.org/2/extending/extending.html, in Ruby: http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions.
3 flashcards · Programming Languages · by lakesare
What's a native extension?
Native extension is just a gem which is written (entirely or partially) in C. However, the term really just means "includes some code that needs to be compiled for your machine". The code is compiled and linked so that the resulting executable file can be required by Ruby on the machine.
Name 2 reasons for creating native extensions.
The usual reasons for writing a Ruby C or C++ extension are: Speed. For some CPU-intense tasks, C code can be 100 times faster than Ruby. In this case a native extension can be completely stand-alone with all C source code included in the gem. Third-party library already written in C. In this case the gem will have C source code that binds the library functions into Ruby modules, classes and methods.
Example of a directory structure for Ruby's gems when gem uses native extensions: