Here are some points, off the top of my head. Several of them overlap with points raised by other posters:
- Functions need own file in Matlab and all files in path intrude in namespace
Whenever you want to define a function, you can’t do it from the command line, or inside a script (except with some major limitations)
- Dispatch vs input parsing
Input parsing in Matlab is a nightmare. You have the
inputParser class now, but it seems really heavy and awkward.
- Default values and keyword arguments
This is related to the above. You can `fake’ keyword arguments using two consecutive inputs, one string for the keyword and one for the value. It’s an awful kludge.
- Everything in Matlab is a matrix (or a higher dimensional array)
You can’t have scalars, so you always have to consider the ramifications of the fact that your value is a container with a shape and linear algebra-like behaviour. Often you want your code to behave one way if it’s a `scalar’ and another if it’s a vector and a third if it’s a matrix. But it’s always a matrix, and it requires a lot of awkward tests and planning. (Is a single number a scalar, is it a vector or is it a matrix?)
- Possible to mutate objects (no copy on assignment)
When you assign to a variable, the object you assign is copied. So you cannot pass an array into a function to mutate it (Matlab can only somtimes mutate as an optimization if certain cases). Mutation is supported for user classes that inherit from the
- Julia can define functions like +() and *()
- Direct access to objects with indexing for example
foo(x) etc are impossible in Matlab, so you must create intermediate variables.
- Better handling of variable inputs and outputs with splat and slurp
varargout in Matlab is an annoying mess to work with.
- Much better iterators
Matlab doesn’t have proper iterators, so you will normally have to do
for n = 1:length(x). You can in principle write
for val in x, but it only works for 1xN vectors, not Nx1. For a matrix each iteration will actually return a column of
- 1d vectors avoid orientation confusion
Column major language, but almost all internal functions return row vectors. Also, iteration only works for row vectors, as mentioned. Proper flat 1D vectors are amazing.
- Map and broadcast vs cellfun, arrayfun, structfun, bsxfun
Vectorizing code is the major coding style in Matlab, but it’s so inconvenient. You have no general
map function, let alone the awsome broadcasting (you have a really pale type of broadcasting that works for
+-*/). Instead you have different and awkward functions, cellfun, arrayfun and structfun for different types of collections.
foois a function call
You don’t have to use parens for a function call, so you cannot tell if
foo is a variable or a function call. Passing functions around requires using
@ to create a ``function handle’’.
- Creating empty containers of specific class is awkward in matlab
Due to everything being a matrix it is actually really hard to create empty arrays of objects. I struggled to implement this for some classes recently. You can do it, but it’s messy, verbose and hard to understand.
- Poor support for hash tables/dictionary
containers.Map which noone uses.
- Generators and comprehensions
These are incredible, and there’s nothing like it in Matlab.
- Explicit multithreading
- char arrays and strings in matlab
This is a big mess. Previously strings were char arrays, and they are still what is mostly used throughout the language. Now they have more proper strings, but they are barely used, and also, of course a string is always a [1x1] string array. I can’t really go into this, but it is awkward.
- Operations that only accept small number of input types.
This is a common problem in most programming languages, except Julia, as far as I can tell. ``Sorry, this function only accepts double floats.’’