Space Vatican

Ramblings of a curious coder

Ruby Bindings for Liblinear

There are already some ruby bindings but I’ve written my own.

I mostly did this for fun, but I think swig sometimes gives you slightly unnatural feeling interfaces, because you’re focussing too much on mapping C++ classes to your ruby classes. For example some liblinear methods take a struct param argument. liblinear-ruby-swig mirrors this by proving an LParameter class that maps onto this:

  param = => 1, :eps => 0.01)
  model =, param)

but I’d rather write:

  model = problem, :c => 1, :eps => 0.01

I imagine that SWIG must incur some sort of overhead but I would have thought that was pretty negligible for something like liblinear where most of the heavy lifting happens in the library being wrapped.