Julia for prototyping, compared to MATLAB?

I was talking to a colleague, and they were basically telling me how they would not want to use Julia because most of their time is actually spent on trying different analyses, and exploring data. And for that MATLAB is established in their field (Neuroscience, multi-channel time series’) and does prototyping really well.

I didn’t really know what to say, I felt I agreed with him but I was also wondering that other scientists also are heavily involved in data exploration and not writing software for commercial usage. What are your thoughts about this? Would it be fair to say a language like MATLAB is better than Julia for “prototyping”? For scientists, what are the real pros of using Julia?

Prototyping…for what? Like they first write code in MATLAB and then write the same code in Fortran? I wouldn’t want to use Julia for that either :wink:

I do lots of data mining exploration in Julia. I use the REPL and IJulia.

5 Likes

Well, it depends. In my area, if I prototype in MATLAB, then I will loose a lot of time porting the code to faster languages to be actually used in optimization problems.

I understand that MATLAB as an IDE, not a language, is better for prototyping and performing data analysis. However, for such cases, any good IDE and interpreted language will do the same…

13 Likes

Julia is great for prototyping and production. Much better than Matlab.

28 Likes

There are many things that Python does better than Julia e.g. many libraries are more mature.
There are many things R does better than julia, e.g. statictical packages we don’t even have.

AFAIK, the only thing Matlab does better than julia is the debugger, both performance and IDE integration.
If that is the key feature for prototyping (which it might well be) then sure Matlab is better than Julia
But iother than that, its a worse language with a worse package ecosystem.

20 Likes

I think this is the key. There are some language quirks, but Matlab has a very polished IDE experience with easy editing/debugging of scripts (note that I didn’t say functions) and a very responsive interface for plotting/etc. You never have to wait for anything… As far as serious programmers are concerned, the IDE is terrible (e.g. lack of standard code editor features like multi-cursors, etc.) but they are not the target audience.

So comparing Matlab to Julia may not be what they have in mind. What they are probably thinking of is Matlab vs. Julia+Jupyter or Julia+Atom. For that, it can’t compete with the polish of Matlab, but it is making good progress. If you are worried you only have one shot to convince them, you might want to wait until the plotting speed (and, depending on whether they write scripts or functions, some of the scoping things) make progress. Regardless, it may be helpful to set expectations on the degree of polish of the IDE experience relative to an expensive commercial alternative.

But saying “prototyping” usually means that you end up writing things in a different language, like Fortran. For that, I think Julia dominates matlab because you don’t need to prototype in different languages. If that is the goal, and matlab is not high enough performance to solve their problems, then any warts in the Julia IDE are worth the trouble in not having to then move to another language for the “real” problem.

15 Likes

You end up writing somethings that get past the prototyping stage in another language.
If something lets you be 50% faster at prototyping,
and only 5% of thens you prototype actually make it past that stage, then the overhead of rewriting it is low.

2 Likes

In grad school I prototyped an algorithm that would take a few months in MATLAB and decided that wasn’t my idea of a quick prototype, and so now that’s the oval2 example in the DiffEqBanchmarks is that model and it takes about 30 seconds or so to run. I think that makes a massive difference as a modeler making prototypes, but that could just be me :smile:

18 Likes

It probably depends on what kind of data you’re using for your prototyping; if everything is “just an array” and you’d only need a few lines of code, then Matlab is usually fine. But in many cases Julia’s expressiveness just blows Matlab away. In Julia, once you start building up a toolkit of objects & properties that you can start snapping together like legos, all the sudden you can write code in 10 minutes that would take a month in Matlab. This lets you come to work in the morning, explore three different approaches to solving some complicated problem, pick the winner, and then break for morning coffee :smile:.

To me that’s even more important than the performance, though of course it’s great that your prototype often ends up having an eerie resemblance to the finished high-performance product.

29 Likes

@ChrisRackauckas has said a few times “Publication via composition of packages”
2 packages work together and let you solve problems that would normally be expected to take writing a whole new package that does both.

7 Likes

This is really what is preventing a few people in my lab from switching. I usually use VScode + Julia for writing large simulations and packages which is a great experience. But I use jupyter for data analysis and exploration, which is slightly less great because of the compilation time for some packages. For example, today I spent an hour trying to debug because I used a variable in one of the Jupyter cells but then deleted that cell. I basically had to restart the kernel to get a clean workspace. The worst thing was that I was screen sharing with 3 other people and waited about 30 - 50 seconds for packages to load and plots to show up. Julia really needs a rm(list = ls()) or clc; clear equivalent without restarting the kernel/runtime.

10 Likes

The debugging and profiling experience with Julia is definitely not quite user-friendly or feature-rich as MATLAB. That’s my only real gripe with the tooling around Julia. Well maybe that and the interactive plots.

