Ruby, Python, and Science

David Jacobs has written a long blog post Ruby is beautiful (but I’m moving to Python). Here’s my summary.

Ruby is much better than Java, but the Ruby community is too focused on web development and the language has no scientific library. Python has a lot of the same advantages as Ruby, is used for more than web programming, and has SciPy.

Update: There is now a fledgling SciRuby project.

Further reading:

Plain Python
Getting started with SciPy
Replacing Mathematica with Python
SciPy and NumPy for .NET

10 thoughts on “Ruby, Python, and Science

  1. That’s my own situation, pretty much. I much prefer Ruby over Python; there are a number of reasons both large and small but the end result is, using Ruby makes me smile while using Python makes me frown.

    However, I end up using Python. And SciPy is a very large part of why that is so. If there were a well-maintained port of equivalent to SciPy/NumPy (and to a lesser degree Pylab – it’s really not all that good) I would spend most of my time with Ruby instead.

  2. Janne: When Enthought finishes their .NET port of SciPy, you could use the SciPy library from Iron Ruby.

  3. Well… it would depend on the scipy port to finish and then remain well maintained over time; on Iron Ruby remaining healthy and similarly well maintained (it hasn’t sounded very hopeful lately); and finally on our administrators admitting the Mono runtime as supported software into our cluster. Which all means it’s not a feasible option in the short or medium-term for me.

    I’m stuck with python for now.

  4. I basically am having to give up on using ruby for science after having tried for 2 years and moving to python. Ruby is missing all sorts of basic things for doing even simple computations. Here are some my obsevrations

    1. it lacks a decent CSV parser. FasterCSV ( csv in ruby 1.9) is a joke. These days i convert all CSV files to JSON and parse this way.
    This does work, but it is a pain sometimes to do the conversion, and not everyone will get this on the first try.

    2. NArray is great…but the array indexing is backwards. NArray should follow standard Matlab array indexing. It makes programming
    useful algorithms like NMF maddening

    Or at least let the user decide what indexing to use (say with an install flag, monkey patch, etc)

    3. There are too many GSL libraries, and I can’t get any of them to install on a Mac It would seem the ruby GSL bindings would offer a lot, but it does not compile easily on the Mac (perhaps one needs Fink to do this,
    I am still working on it). And while there are pre-compiled GSL libraries for the Mac, they don’t include the shared libraries
    needed for the ruby GSL bindings

    And this does not have to that hard with the ruby FFI bindings .

    4. What is needed is “gem install SciRuby” and it should work on all platforms
    This will probably require a Fortran and C++ compiler, so these should also be installed . A good solution would be to use
    something like RVM to install Fortran and get things compiled properly on different architectures and with the best maintained libraries

    Granted, Python SciPy is not that easy to install…but it does install on a Mac , at least with Python 2.6. or 2.7

  5. A group of us are beginning work to make sciruby a reality. NArray is currently being rewritten (using matlab/numpy index order). The author of rubyvis and statsample is on board, as well as a number of others dedicated to doing science in ruby.

    sciruby

  6. Reading “Ruby is Beautiful” was interesting. It is a nice language, but I do favor the functionality of Python and its access to NumPy and SciPy.

    The author did make an excellent point: Installing binary Python packages is a nightmare for beginners. I have given lectures on Python and getting everyone up to par with NumPy and SciPy was not easy. Especially if someone has Fink on Mac and others have several different flavors of Linux. Pip is making good headway, but it would be great if it installed compiled binary code.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>