In Defense of Matlab Code

2025-12-1220:13144167runmat.org

MATLAB still shines for math-heavy work. Its whiteboard-style syntax makes code easy to read, review, and run on modern tools like RunMat and fast GPUs.

The issue was never the syntax—it was the runtime. Why readable math still matters in a world aided by LLM-assisted code generation

The enduring relevance of MATLAB in modern engineering

If you look at the most preferred language list on any Stack Overflow developer survey, you will usually find MATLAB hovering near the bottom. It sits there alongside VBA and COBOL, often dismissed by modern software engineers as a dinosaur. You have probably seen the memes: complaints about license manager errors, the massive install size, or the feeling that it is a language strictly for "old-school academics.”

The world has moved toward open source, containerization, and agile cloud deployments. In that context, a closed ecosystem feels restrictive.

But if you walk into the R&D departments of top aerospace, automotive, or medical device companies, MATLAB is still everywhere. It isn't there because these engineers don't know better. It is there because, for a specific type of work—linear algebra, signal processing, and control theory—MATLAB did one thing better than almost anyone else:

It made the code look exactly like the math on the whiteboard.

We need to separate the language syntax (which is excellent) from the runtime and business model (which are dated).

What is "whiteboard-style code"?

When I say "whiteboard-style code," I am referring to a specific level of abstraction. In engineering, the "truth" is derived on a whiteboard or a notepad. That is where the physics is worked out. You draw matrices, you transpose vectors, and you define relationships ($F = ma$, $V = IR$, $Y = Hx$). The goal of engineering software is to translate that whiteboard truth into executable logic with as little "translation loss" as possible. "Whiteboard-style code" means:

  1. High Density: One line of math equals one line of code.
  2. Visual Similarity: The code visually resembles the equation.
  3. Low Boilerplate: No memory allocation logic, no type declarations, and minimal imports. For vectors, matrices, and arrays, MATLAB’s syntax is often the shortest distance between the board and the running code

The translation test: board vs. code

Let’s look at a concrete example. Imagine you are sketching a simple linear algebra operation during a lecture or a design review.

In MATLAB: The code is almost a direct transcription of the board:

X = [1, 2, 3];
Y = [1, 2, 3; ...
 4, 5, 6; ...
 7, 8, 9];

Z = Y * X'; W = [Z, Z]; 

In Python (NumPy): Python is an incredible language, and NumPy is a powerhouse. But notice the cognitive load required to handle the shapes explicitly:

import numpy as np

X = np.array([1, 2, 3])
Y = np.array([[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9]])



Z = Y @ X.reshape(3, 1)


W = np.concatenate([Z, Z], axis=1)

The math is identical. But in the Python version, the engineer is thinking about computer science concepts: imports, methods, tuples, and axes. In the MATLAB version, the engineer is thinking about linear algebra: rows, columns, and multiplication.

Why readable math is a safety feature

Why does this subtle difference matter?

In mission-critical fields, code review is safety review.

Senior engineers and Principal Investigators perform these reviews. These are brilliant people who understand the physics deeply, but they may not be experts in modern software design patterns. They don't want to parse decorators or understand the nuances of an object-oriented class hierarchy.

When they review code, they are holding their derivation notes in one hand and looking at the screen with the other. They want to verify that step A leads to step B.

  • "Here is the rotation matrix."
  • "Here we apply the filter."
  • "Here we calculate the error."

MATLAB’s syntax allows them to verify the math without getting bogged down in the implementation. When the code looks like the math, bugs have fewer places to hide. The syntax itself reduces the cognitive load, allowing the reviewer to focus on the physics rather than the programming.

MATLAB code review

It's not just for humans (compilers love it too)

There is a misconception that "simple syntax" means "slow interpretation." Actually, high-level array syntax gives runtimes and compilers excellent signals for optimization.

When you write C = A * B in a vectorized language, you are giving the runtime a very high-level instruction: "Perform a matrix multiplication on these two objects."

Because the language constraints are strict (matrices have defined shapes, types are usually consistent), a modern runtime can:

  • Immediately infer the shapes of the result.
  • Fuse multiple element-wise operations into a single pass through memory.
  • Offload the entire chunk of work to a GPU without the user writing a single line of CUDA kernel code.

