5 ms·
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 Ju
by jsw97 6y ago
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.
- leephillips 6y agoWorking with matrices is similar in Julia. In fact, the syntax was partly influenced by the desire to make it easy for MATLAB users to pick up.
- fluidcruft 6y agoDo 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.
- eigenspace 6y agoJulia 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.
- fluidcruft 6y agoWhat 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.
- tikej 6y agoJulia 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.
- eigenspace 6y agoIt 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.
- fluidcruft 6y agoThat'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!
- leephillips 6y agoNot specifically, but Julia would be a better choice than Python + Numpy.
- kwertzzz 6y agoI 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/ 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.