4 ms·
i noticed that running arithmetic loops tend to be the popular method of benchmarking these three languages. I don't know how many folks who use MATLAB care th
by princeb 11y ago
i noticed that running arithmetic loops tend to be the popular method of benchmarking these three languages.
I don't know how many folks who use MATLAB care that much about loop performance that they will be inclined to look at Python or Julia just because someone found an amazing improvement there.
The one thing that made me finally go over to Scipy from MATLAB was that I changed focus and no longer have to do analysis involving nonlinear/stochastic optimization. Several years ago (maybe 2009?), Octave was really struggling with speed here, and numpy still felt too new. I vaguely remember needing to wrangle with the mathematics a lot more (like approximating the Jacobians or Hessians) in order to get Octave to work. On the other hand I can only remember a handful of times where I needed to get MATLAB to do loops like these benchmarks (like maybe Runge Kutta or FD ODE solutions). Loops are really quite unnatural/unidiomatic in MATLAB, if you can keep your algorithm as close to linear systems as possible it's quite fast.
Has it changed much since? I know right now most of the important nonlin opt algorithms are available in scipy and if you want more there are external packages, but you still have to tinker a bit for the best solution. There's nothing like mindlessly using fmincon for every single problem in the world. I am only a layperson at nonlinear optimization, so I can't tell you why MATLAB is so much better out of the box.
- tavert 11y ago"Vectorizing" (interpreter-out-of-the-way vectorization, which isn't the same and doesn't necessarily give you SIMD vectorization) your code to get Matlab or NumPy to run it efficiently always seems like an unnecessary burden to put on the programmer, especially for algorithms that don't lend themselves to expressing in a vectorized way. Sometimes you just need to write a for loop, and it's great when the language gets out of your way and lets you do so without slowing your code down by an order of magnitude. If you care about constrained optimization, Julia has leaps-and-bounds more sophisticated tools than anything Matlab or Python have to offer. Check out http://www.juliaopt.org http://www.juliaopt.org and especially JuMP.jl. http://www.optimization-online.org/DB_FILE/2015/04/4891.pdf http://www.optimization-online.org/DB_FILE/2015/04/4891.pdf has some detailed comparisons. Macros and fast generic programming make Julia a very well-suited language for doing automatic differentiation (https://en.wikipedia.org/wiki/Automatic_differentiation https://en.wikipedia.org/wiki/Automatic_differentiation).