The structure that makes it readable for humans also makes it predictable for machines.

The honest truth: why the hate exists

If the syntax is so good, why is the sentiment so mixed?

To be fair, the backlash against MATLAB is largely justified. The frustration usually stems from three areas, none of which have to do with the math syntax itself:

  1. The "Black Box" Runtime: The engine is closed source. You cannot see how fft or ode45 are implemented under the hood. For high-stakes engineering, not being able to audit your tools is a risk.
  2. Licensing Pain: Everyone has a story about a simulation crashing because the license server timed out, or not being able to run a script because a colleague "checked out" the toolbox token.
  3. The Cloud Gap: Modern engineering happens in CI/CD pipelines, Docker containers, and cloud clusters. Integrating a heavy, licensed desktop application into these lightweight, automated workflows is painful.

This friction pushed a generation of engineers toward Python, not because they preferred writing np.concatenate, but because they needed tools that played nice with the modern stack.

MATLAB meme

A vision for a modern "whiteboard" runtime

The solution isn't to abandon the syntax that engineers love. The solution is to build a new, modern engine to run it.

We need a runtime that preserves the dense, array-oriented notation but operates like a modern piece of software infrastructure. It should be:

  • Open and inspectable: No black boxes.
  • Hardware agnostic: It should run on CPUs or GPUs without changing the code.
  • Portable: It should run in a Docker container or a web browser.

We should keep the language surface that mimics the whiteboard, but swap out the engine for something designed for the era of cloud computing and massive datasets.

Keeping the math, changing the engine

This is exactly why we are building RunMat.

Our team realized that the problem wasn't the .m files—it was how they were being executed. RunMat is a new, high-performance runtime designed to execute MATLAB-style syntax. It targets modern hardware (CPUs and GPUs) and integrates seamlessly into cloud and CI workflows, all without the traditional licensing headaches.

It allows teams to keep their "whiteboard code" while gaining the performance and portability of a modern software stack.

Conclusion

Technology trends come and go, but the laws of physics and mathematics don't change.

Engineers working on the next generation of renewable energy grids, autonomous vehicles, and medical robotics need tools that respect the complexity of their math. They need code that can be written, read, and verified by experts who care more about differential equations than software dependencies.

The future doesn't need to copy the business models of the past. But it should absolutely keep the best part of the legacy: code that looks like the math on the board.

Monthly updates on RunMat, Rust internals, and performance tips.

Get started with the modern MATLAB runtime today.


Read the original article

