Ruby and Fortran libraries

I’ve been trying to learn Fortran for reasons of: future job security; masochism; curiousity.

Since having a REPL for a language makes learning it so much easier, I wrote one in ruby, called frepl. It is pretty buggy, and needs serious refactoring, but mostly works. After having written it, I was informed that there are other such efforts, e.g. in Python, but after cursory examination, they seem a bit less REPL-y than frepl.

I also have been interested in calling Fortran from Ruby, with the ultimate goal of perhaps being able to benefit from Fortran’s superior array-handling abilities for doing machine learning work in ruby. Turns out this is somewhat possible with ruby-ffi. I say “somewhat” because it is not very ergonomic to call Fortran from Ruby, as far as I can tell, and of the solutions I’ve come up with, some seem unstable (as in, occasionally produce segfaults), especially when trying to interact with Fortran derived types.

The ruby-fortran FFI proof-of-concept is here, along with some benchmarks. As I suspected/hoped, Fortran is much faster than ruby at some array manipulation tasks, e.g. summing an array is ~10x faster, doing dot product is ~2x faster. I mean, when using Fortran without the FFI/Ruby overhead, I suspect the speed differences are even more pronounced–these numbers are specifically with regard to pure ruby vs. ruby-calling-fortran.

2 thoughts on “Ruby and Fortran libraries”

  1. Everyperson wants to be able to gain money online. Do you really want to start getting benefits online with Forex? Forex trading is a big marketplace where tons of Dollars are traded every day. Pick this way and start using it to increase your earnings. Most of traders are maximizing their time by using a Robot to analyze the market movement. I am a honest Developper IT. Don’t waste your time trading without use of Robot, use MBF Robot. If you are searching for good Forex Brokers and good Forex Robot Trading. This is your chance!

  2. Everybody wants to be able to get money online. Do you really want to start making benefits online with Foreign Exchange Trading Market? Forex trading is a huge marketplace where trillions of Dollars are traded every day. Pick this way and start using it to increase your revenues. Most of traders are maximizing their time by using a Forex EA to analyze the market movement. I am a honest Developper IT. Don’t waste time trading without use of System, use MBF Robot. If you are searching for good Forex Brokers and good Forex Robot Trading. This is your chance!

Leave a Reply

Your email address will not be published. Required fields are marked *