Just yesterday I was trying to help find a bug in a hobby GPS software, where the map projection was off by a bit, resulting in surfaces that were off by 5% compared to Google Earth. Someone had written a little library for matlab and gave it away on the mathworks website.
Being able to test that library without matlab, confirm it was working, then using Octave to debug the translated code was invaluable.
After debugging and confirming both version gave the same result, we were closer to the Google Earth solution, but still off by a bit. That’s when we learned the projection used by GE isn’t very good to compute surfaces, and ours was actually doing a better job. Octave turned day+ job into a one hour session.
Massive thanks to the authors, and the author of that matlab library!
Is GNU Octave still relevant in the fields where it once was considered as a FOSS alternative to MATLAB?
Since it seems researchers are migrating away from MATLAB itself to python (numpy/scipy).
BTW, GNU Octave is fantastic! You can setup termux ([1]) in your android phone and `apt install octave`. Now you have a portable REPL for many advanced mathematical problems you might face for example in solving homeworks (Singular Value Decomposition, Curve Fitting, etc)
GNU Octave is a much better language for linear algebra problems that python+numpy. If all you have to do is state and solve some systems, you can typically do it in one or two lines of octave, while in python you need to import libraries and use a bizarre notation (either @ or .dot look very ugly in formulas).
Besides, the sparse linear solvers are much more performant in octave than in numpy.linalg (because the scipy developers are notorious anti-GPL fanatics and they refuse to use the state of the art free solvers due to stupid license reasons).
I for one use octave almost everyday, and I'm a bit annoyed when I have to turn something into python.
MATLAB seems ill condusive for structuring and organising code in a sane manner. It tends to give its users bad habits with respect to structuring code is what I observe.
It seems to lack data structures that are quite pervasive in modern programming practise.
Also python being a general purpose system brings its own benefits, one can easily hook up ones code to fetch or push data to databases and even easily scrape data of the web or extract/reparse/rectify/reformat poorly/complexly structured data before processing.
And I find MATLAB not feature rich in terms of being able to manipulate tabular data in a relational DB like manner, that is querying/projecting/selecting rows/colums to find interesting facts.
This makes sense, though, because it isn't really a general purpose language for creating standalone programs. I mean, you can try that, but it is a bit awkward. The usecase is mostly "I've got some matrices and I want to try some things with them before writing a couple thousand lines of FORTRAN with a bunch of ugly BLAS calls."
Most programming languages are tools for making tools. Matlab is the tool itself.
I've seen scripts where you have to set up your matrices, manually put them in particular named variables, and run them through a script that was basically a bunch of matlab shell commands listed one after another. That's not scalable of course, but if elderly professors were willing to mess around with makefiles, dependencies, interfaces, and importing stuff then grad students would all find themselves unemployed.
Yes, if that tool were created, I bet it would be really popular. But it hasn't been. Python+Numpy+Scipy isn't it by virtue of the fact that we have to specify three different software packages, haha.
I've done tiny prototypes that I later turned into a nice little Python+Numpy+Scipy scripts, and the final Python version was much nicer, but writing it was still more like a couple hour project, compared to the real-time process of figuring out what I wanted, done in Octave.
It compares quite favorably. The nice thing is that most of Numpy and Octave functionality is already builtin to Julia (multidimensional matrices are first class as they are in Matlab/Octave). Julia performance is quite good and multiple dispatch is great for composing packages (once you get used to it).
Check out SciML, Julia's answer to scipy (https://sciml.ai/) and Flux Julia's answer to PyTorch/Tensorflow (https://fluxml.ai/). Are these projects as mature as their Python counterparts? To be honest, no they're not, but they are making pretty rapid progress.
I haven't tried it out. It seems really interesting, though. A guy in my group loved it, but he graduated. I haven't yet so I guess we can put at least one point on the board for Julia!
It's pretty much already decently configured out of the box, so you spend little time playing with build and project configuration and there's a debugger built-in. Syntax is straightforward and the language is pretty optimized so it doesn't take long to get a working simulation for an engineering major.
It breaks down horribly for larger projects however.
Agreed it is mostly used interactively in the IDE. FWIW one can compile into p-code (=underlying virtual machine), package the p-code files of the application with the matlab standalone engine+libraries (MCR), and deploy using standard shell tools (e.g make with Makefile).
I don't have extensive experience with Matlab's toolboxes, but my impression is that most toolboxes without graphical interface (e.g., optimization, signal processing) have an octave equivalent with the same function names and mostly compatible. What is missing are the "gui" toolkits like simulink, the circuit stuff, etc.
> It tends to give its users bad habits with respect to structuring code is what I observe.
MATLAB is _approachable_ to engineers who don't give crap about programming, which often results in horrendous codebases (to be fair, I've observed the same, if not worse, with non-programmer's made Python)
> It seems to lack data structures that are quite pervasive in modern programming practise.
This however, is simply not true. MATLAB has many constructs to manipulate tabular and timeseries data in a very efficient way. It also has perfectly capable OOP, which allows building very large applications while staying sane.
MATLAB has evolved tremendously in the last 15 years, and most critics I read, while valid if you compared a circa 2005 version to current Python + numpy + pandas + scipy, are usually just uninformed.
> It seems to lack data structures that are quite pervasive in modern programming practise.
At least it has multi-dimensional arrays of floats, that is all I need and are sorely lacking in Python. On the other hand, Python has dictionaries and strings, but those are completely useless in a numerical setting.
I agree that the M language is not a good general-purpose programming language. But for expressing linear algebra manipulations is probably the best in town.
In the opposite direction, being away from matlab, I notice an upside to "vectorise everything" seems to have been "code shrinkage". Looks like ~3-5x times compared to "code with loops". I often find myself ill disposed towards my (and other's) code, it looks complex and verbose. I guess one can't easily un-see/forget how much simpler things can be.
Amen to this. The effortless translation of matrix expressions into code is a huge positive for Matlab/Octave and negative for Python. Have not worked with Julia, and I wonder what the experience is there.
Do you know how difficult it is to translate Matlab into Julia? I have a bunch of Matlab code I'm needing to refresh and honestly I could go either to Python or Julia. Python is more mature, but Julia doesn't seem like it's going to die or anything.
I haven't had a lot of time to look into it but my hunch is it would be magnificent to code numerical routines in Julia and access them from Python. There was some work for adding that sort of an interface with octave but it never seemed to work well.
I have translated quite a bit of Matlab code to Julia. Just the simple fact that indices are handled the same way in Matlab and Julia makes this transition easier than going from Matlab to Python in my opinion. What I would suggest, is that you first write some test suite of your Matlab code (you might have it already), have a look to the Julia documentation and in particular to the performance tips (https://docs.julialang.org/en/v1/manual/performance-tips/) and for functions where performance is important check its type-stability. You might want to start first with a small project to familiarize yourself with the (quite rich) type system in julia.
Julia is not a Matlab clone, but it does have more in common with Matlab than Python does, so translation is easier.
That said, Matlab does encourage quite a few bad habits that can kill performance in Julia, so it's important to try and properly learn Julia idioms too before you just blindly start translating if you care about performance.
What do you mean by killing performance? Compared to Matlab implementation or compared to better Julia implementations? To me, numpy operates the same way Matlab/Octave/IDL does (slow bulky interpreter that basically orchestrates feeding/retrieving memory to fast/optimized primitives/BLAS etc). Coding in Matlab is about "vectorizing", which is also how I understand numpy to work. So to me numpy has a lot in common with Matlab conceptually in terms of how I approach implementing an algorithm.
My assumption was that Julia could at least match that as worst-case but offered better optimizations to get even more performance.
I guess it depends on what's considered bad habits. Octave/Matlab do tend to be not terribly memory efficient so I tend to just buy RAM and larger cache CPUs. But my domain is memory-limited anyway.
Matlab's JIT does enable some things that are dog slow in octave for example. I assumed that sort of thing would actually be faster in Julia.
Julia isn’t as good as matlab in optimising badly written matrix code. For example some vectorised (in sense A = G(BX + CD) for matrices and vectors) it allocates temporary matrices whreas matlab is great at optimising such stuff. Most things could (and for optimal performance should) be written with loops and that will be much faster in Julia. However, there is Julia package Tullio.jl and it’s great with matrices/vectors/tensor stuff. It fuses operations, uses AVX instructions and creates code for GPU if asked.
It can really depend. It’s certainly possible to write code in Julia that is slower than corresponding Matlab or Python code.
Generally, naive Julia code shouldn’t be any slower than Matlab or Python, but it can happen. The Julia Discourse forum has many posts from people surprised to find their code running slower in Julia, but the community is also incredibly helpful so these posts almost always result in some rather simple modifications to the code that makes it handily outperform Matlab or Python implementations.
That's good to hear. I can usually get things to work well in matlab/octave, but it takes a lot of time thinking about how to restructure a calculation as vectorized. What I'm hearing is that with Julia I can probably just write what I mean directly and skip the pondering/iterating about how to vectorize. So I think I'll try it. Thanks!
Best ODE/SDE etc support of any programming language. Including composing them with machine learning and AD, GPU, multithreading, DSLs and symbolic simplification etc
Looks like when making use of gazilions numbers, a single and thus minimal data structure that suffices to get the job done is a matrix is a spreadsheet is an sql table. ;-)
I too am trying pandas daily after matlab (and q/kdb) and getting more annoyed by the day, of how inept it is. :-O Then again, it could be me - a craftsman & its tools, etc.
Anyhow, the * operator does not work with sparse matrices, and you really don't want to maintain two versions of your formulas. Thus, you are unfortunately stuck with @ or .dot
I guess there might be a much more math-friendly library than numpy, but I have never found it.
> hmmm, I thought the matrix class was deprecated? At least it says so in the official numpy documentation:
Huh, you're right. Bummer, I hadn't noticed that yet. I agree that an ergonomic matrix class is sorely missing in the Python ecosystem. It shouldn't even be that hard to implement, since all the plumbing is already there.
In practice it seems like Octave isn’t a great alternative to MATLAB in industry because so many industrial customers use proprietary MathWorks packages (eg Simulink) that are missing in Octave.
The fundamental problem is MATLAB/Octave simply aren’t as useful as Python for real world stuff (a bit of syntactical awkwardness around linear algebra is worth painless web access and system IO). The languages also aren’t as nice as R for statistics and machine learning. And nowadays they don’t have much performance benefit either. In most cases I think Octave/MATLAB provide too little benefit and too many drawbacks.
Octave is a great option as a personal calculator, and be the best option for small mechanical/electrical engineering firms. MATLAB code is unusually clear and expressive for numerical calculus and linear algebra, so are a good choice for problem domains where the math is very complicated but the dataset isn’t terribly large (e.g., models of crack formation in ceramics). I worked at a place that used Octave to run a free MATLAB script that did some very complicated microeconomics: a lot of very smart professors have written many useful algorithms in MATLAB, so being able to run them without porting is nice.
But I think Python and R have, sadly, made MATLAB as a language mostly obsolete for future development. The real relevance is MATLAB as an analysis tool with lots of MathWorks goodies.
All anecdotes, but In my Chem degree we used MATLAB, as did all the (non software) engineers I knew. My brother is a physics PhD student in Zurich, he uses MATLAB almost exclusively.
I think the universities use it for two reasons. Firstly, they’ve paid for the license and many proprietary add-ons, so they may as well use it. Secondly, MATLAB is a fast and safe playground for bright students who don’t know how to code. Teaching students to code well is too expensive (mainly in time).
While I was working on my masters (comp chem) I encountered a bottleneck written by a previous masters student. This was a python library. The student had written all his numerical methods manually. He was using python lists for vectors. His algorithms were great though. If you just use MATLAB, no one is making that mistake.
I work with folks in electrical controls and there's still a fair amount of modeling in Simulink. Although Octave doesn't replicate Simulink, a good amount of code is still in MATLAB. For me, I own both a MATLAB license as well as use Octave.
Personally, I find Octave easier to work with than MATLAB when developing applications because (1) It avoids the often times broken license manager and starts faster and (2) Has a more reasonable, integrated connection to the machine C compiler for debugging mex files. Especially for reason (1), my clients also prefer to use Octave when possible. That said, we often need to do production runs in MATLAB because they tend to use more updated numerical libraries than Octave. For example, Octave still has not migrated to SPQR from CSparse.
All that said, Octave has provided us with an amazing, reliable tool. It is not well suited for everything. It is incredibly well suited for implementing and rapid prototyping many kinds of numerical algorithms that take advantage of the ease of access to linear algebra operations.
Anecdotally: Some undergraduate degrees teach MATLAB, and it's the first time programming for many of the students. It is great that the students can use a FOSS alternative on their own machines. Doing the work in Python and then translating back to MATLAB would be a bit too much a stretch.
As far as I could tell, my undergraduate department ran on MATLAB (and I suspect it still does).
After using matlab full-time for ~15 years, as of recently I'm trying pandas/numpy/spyder because the colleagues are users. So to aid collaboration mainly, but also to try out the environment - I was curious. In matlab matrices (arrays) are 1st class citizens of the language, so having them be just another set of objects with some libraries operating on them - that feels like a step back to me. Quite a few things easy in matlab, I find less-than-easy in pandas. Hope it will get better in time. I was hoping to move from matlab to julia, but noone else I know uses it. (I do quant trading)
Would like to try it at some point. I am trying pandas now b/c other people are using it. So far - the more I learn pandas, the less I like it. Not a good sign. I keep finding things that annoy me in pandas, b/c have seen them solved in array languages (like q/kdb) and matlab.
I often find myself wondering what the field at large is using. I still use matlab daily in my job (signal processing), and have octave on my personal laptop. Ive played w/ the anaconda/spyder/scipi/numpi suite on my own a bit, mostly cuz it seems thats gotten some momentum, but i dont have a big use for it outside work. We are pretty deep in having a lot of tooling built up in matlab, and i dont see us leaving it anytime soon, and to be honest, I love it, probably cuz thats what im most proficient at.
I'm interested to know how you rate the matlab alternatives on interacting visually with the data? I often want to do things in Matlab like plot a largeish data set, then zoom in to different features, or open an array of data in a window and check values. How is octave for that sort of thing? How about python?
Octave is ok for that, but not as good as Matlab. All the Matlab plotting functions work, but the plots don't look as nice, and require more tweaking to get them to "publication quality". Octave includes a Qt-based GUI, but it is not nearly as polished as the Matlab GUI.
Python is also just ok. You can use matplotlib[1] to create plots using an interface explicitly modeled on the Matlab interface, or use higher-level wrappers like Seaborn[2] which reduce the amount of work required to create nice-looking plots of certain types. "Zoom to different features" can be done via Pandas[3], or directly via NumPy, although the syntax can get a little cumbersome. The best Matlab-like GUI is probably "Scientific mode" in PyCharm[4], which requires a paid license. Jupyter notebooks[5] are a free option, but don't include all the features you'd have in a Matlab-style GUI.
R is, in my opinion, best-in-class for exploratory data analysis. The combination of ggplot2[6] and dplyr[7] makes plotting, drill-down, aggregation, etc. easier than any other environment I've used. Chapters 2 and 4 of the free "R for Data Science" book[8] provide great examples of this. The RStudio[9] GUI is comparable to Matlab in features and overall polish, and it's available with either an AGPLv3 or commercial license. Jupyter notebooks also work.
The major downside of R is that it's very optimized for interactive use, which makes deploying it to any sort of production environment tricky and error-prone. I'd mostly advise doing your ad hoc analysis in R, but rewriting things in another language if you want to deploy them. The other downside is that all the major deep learning libraries use Python, so if you want to do work in that space you should really just use Python.
I work in a small industrial R&D group that was using a hodgepodge of Excel, Visual Basic, C, and an outdated MATLAB license. I switched from VB to Python, and the rest of the group has followed suit.
All that aside, I've noticed that when we bring in a new recruit, if they can code in MATLAB, they can switch to Python in a jiffy. I think the take-away is, if someone offers you a chance to learn how to code in any language, you should take them up on it.
I'm not sure how relevant it is. I use it almost everyday (EE). For me it basically serves as my (very advanced) calculator. If my scripts get above a certain complexity, I'll move to Python, but for smaller things I much prefer Octave.
A few reasons: legacy code in research (often headed by older staff), Matlab's speed out of the box, use in industry (Toyota), and toolboxes developed by Mathworks itself. For those who don't want to resort to piracy when doing "home work", Octave is a really good alternative for less complex scripts.
I'm sure some are, sure, but I bet the vast majority of researchers:
a) are still using python + libs
b) that ARE changing from something to something else are moving to python from not-python
An annoying aspect of getting into Octave was realizing that it had only very basic support for Unicode (no Unicode in filenames, variable names, comments...)
The main issue seems to be Matlab compatibility, which is stuck with UTF-16 (like some Windows internals), while most languages have moved on to UTF-8 as a standard (Heck, even Windows PowerShell (and Notepad?) default to UTF-8 now!)
Some time ago I even opened a feature request[1] to implement Unicode symbols like in Lean, for example. And to have the Language Server Protocol implementation[2] for better integration with various editors, including VS Code, Emacs, Vim, etc.
What the world needs is a pull request, not a feature request ;)
Especially for the first one. Being able to use greek letters as variable names would be incredible (now that it is possible to do so in Python and in C).
> Being able to use greek letters as variable names would be incredible
I've seen people do that in Haskell, I think. I've no idea why that's desirable. It's difficult to type up. It only adds complexity. Is it to be able to use variable names like they're used in mathematics? That's optimized for easy handwriting, through terseness, but because of just how terse it is it's incompatible with autocomplete, so it actually offers a much worse writability/readability ratio in an editor. Why use a miniature vocabulary of symbols when you can use English? I'd always choose `delta` over `Δ`. Actually, why use greek at all?
I realise my insight is a bit condescending. My background is plain programming. I've had to implement some algorithms from papers. I guess I'm venting having to interpret those symbols, where terseness was favored over readability.
> Is it to be able to use variable names like they're used in mathematics?
Yes. That's the main point (in my case). I'm really tired of having variables with ugly names like "alpha" and "beta", when I could have simply α and β, just like they appear in print.
> Why use a miniature vocabulary of symbols when you can use English?
Because that's the vocabulary which is already used in math, and I do not wont to change mathematics to adapt to the limitations of programming languages.
See, I don't coincide at all with your point of view, but allowing greek leters in variable names would not keep you from using your preferred naming conventions.
EDIT: it's not really "difficult to type" either. For example, in linux if you add
setxkbmap -option caps:ctrl_modifier
to you keyboard configuration, then you can type greek leters by preceeding regular keys by CAPS LOCK.
I’m with you. It’s great the way Julia lets math look like math in code. And if you define a "dead Greek" key using xmodmap, typing the whole greek alphabet is no harder than typing uppercase letters.
That's like saying that |||| is more readable than 4. Yes, it does take some time to learn the symbols. (I'm not sure what you mean about being incompatible with autocomplete?)
> Why use a miniature vocabulary of symbols when you can use English?
Why do you assume that English is going to be easier? Heck, even for a native English speaker not familiar with programming, √() is going to be easier to understand than sqrt() !
What would you say if you had to work on a code of Russian origin, would you prefer α or альфа ?
I guess that I formulated that poorly : Having to default to one of the UTF-16 instead of UTF-8 is another complication that makes it harder to do Unicode properly. (What happens when you paste UTF-8 into a UTF-16 file ?)
This isn't related to Matlab compatibility... Matlab uses UTF-16 internally but recent versions work with UTF-8 input seamlessly (converting automatically). Octave uses UTF-8 on Linux which works well, but last time I checked has broken Unicode support on Windows.
Octave on Linux has no problem with UTF-8 filenames, it can read from and write to such files without problem.
It's true you cannot use non-ASCII UTF-8 names for script and functions, since in that case the file name is also the command/function name. But that's a statement about valid identifiers, not supported filenames. Every language I know of has restrictions on identifiers.
Prompted by this thread, I went to the (slight) hassle of compiling the latest octave (and installing the dependent libs along the way). What a pleasant surprise! I remembered ancient versions (maybe v3?), and it was a (very) poor relative of matlab then. What change since! Nice GUI, editing, debugging, documentation - all under one roof. Looks perfectly adequate to me for anything really.
Back in college I enrolled for a digital image processing class. Unfortunately the uni did not have licensing for MatLab so the professor instructed us to use Octave.
Fun memories, I implemented every basic algorithm of image processing in it.
Later I ported the algorithms to JavaScript and created a image editor:
Oracle winning would mean any project reimplementing another API would be at the mercy of the original authors' approval to be legal. I don't know how litigious Mathworks would be.
Does anybody know where to find the download link for the Octave 6.1 Mac binary (dmg)? I see no way to install it without HomeBrew or Macports, even though the Octave website claims otherwise.
MATLAB is one of those things I've spent a ton of time learning in college, but never used in real life. I've used python to get around MATLAB installs that barely worked.
Thanks to Andrew Ng's class I learnt Octave which helped me tremendously with this semester's Linear Algebra class. It is a nice software that I always keep out there when I need to test things out.
Just yesterday I was trying to help find a bug in a hobby GPS software, where the map projection was off by a bit, resulting in surfaces that were off by 5% compared to Google Earth. Someone had written a little library for matlab and gave it away on the mathworks website.
Being able to test that library without matlab, confirm it was working, then using Octave to debug the translated code was invaluable.
After debugging and confirming both version gave the same result, we were closer to the Google Earth solution, but still off by a bit. That’s when we learned the projection used by GE isn’t very good to compute surfaces, and ours was actually doing a better job. Octave turned day+ job into a one hour session.
Massive thanks to the authors, and the author of that matlab library!