Comments

  • By mNovak 2025-12-1520:154 reply

    As an engineer, I use Matlab (or rather, Octave the free equivalent) all the time. It's really great for numerical computing and plotting. Most things 'just work', there's a sizeable collection of packages, and I personally like how flexible the function inputs are.

    Biggest drawback though is that it's over-optimized for matrix math, that it forces you to think about everything as matrices, even if that's not how your data naturally lies. The first thing they teach about performant Matlab code is that simple for-loops will tank performance. And you feel it pretty quickly, I saw a case once of some image processing, with a 1000x speedup from Matlab-optimized syntax.

    Other things issues I've run into are string handling (painful), and generally OOP is unnatural. Would love to see something with the convenient math syntax of Matlab, but with broader ease of use of something like JS.

    • By nallana 2025-12-1520:383 reply

      @mNovak -- super helpful note! Thank you!

      Author of RunMat (this project) here --

      > The first thing they teach about performant Matlab code is that simple for-loops will tank performance.

      Yes! Since in RunMat we're building a computation graph and fusing operations into GPU kernels, we built the foundations to extend this to loop fusion.

      That should allow RunMat to take loops as written, and unwrap the matrix math in the computation graph into singular GPU programs -- effectively letting loop written math run super fast too.

      Will share more on this soon as we finish loop fusion, but see `docs/fusion/INTERNAL_NOTE_FLOOPS_VM_OPS.md` in the repo if curious (we're also creating VM ops for math idioms where they're advantageous).

      > Would love to see something with the convenient math syntax of Matlab, but with broader ease of use of something like JS.

      What does "convenient math syntax of Matlab, but with broader ease of use of something like JS" look like to you? What do you wish you could do with Matlab but can't / it doesn't do well with?

      • By dkarl 2025-12-161:351 reply

        Piggybacking on this comment to say, I bet a lot of people's first question will be, why aren't you contributing to Octave instead of starting a new project? After reading this declaration of the RunMat vision, the first thing I did was ctrl-f Octave to make sure I hadn't missed it.

        Honest question, Octave is an old project that never gained as much traction as Julia or NumPy, so I'm sure it has problems, and I wouldn't be surprised if you have excellent reasons for starting fresh. I'm just curious to hear what they are, and I suspect you'll save yourself some time fielding the same question over and over if you add a few sentences about it. I did find [1] on the site, and read it, but I'm still not clear on if you considered e.g. adding a JIT to Octave.

        [1] https://runmat.org/blog/matlab-alternatives

        • By finbarr1987 2025-12-165:24

          Fair question, and agreed we should make this clearer on the site.

          We like Octave a lot, but the reason we started fresh is architectural: RunMat is a new runtime written in Rust with a design centered on aggressive fusion and CPU/GPU execution. That’s not a small feature you bolt onto an older interpreter; it changes the core execution model, dataflow, and how you represent/optimize array programs.

          Could you add a JIT to Octave? Maybe in theory, but in practice you’d still be fighting the existing stack and end up with a very long, risky rewrite inside a mature codebase. Starting clean let us move fast (first release in August, Fusion landed last month, ~250 built-ins already) and build toward things that depend on the new engine.

          This isn’t a knock on Octave, it’s just a different goal: Octave prioritizes broad compatibility and maturity; we’re prioritizing a modern, high-performance runtime for math workloads.

      • By zackmorris 2025-12-1617:251 reply

        Piggybacking also to say that I hope you succeed, as your work aligns closely with the type of runtime that I had hoped to write someday when I first used MATLAB in the early 2000s (now mostly GNU Octave for small hobby projects).

        The loop fusion idea sounds amazing. Another point of friction which I ran into is that MATLAB uses 1-based offsets instead of 0-based offsets for matrices/arrays, which can make porting code examples from other languages tricky. I wish there was a way to specify the offset base with something like a C #define or compiler directive. Or a way to rewrite code in-place to use the other base, a bit like running Go's gofmt to format code. Apologies if something like this exists and I'm just too out of the loop.

        I'd like to point out one last thing, which is that working at the fringe outside of corporate sponsorship causes good ideas to take 10 or 20 years to mature. We all suffer poor tooling because the people that win the internet lottery pull up the ladder behind them.

        • By markkitti 2025-12-172:08

          > I wish there was a way to specify the offset base with something like a C #define or compiler directive.

          Julia has OffsetArrays.jl implementing arbitrary-base indexing: https://juliaarrays.github.io/OffsetArrays.jl/stable/

          The experience with this has been quite mixed, creating a new surface for bugs to appear. Used well, it can be very convenient for the reasons you state.

            julia> A = collect(1:5)
            5-element Vector{Int64}:
             1
             2
             3
             4
             5
          
            julia> B = OffsetArray(A, -1)
            5-element OffsetArray(::Vector{Int64}, 0:4) with eltype Int64 with indices 0:4:
             1
             2
             3
             4
             5
          
            julia> A[1]
            1
          
            julia> B[0]
            1

      • By Alexander-Barth 2025-12-1611:431 reply

        I wish you all the best luck with your product!

        Unfortunately, mathworks is a quite litigious company. I guess you are aware of mathworks versus AccelerEyes (now makers of ArrayFire) or Comsol.

        For our department, we mostly stop to use MATLAB about 7 years ago, migrating to python, R or Julia. Julia fits the "executable math" quite well for me.

        • By fluidcruft 2025-12-1612:161 reply

          All anyone really needs is seamless integration of Julia with python. Instead everyone seems to be rewriting python into rust.

          • By FacelessJim 2025-12-1613:251 reply

            Checkout PythonCall.jl and juliacall (on the python side). Not to mention that now you can literally write python wrappers of Julia compiled libraries like you would c++ ones.

            • By fluidcruft 2025-12-1614:581 reply

              I will, thanks.

              > you can literally write python wrappers of Julia compiled libraries like you would c++ ones

              Yes, please. What do I google? Why can't julia compile down to a module easily?

              No offense but once you learn to mentally translate between whiteboard math and numpy... it's really not that hard. And if you were used to Matlab before Mathworks added a jit you were doing the same translation to vectored operations because loops are dog slow in Matlab (coincidentally Octave is so much better than Matlab syntax wise).

              And again python has numba and maybe mojo, etc. Because julia refused to fill the gap. I don't understand why there's so much friction between julia and python. You should be able to trivially throw a numpy array at julia and get a result back. I don't think the python side of this is holding things back. At least back in the day there was a very anti-python vibe from julia and the insistence that all the things should be re-implemented in julia (webservers etc) because julia was out to prove it was more than a numerical language. I don't know if that's changed but I doubt it. Holy wars don't build communities well.

              • By markkitti 2025-12-202:29

                >> you can literally write python wrappers of Julia compiled libraries like you would c++ ones. > Yes, please. What do I google? Why can't julia compile down to a module easily?

                Try JuliaC for compiling shared libraries if that is what you mean by a "module": https://github.com/JuliaLang/JuliaC.jl

                That said Julia's original design focused on just-in-time compilation rather than ahead-of-time compilation, so the AOT process is still rough.

                > I don't understand why there's so much friction between julia and python. You should be able to trivially throw a numpy array at julia and get a result back.

                You can throw a numpy array at Julia and get a result back. See https://juliapy.github.io/PythonCall.jl/stable/juliacall/

    • By queuebert 2025-12-1520:17

      > Biggest drawback though is that it's over-optimized for matrix math ...

      I think this is what inspired the creation of Julia -- they wanted a Matlab clone where for loops were fast because some problems don't fit the matrix mindset.

    • By grandiego 2025-12-165:06

      Yes, strings appear like an afterthought, and sadly the Octave version has slight incompatibilities which may be a PITA for any non trivial script which aims to be compatible.

    • By hatmatrix 2025-12-162:34

      It's one of those languages that outgrew its original purpose, as did Python IMHO. So non-matrix operations like string processing and manipulation of data structures like tables (surprisingly, graphs are not bad) become unwieldy in MATLAB - much like Python's syntax becomes unwieldy in array calculations, as illustrated in the original post.

  • By lemonwaterlime 2025-12-1519:585 reply

    There's also Julia.

    Earlier in my career, I found that my employers would often not buy Matlab licenses, or would make everyone share even when it was a resource needed daily by everyone. Not having access to the closed-source, proprietary tool hurt my ability to be effective. So I started doing my "whiteboard coding" in Julia and still do.

    • By fph 2025-12-1520:063 reply

      Precisely; today Julia already solves many of those problems.

      It also removes many of Matlab's footguns like `[1,2,3] + [4;5;6]`, or also `diag(rand(m,n))` doing two different things depending on whether m or n are 1.

      • By hatmatrix 2025-12-162:26

        An understated advantage of Julia over MATLAB is the use of brackets over parentheses for array slicing, which improves readability even further.

        The most cogent argument for the use of parentheses for array slicing (which derives from Fortran, another language that I love) is that it can be thought of as a lookup table, but in practice it's useful to immediately identify if you are calling a function or slicing an array.

      • By drnick1 2025-12-1520:217 reply

        I don't think Julia really solves any problems that aren't already solved by Python. Python is sometimes slower (hot loops), but for that you have Numba. And if something is truly performance critical, it should be written or rewritten in C++ anyway.

        But Julia also introduces new problems, such as JIT warmup (so it's not really suitable for scripting) and is still not considered trustworthy:

        https://yuri.is/not-julia/

        • By SatvikBeri 2025-12-1521:113 reply

          > Python is sometimes slower (hot loops), but for that you have Numba

          This is a huge understatement. At the hedge fund I work at, I learned Julia by porting a heavily optimized Python pipeline. Hundreds of hours had gone into the Python version – it was essentially entirely glue code over C.

          In about two weeks of learning Julia, I ported the pipeline and got it 14x faster. This was worth multiple senior FTE salaries. With the same amount of effort, my coworkers – who are much better engineers than I am – had not managed to get any significant part of the pipeline onto Numba.

          > And if something is truly performance critical, it should be written or rewritten in C++ anyway.

          Part of our interview process is a take-home where we ask candidates to build the fastest version of a pipeline they possibly can. People usually use C++ or Julia. All of the fastest answers are in Julia.

          • By sbrother 2025-12-165:463 reply

            > People usually use C++ or Julia. All of the fastest answers are in Julia

            That's surprising to me and piques my interest. What sort of pipeline is this that's faster in Julia than C++? Does Julia automatically use something like SIMD or other array magic that C++ doesn't?

            • By jakobnissen 2025-12-167:251 reply

              I use Rust instead of C++, but I also see my Julia code being faster than my Rust code.

              In my view, it's not that Julia itself is faster than Rust - on the contrary, Rust as a language is faster than Julia. However, Julia's prototyping, iteration speed, benchmarking, profiling and observability is better. By the time I would have written the first working Rust version, I would have written it in Julia, profiled it, maybe changed part of the algorithm, and optimised it. Also, Julia makes more heavy use of generics than Rust, which often leads to better code specialization.

              There are some ways in which Julia produces better machine code that Rust, but they're usually not decisive, and there are more ways in which Rust produces better machine code than Julia. Also, the performance ceiling for Rust is better because Rust allows you to do more advanced, low level optimisations than Julia.

              • By SatvikBeri 2025-12-1617:07

                This is pretty much it – when we had follow up interviews with the C++ devs, they had usually only had time to try one or two high-level approaches, and then do a bit of profiling & iteration. The Julia devs had time to try several approaches and do much more detailed profiling.

            • By adgjlsfhk1 2025-12-166:36

              The main thing is just that Julia has a standard library that works with you rather than working against you. The built in sort will use radix sort where appropriate and a highly optimized quicksort otherwise. You get built in matrices and higher dimensional arrays with optimized BLAS/LaPack configured for you (and CSC+structured sparse matrices). You get complex and rational numbers, and a calling convention (pass by sharing) which is the fast one by default 90% of the time instead of being slow (copying) 90% of the time. You have a built in package manager that doesn't require special configuration, that also lets you install GPU libraries that make it trivial to run generic code on all sorts of accelerators.

              Everything you can do in Julia you can do in C++, but lots of projects that would take a week in C++ can be done in an hour in Julia.

            • By SatvikBeri 2025-12-1616:40

              To be clear, the fastest theoretically possible C++ is probably faster than the fastest theoretically possible Julia. But the fastest C++ that Senior Data Engineer candidates would write in ~2 hours was slower than the fastest Julia (though still pretty fast! The benchmark for this problem was 10ms, and the fastest C++ answer was 3 ms, and the top two Julia answers were 2.3ms and .21ms)

              The pipeline was pretty heavily focused on mathematical calculations – something like, given a large set of trading signals, calculate a bunch of stats for those signals. All the best Julia and C++ answers used SIMD.

          • By pbowyer 2025-12-169:161 reply

            > Part of our interview process is a take-home where we ask candidates to build the fastest version of a pipeline they possibly can. People usually use C++ or Julia. All of the fastest answers are in Julia.

            It would be fun if you could share a similar pipeline problem to your take-home (I know you can't share what's in your interview). I started off in scientific Python in 2003 and like noodling around with new programming languages, and it's great to have challenges like this to work through. I enjoyed the 1BRC problem in 2024.

            • By SatvikBeri 2025-12-1617:05

              The closest publicly available problem I can think of is the 1 billion rows challenge. It's got a bigger dataset, but with somewhat simpler statistics – though the core engineering challenges are very similar.

              https://github.com/gunnarmorling/1brc

          • By drnick1 2025-12-165:532 reply

            The C++ devs at your firm must be absolutely terrible if a newcomer using a scripting language can write faster software, or you are not telling the whole story. All of NumPy, Julia, MATLAB, R, and similar domain-specific, user-friendly libraries and platforms use BLAS and LAPACK for numerical calculations under the hood with some overhead depending on the implementation, so a reasonably optimized native implementation should always be faster. By the looks of it the C++ code wasn't compiled with -O3 if it can be trivially beaten by Julia.

            • By SatvikBeri 2025-12-1616:40

              Are you aware that Julia is a compiled language with a heavy focus on performance? It is not in the same category as NumPy/MATLAB/R

            • By postflopclarity 2025-12-1622:16

              Julia is not a scripting language and can match C performance on many tasks.

        • By sundarurfriend 2025-12-1521:001 reply

          As your comment already hints at, using Python often ends up a hodgepodge of libraries and tools glued together, that work for their limited scope but show their shaky foundations any time your work is outside of those parts. Having worked with researchers and engineers for years on their codebases, there is already too much "throw shit at the wall and see what sticks" temptation in this type of code (because they'd much rather be working on their research than on the code), and the Python way of doing things actively encourages that. Julia's type hierarchies, integrated easy package management, and many elements of its design make writing better code easier and even the smoother path.

          > I don't think Julia really solves any problems that aren't already solved by Python.

          I don't really need proper furniture, the cardboard boxes and books setup I had previously "solved" the same problems, but I feel less worried about random parts of it suddenly buckling, and it is much more ergonomic in practice too.

          • By wolvesechoes 2025-12-168:481 reply

            > using Python often ends up a hodgepodge of libraries and tools glued together

            At least it has those tools and libraries, what cannot be said about Julia.

            • By forgotpwd16 2025-12-169:471 reply

              What tools/libraries you miss from Julia? Have you used the language or merely speculating?

              • By wolvesechoes 2025-12-1612:17

                > What tools/libraries you miss from Julia?

                My experience with this website is that it would be rather pointless to enumerate, because you will then point to some poorly documented, buggy and supporting fraction of features Julia "alternatives" to Python packages or APIs that are developed and maintained by well-resourced organizations.

                The same thing for tooling - unstable, buggy Julia plugin for VSCode is not the same as having products like PyCharm and official Python plugins made by Microsoft for VS and VSCode.

                Now, I will admit that Julia also has some niceties that would be hard to find in Python ecosystem (mainly SciML packages), but it is not enough.

                > Have you used the language or merely speculating?

                I just saw the logo in Google Images.

        • By MillironX 2025-12-161:151 reply

          > I don't think Julia really solves any problems that aren't already solved by Python.

          But isn't the whole point of this article that Matlab is more readable than Python (i.e. solves the readability problem)? The Matlab and Julia code for the provided example are equivalent[1]: which means Julia has more readable math than Python.

          [1]: Technically, the article's code will not work in Julia because Julia gives semantic meaning to commas in brackets, while Matlab does not. It is perfectly valid to use spaces as separators in Matlab, meaning that the following Julia code is also valid Matlab which is equivalent to the Matlab code block provided in the article.

              X = [ 1 2 3 ];
              Y = [ 1 2 3;
                    4 5 6;
                    7 8 9 ];
              Z = Y * X';
              W = [ Z Z ];

          • By forgotpwd16 2025-12-161:22

            This snippet is also cleaner than one in article and more in spirit. Also the image next to whiteboard has a no-commas example.

        • By jakobnissen 2025-12-167:301 reply

          Yes, Python code is indeed fast if you write it in C++... what a bizarre argument. The whole selling point of Julia is that I can BOTH have a dynamic language with a REPL, where I can redefine methods etc, AND that it runs so fast there is no need to go to another language.

          It's wild what people get used to. Rustaceans adapt to excruciating compile times and borrowchecker nonsense, and apparently Pythonistas think it's a great argument in favor of Python that all performance sensitive Python libraries must be rewritten in another language.

          In fairness, we Julians have to adapt to a script having a 10 second JIT latency before even starting...

          • By wolvesechoes 2025-12-168:501 reply

            > Pythonistas think it's a great argument in favor of Python that all performance sensitive Python libraries must be rewritten in another language.

            It is, because usually someone already did it for them.

            • By jakobnissen 2025-12-1914:31

              That's fair - if you work in a domain where you can solve your problems by calling into existing C libraries from Python, then Python's speed is indeed fine.

        • By forgotpwd16 2025-12-161:19

          >I don't think Julia really solves any problems that aren't already solved by Python.

          You read the article that compares MATLAB to Python? It's saying MATLAB, although some issues exist, still relevant because it's math-like. GP points out Julia is also math-like without those issues.

        • By nallana 2025-12-1520:54

          In Julia, you explicitly need to still reason about and select GPU drivers + manage residency of tensors; in RunMat we abstract that away, and just do it for you. You just write math, and we do an equivalent of a JIT to just figure out when to run it on GPU for you.

          Our goal is to make a runtime that lets people stay at the math layer as much as possible, and run the math as fast as possible.

        • By kelipso 2025-12-161:28

          Sometimes slower? No, always slower. And no one wants to deal with the mess that is creating an interface with C or C++. And I wouldn’t want to code in that either, way too much time, effort, headache.

      • By freehorse 2025-12-163:022 reply

        Why is the `[1,2,3] + [4;5;6]` syntax a footgun? It is a very concise, comprehensible and easy way to create matrices in many cases. Eg if you have a timeseries S, then `S - S'` gives all the distances/differences between all its elements. Or you have 2 string arrays and you want all combinations between the two.

        The diag is admittedly unfortunate and it has confused me myself, it should actually be 2 different functions (which are sort of reverse of each other, weirdly making it sort of an involution).

        • By fph 2025-12-179:04

          What happens most of the time with unexperienced or distracted users is that they write things like `norm(S - T)` to compute how close two vectors are, but one of them is a row vector and the other is a column vector, so the result is silently completely wrong.

          Matlab's functions like to create row vectors (e.g., linspace) in a world where column vectors are more common, so this is a common occurrence.

          So `[1,2,3] + [4;5;6]` is a concise syntax for an uncommon operation, but unfortunately it is very similar to a frequent mistake for a much more common operation.

          Julia tells the two operations (vector sum and outer sum) apart very elegantly: one is `S - T` and the other is `S .- T`: the dot here is very idiomatic and consistent with the rest of the syntax.

        • By BobbyTables2 2025-12-163:152 reply

          What does it even mean to add a 1x3 matrix to a 3x1 matrix ?

          • By freehorse 2025-12-163:53

            This is about how array operations in matlab work. In matlab, you can write things such as

                >> [1 2 3] + 1
                ans = [2 3 4]
            
            In this case, the operation `+ 1` is applied in all columns of the array. In this exact manner, when you add a (1 x m) row and a (n x 1) column vector, you add the column to each row element (or you can view it the other way around). So the result is as if you repeat your (n x 1) column m times horizontally, giving you a (n x m) matrix, do the same for the row vertically n times giving you another (n x m) matrix, and then you add these two matrices. So basically adding a row and a column is essentially a shortcut for repeating adding these two (n x m) matrices (and runs faster than actually creating these matrices). This gives a matrix where each column is the old column plus the row element for that row index. For example

                >> [1 2 3] + [1; 2; 3]
                ans = [2 3 4
                       3 4 5
                       4 5 6]
            
            A very practical example is, as I mentioned, getting all differences between the elements of a time series by writing `S - S'`. Another example, `(1:6)+(1:6)'` gives you the sums for all possible combinations when rolling 2 6-sided dice.

            This does not work only with addition and subtraction, but with dot-product and other functions as well. You can do this across arbitrary dimensions, as long as your input matrices non-unit dimensions do not overlap.

          • By quietbritishjim 2025-12-166:021 reply

            It means the same thing in MATLAB and numpy:

               Z = np.array([[1,2,3]])
               W = Z + Z.T
               print(W)
            
            Gives:

               [[2 3 4]
                [3 4 5]
                [4 5 6]]
            
            It's called broadcasting [1]. I'm not a fan of MATLAB, but this is an odd criticism.

            [1] https://numpy.org/devdocs/user/basics.broadcasting.html#gene...

            • By adgjlsfhk1 2025-12-166:29

              One of the really nice things Julia does is make broadcasting explicit. The way you would write this in Julia is

                  Z = [1,2,3]
              
                  W = Z .+ Z' # note the . before the + that makes this a broadcasted
              
              This has 2 big advantages. Firstly, it means that users get errors when the shapes of things aren't what they expected. A DimmensionMismatch error is a lot easier to debug than a silently wrong result. Secondly, it means that julia can use `exp(M)` etc to be a matrix exponential, while the element-wise exponential is `exp.(M)`. This allows a lot of code to naturally work generically over both arrays and scalars (e.g. exp of a complex number will work correctly if written as a 2x2 matrix)

    • By constantcrying 2025-12-1521:042 reply

      Julia competes with the scientific computing aspect of matlab, which is easily the worst part of matlab and the one which the easiest to replace.

      Companies do not buy matlab to do scientific computing. They buy matlab, because it is the only software package in the world where you can get basically everything you ever want to do with software from a single vendor.

      • By moregrist 2025-12-164:39

        In addition: Simulink, the documentation (which is superb), and support from a field application engineer is essentially a support contract and phone call away.

        I say this as someone who’d be quite happy never seeing Matlab code again: Mathworks puts a lot of effort into support and engineering applications.

      • By wolvesechoes 2025-12-168:53

        It is hard to explain that to people here.

    • By dcanelhas 2025-12-1521:451 reply

      I remember the pitch for Julia early on being matlab-like syntax, C-like performance. When I've heard Julia mentioned more recently, the main feature that gets highlighted is multiple-dispatch.

      https://www.youtube.com/watch?v=kc9HwsxE1OY

      I think it seems pretty interesting.

    • By a-dub 2025-12-163:05

      julia is still clunky for these purposes! you can't even plot two things at the same time without it being weird and there's still a ton of textual noise when expressing linear algebra in it. (in fact, i'd argue the type system makes it worse!)

      matlab is like what it would look like to put the math in an ascii email just like how python is what it would look like to write pseudocode and in both cases it is a good thing.

    • By gmadsen 2025-12-165:021 reply

      simulink is the matlab moat ,not just general math expression

  • By ubj 2025-12-1521:292 reply

    Matlab is an great tool, if you can afford it.

    It was a very unpleasant feeling when I graduated from my PhD and realized that most, if not all, of the Matlab scripts I had used for my research would now be useless to me unless I joined a company or national laboratory that paid for licenses with the specific toolboxes I had used.

    I'm glad that a significant portion of tools in my current field are in open source languages such as Python and Julia. It widens access to other researchers who can then build upon it.

    (And yes, I'm aware of Octave. It does not have the capabilities of Matlab in the areas that I worked in, and was not able to run all of my PhD scripts. I have not tried RunMat yet, but am looking forward to experimenting with it.)

    • By drnick1 2025-12-1521:43

      > I graduated from my PhD and realized that most, if not all, of the Matlab scripts I had used for my research would now be useless

      And this is why you should write free software and, as a scientist, develop algorithms that do not rely on the facilities of a specific language or platform. Nothing is more annoying than reading a scientific paper and finding out that 90% of the "implementation" is calling a third party library treated as a blackbox.

    • By bsder 2025-12-161:202 reply

      > And yes, I'm aware of Octave. It does not have the capabilities of Matlab in the areas that I worked in

      Was there a specific reason for that? Or was it simply nobody wrote the code?

      • By ubj 2025-12-161:32

        Octave has not implemented all of Matlab's functionality. You can see a list of Matlab functions that have not yet been implemented in Octave at the link below. It's a long list.

        https://hg.savannah.gnu.org/hgweb/octave/file/tip/scripts/he...

        EDIT: If the original link above isn't working, here's a fairly recent archived version:

        https://web.archive.org/web/20250123192851/https://hg.savann...

      • By kelipso 2025-12-161:32

        You could say that no one wrote that code. But Matlab has serious packages in numerous engineering fields and it’s not anywhere close to easily replicable.

        It’s like how open source will never replace Excel but probably worse because it’s multiple fields and it’s way harder to replicate it.

HackerNews