Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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!




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: