Why and how I started using GNU Octave (and broke up with MATLAB after 15 years)

Why (short version): $$$

How (short version): Downloaded Octave.app for Mac, installed and used in place of MATLAB.

Why (the details):

I wrote some .m code several years ago to process grades from spreadsheet data that prints out a little text summary of the semester’s performance for my thermo students. I update it each year with the number of students in the class and tweak as needed, but it’s essentially plug and play when I get ready to do the final grades. However, I found that I had to pay $130 just to use the MATLAB compiler to run the code.

I’m embarrassed to admit that I was in the exact same predicament last year and wound up paying up out of my personal funds for a license that I never used again until it expired, annoyingly, 8 months later in August 2018. I was told by the university software representative that my only option to use MATLAB was to pay this licensing fee and have it expire in August 2019, and that this was actually a good deal because “if [I] were to purchase a MATLAB license directly from MathWorks, the price starts at $200 and does not include any toolboxes.” Never mind that MATLAB licenses were provided by my college for free when I started 5 years ago. This year, I’m not sinking >$100 of my personal or research funds to do this, as it doesn’t benefit my personal life or my research program.

In the research arena, I’ve been pushing for my group to release open source code as much as possible, like so many ethical and collaboratively-minded scientists are doing these days. The student researchers are actually the ones writing the new code that we produce, and it’s ultimately their call which language and software they use, but they’re increasingly proficient in Python and eager to contribute to the larger research community as well.

I’m also increasingly conflicted about the way that software, publishing, and other companies profit off of the higher education system. One way to do this is to get free publicity, early buy-in and perhaps vendor lock-in by pushing your proprietary software platforms to college students. MATLAB is the first programming language I learned to use effectively, for this very reason (<$100 student licenses and extensive use in my undergraduate courses), and it’s still the easiest for me to fall back on.

Aside from its proprietary nature, MATLAB has other minor annoyances — it indexes from 1; the name is not an acronym (Why capitalize a portmanteau?) — but it fits its niche quite well. The benefits are considerable: it generally performs well for an interpreted language on numerical computing tasks, the learning curve is manageable for new programmers, the basic IDE is useful, the online help is excellent, and there’s a substantial base of code and instructional materials for academic use.

Enter GNU Octave, a scientific programming language suite that is designed to be compatible with many .m scripts and allows its users to leverage many of these benefits. The Octave program is released under the respectful “copyleft” GNU General Public License and meets the Free Software Definition — “a matter of liberty, not price” — established by the Free Software Foundation. It is an excellent solution for using legacy .m code, and allowed me to get my grades done with just a bit of extra tweaking.

How (the details):

Linux and Windows users (or Mac users who resent the ease of a precompiled installer and want to build the application themselves) will want to start at the GNU Octave landing page, where you can find distributions for each operating system. I did experience multiple crashes using the Octave GUI on my 2017 Macbook Air (although only one crash on a more powerful Mac Pro), so I don’t see myself writing a lot of new code in Octave in this way.

The GUI may be a bit of a CPU hog — my 1.8 GHz i5 processor jumps from 8% to 58% load when the program is running, without even executing code — but it is customizable and its features will be familiar to MATLAB users. I’d recommend it for people with better computers or more patience than me.

The online documentation for Octave is helpful. Mathematical users, even or especially those without a MATLAB background, will appreciate the Introduction to GNU Octave free textbook by Jason Lachniet on the University of Minnesota’s Open Textbook Library (hint, hint, University of Utah).

Once you’re up and running, you’ll probably find that not all of your existing .m code will run perfectly, especially if you have used syntax that is unique to more recent releases or that is part of a proprietary toolbox. Here are a few good options for moving forward:

  1. If you’re not sure what isn’t working, you may want to check the Differences between Octave and Matlab page on the Octave wiki.
  2. If you know what piece isn’t working, you may be able to find a package at Octave Forge that meets your needs for that specific functionality.
  3. Python users can just call .m files within their Python codes using Oct2Py. (I haven’t tried this yet — let me know if it works for you.)

If I were to use Octave more extensively, I would move to Terminal-based (command line) execution, run the GUI on a Linux machine (where it is native, and may already be pre-packaged with your distro), or just use an Octave kernel for Jupyter (which would be my preferred solution but I couldn’t get it to work right off the bat).