JRuby: Elegant Java Integration Solves External Library Headaches
At RubyKaigi, the author encountered difficulties using external libraries in Ruby: C libraries require writing C extensions or FFI bindings, while other languages pose even greater challenges. Examples like Charty (wrapping matplotlib) and QuickChart (implemented in JavaScript) highlighted the clumsiness of existing solutions. The author proposes a more elegant approach: leveraging JRuby's Java integration. Using JFreeChart as an example, the article demonstrates how to create charts effortlessly without writing Java, C, Python, or JavaScript code. It details JRuby's Java integration layer, including managing dependencies with `jar-dependencies`, calling Java classes, and creating simple bar and pie charts. The author concludes with an encouragement to experiment with JRuby and support its continued development.
Read more