So I just read this great rant about Matlab by Olivia Guest, and it reminded me to update my previous rant about Matlab, so here it is. For the record, I don’t disagree with anything Olivia said, and I’m not overly defending Matlab. I am trapped in its local minima and am slowly reaching escape velocity, moving over to a combination of R, Python, and hopefully Julia.
Bear in mind I am only partially aware of how things are done outside of Matlab land, so I might be unaware of some of the ways how things are better in other languages. However, in the past 1-2 years I’ve really focussed on upping my game in terms of taking on more pro coding practices. I’ve learnt about Object Oriented Programming, Functional programming, Unit testing, etc. Matlab has support for these things, and has allowed me to learn these more meta-level issues, so that is something. But, in line with Olivia’s rant, I am somewhat frustrated that I could go for over 10 years without ever hearing about these practices. The communities of other programming languages seem to have a greater level of dialogue which points people to good practice, and to develop as programmers.
- While the IDE does have a few issues, it is actually pretty good. In particular, I find the debugger particularly useful. It’s great to be able to set break points and step through, and to explore the call stack. I don’t know enough to compare to the IDE’s used for other languages however.
- The documentation is pretty solid.
- It does support namespaces, but this feature relies on the hardly ever used packages feature.
- You can do OOP in Matlab. I’ve found it ok, but setting up classes is verbose and clunky. The way how it is done in Python is pretty concise.
- You can do functional programming (kinda) in Matlab, but I would really love to see more work done here. Functional programming is so hot right now. I’ve used some closures to good effect on a current (stealth-mode) project, and all the arrayfun, cellfun stuff is cool.
- You can do unit or integration testing, but it’s annoying that this is tucked away as an advanced feature. Instead, testing should be centre stage.
- Plotting is good and pretty easy. A lot has been done recently to improve the default plot settings, but it’s still very clunky on the underlying engine (e.g. transparency) and exporting (pdf in particular).
- Lack of keyword arguments is a major pain. Instead, you have to jump through the hoops with InputParser, which is a good solution to a problem that should not exist.
- Lack of good package management. They’ve tried with their Apps feature, but I’ve not really found this very doable in terms of decent package management to sort all the dependencies of a project. I had to write my own GitHub package manager, which was an interesting thing to do, but again should not have been a problem I needed to solve.
- I entirely agree with the often mentioned complaint about 1 publicly accessible function per .m file. This does encourage spaghetti coding.
- Accessibility of advanced features: A lot of the features which Mathworks considered as advanced, are considered perhaps as normal good programming practice in other languages. This resonates with Olivia’s point that Matlab can trap you in a local minima. You can get a lot done just with basic skills, but I entirely agree (and I am a live example) of having just sat there with very slow visible progress in my coding style and abilities. I think Mathworks could do a bit more to push good programming practices. Labelling them as advanced topics is probably not the best way to achieve this. Although yes, you can see efforts in this direction with Matlab Examples.
- I don’t know why yet, but I want meta programming. And Matlab doesn’t do that.
- While I like arrayfun and cellfun etc, I really want to break free of the bonds of writing loops. I would really love to see some development here, whether it’s in the form of writing Python style list comprehensions, or just a more generic thing-iterator, then that would be super useful.
- SEMICOLONS FFS!
PS. You can go see my GitHub here, and hopefully not code-shame me. I look back at code I wrote even from just a few years ago and I want to cry. But progress is being made 🙂