The other side of this coin is that Julia is just a way more expressive language than MATLAB. So even though the tooling around Julia isn’t as good, I’ve noticed myself being way more productive in the last few months since I’ve picked up Julia than I ever was with MATLAB. I now feel like I am spending most of my time in MATLAB trying unsuccessfully to express the things that would be trivial to do in Julia. And I’m a pretty experienced MATLAB programmer.

6 Likes

I am really happy with Interactive Plots via Plots.jl with Plotly backend + Interact.jl.
It goes a long way, though there are somethings one can’t do with it, I never want those things.

4 Likes

Everyone in my neuroohysiogy lab uses matlab. It’s because it’s what everyone else does, not because matlab is good at it.

6 Likes

I am not sure everyone in this discussion is using prototyping in the same sense.

A lot of programmers understand it as software prototyping, which is something Julia is really good at — one could argue that creating a smooth transition from a small working prototype to a full-fledged, optimized set of packages was the main motivation for creating Julia.

In contrast, your colleagues seem to be doing exploratory data analysis, probably using some field-specific libraries (which in Matlab are usually “toolkits”).

If

  1. these tools serve them well,
  2. there is no equivalent in Julia yet, and they are not interested in developing it,
  3. they don’t need to write a lot of actual code for novel algorithms,

then it is very likely that they should just stick to what they are using at the moment — these are tools they find useful and familiar, and they just happen to be in Matlab, but the question is not about Matlab vs Julia per se, but about these tools.

Conversely, if any of these conditions are not met, and especially if they want to develop new algorithms, then Julia would be a good match.

19 Likes

Personally I also like using Julia for other reasons: nicer syntax, better readability (even though I’m very familiar with MATLAB) and I feel Julia resolves a big issue from my previous MATLAB code—code that was becoming incredibly difficult to maintain. The latter may be my fault, but I feel a little ‘forced’ to use better coding practices that I would otherwise ignore. Also, it’s super swell that I can make reports of analyses and simulations on juypter notebooks.

Personal sidenote: I’m having issues regarding my work (I’m a grad student) because everyone around me is using MATLAB and collaboration is becoming a little difficult. On top of that, I get lost in trying to find solutions since no one in my vicinity can give me immediate help.

5 Likes

Do you think Julia is the way to go for Neurophysiology? If so, why? I will be working with MEG data soon, and I have a strong feeling that building the code from the ground up in Julia will be very valuable due to the readability and reproducability. (rant: Also no paywall locking away analyses!)

2 Likes

I would suggest that you ask on this forum. Even if it is not a programming question in the narrow sense, there are a lot of knowledgeable people here in various fields, and most of them are happy to provide domain-specific help and don’t consider this off-topic if it relates to Julia.

13 Likes

Thank you—it’s really nice to hear that.

2 Likes

I would love it if I could say you should just go all in with Julia but it’ really hard to know what peoples expectations are going in. There are a handful of really good tool boxes for neurophyiology in matlab and your expectations of what would constitute “good” are highly dependent on your previous experience.

There have been a lot of comments on the IDE aspect of matlab. But here’s the crux of the issue: neuroscience NEEDS to stop using Matlab. Neuroscientists aren’t typically programers, so they use GUIs or do so until they give up and learn Matlab. Then you prototype things in Matlab and the claim is that it’s more intuitive. Of course it is. It is the only thing many have ever known. The familiar language will always be more intuitive than the new one no matter how much simpler the new language is.

Here are some problems that Julia is uniquely capable of solving:

  • Neuroscience data isn’t necessarily tabular. However, it is consistent (usually), so we should use arrays that have semantic meaning along each dimension (“channel dimension” x “time”). Instead of having a set of functions that search separate look up tables you should be able to do something like: array[channel = :T3].
  • Neurophysiology isn’t usually doing anything that hasn’t been done elsewhere, so stop reinventing everything for neurophysiology. Yesterday a grad student was complaining about how EEGLab just makes new functions that call FieldTrip. Furthermore, if your using something like SPM you have tons of could that rewrites statistical distributions. This is all crazy! Have someone that know how to write the stats correctly do it and use their package. If FieldTrip wrote the function use it and don’t try to reclaim it. Part of this is because we have multiple dispatch to ease this sort of thing. Part of it is just insanity in Matlab development. Fourier transforms, graph theory, ICA CCA, etc. have all been implemented before and we don’t need to redo the implementation every time we have a new modality.
  • Reproducibility. So much to say but so little time. Probably the biggest problem is that most the people I know have to use a GUI in Matlab for at least 50% of their workflow. That part of their workflow isn’t reproducible by anyone.

I could rant for a very long time, but I would urge you to consider what has made prototyping so easy for this person. Is it because they know exactly where their channel is and how to extract the relevant information? If so, that’s because they know the exact sequence of commands to get there. Imagine if they had to switch to a different number of channels and didn’t know exactly where things were anymore.

8 Likes