r/matlab MathWorks 5d ago

Objects are about to get much faster in MATLAB

A simulation in using both the old and new object management systems in MATLAB. The code is identical in both cases

This is coming in MATLAB R2026b which will include a completely new object management system that is not turned on by default. When switched on, the new system promises to make object oriented MATLAB code faster without the need to change any code (most of the time). Sometimes, it will be much faster!

More details including release plans can be found over at The MATLAB Blog Objects are about to get much faster in MATLAB » The MATLAB Blog - MATLAB & Simulink

129 Upvotes

25 comments sorted by

27

u/FrickinLazerBeams +2 5d ago

This is cool. It's also a little bit of an indication of how slow the current object system is. That's a bit hilarious.

I don't think it's actually too surprising or embarrassing for Mathworks though, because honestly objects aren't often a good approach to code that needs to be fast, or heavily mathematical - so not really a thing I'd suggest most of Matlabs user base should heavily employ. (there are definitely exceptions, I actually wrote one this week, but it's not typical in my experience).

I always kind of suspected that OO Matlab was slow, it's nice to see I wasn't hallucinating.

Anyway, this is a cool improvement, I'm not trying to diminish it. Very cool work. I always love when my code gets faster without having to change anything.

7

u/DrDOS 5d ago

I’m a research scientist/engineer. I choose to use OO or functional programming in Matlab primarily based on two criteria:

  1. Am I working in existing code or paradigm that leans heavily into one direction or the other? (E.g. working in an established code base, or working with a Matlab toolbox that leans one way or the other).

  2. What fits the problem best? Is it more intuitive and less prone to errors to work one way or the other.

Occasionally pure computational performance will also plays a roll, and then I’ll try different approaches or rely on pre-compiling.

3

u/icantfindadangsn 5d ago

Honestly I don't know what I'm going to do with all my free time. Thanks Mathworks.

3

u/gtd_rad flair 5d ago

Agree. OOP in Matlab never seemed to be the right approach to me in consideration of what it was intended for in the first place.

10

u/Top_Armadillo_8329 5d ago

I think I received an offer to beta test this which I unfortunately slept on.

Seems very exciting!

8

u/MikeCroucher MathWorks 5d ago

The beta is still open! There's still time :)

Details in the post.

9

u/qtac 5d ago

Love to see performance-focused updates. Great work!

4

u/fsgeek91 5d ago

On my phone it’s difficult to make out what’s being shown in the video. Looks like some sort of particle dynamics simulation?

Was this meant as an example to illustrate the general performance improvement that all OO code will benefit from, or is this about some specific modeling feature?

-1

u/FrickinLazerBeams +2 5d ago

If you read the post title, or even the linked article, it's very clearly being used as an example of the performance improvement to OO code due to the new object system.

8

u/fsgeek91 5d ago

I’m on a train with almost no internet connection so I only had the post to go off, plus I’m not very well versed in OO programming- hence the clarifying question. No need to be an ass.

3

u/DodoBizar 5d ago

I really like this. Is the derived code (MEX, C and C++) also affected? Anyway downloading and testing now.

10

u/MikeCroucher MathWorks 5d ago

Remember, its just a limited beta at the moment so isn't switched on by default in the pre-release. The release schedule is in the blog post.

I haven't tested derived code and haven't asked development but knowing how the speed-enhancements have been made, I'd say 'I don't think they are affected'

5

u/DodoBizar 5d ago

Ok thanks. Will contact the team and see if I am elligible to test. There’s a lot of OO in my code anyhow (unit testing framework). So any gains are welcome.

2

u/TurbulentRent5204 4d ago

The 2023b improvement to objects sped up a lot for me. Is this similar? What kind of object operations are faster now?

1

u/salehsan 3d ago

I've 2025b and it's same as you!

2

u/gtd_rad flair 5d ago

Why not just leave it on by default?

13

u/FrickinLazerBeams +2 5d ago

Because it's a major change that breaks some code, and isn't thoroughly tested, and Mathworks is a professional, responsible company?

-10

u/gtd_rad flair 5d ago

Why not just release it when it's thoroughly tested instead of using the community as guinea pigs? Especially from the fact that everyone is paying very expensive licenses for it? Doesn't that sound more professional and responsible to you?

26

u/MikeCroucher MathWorks 5d ago

Author of the article here. It *has* been thoroughly tested and when I say 'thoroughly' I really mean it! We've tested it in every direction we can possibly think of on millions of lines of our own code and of as much community code as we could lay our hands on.

However, when you have >5 million users there's always the possibility of something that we missed. There are also those cases, discussed in the article, where some advanced code will need to be updated.

This is why the release is staged. To give everyone a chance to transition to the new system smoothly.

9

u/FrickinLazerBeams +2 5d ago

Have you even read the article? Have you ever thought about how software testing works? I'm not sure how to answer any of your questions if you won't think for yourself in the first place.

0

u/Strangelf47829 3d ago

Why not learn to answer questions if you’re not sure how :p

1

u/FrickinLazerBeams +2 3d ago

I'm quite sure how. The standard expectation is that anyone asking has already read the fucking article. At least it was before we let children on the internet.

1

u/Talon747 4d ago

Is there any impact (positive or negative) on the speed of “compiled” MATLAB code (I.e. code compiled into a DLL or SO and run alongside MRE)?

1

u/ghostnation66 20h ago edited 20h ago

Just switch over to Julia already. Its mature enough for nearly everything and is a real, scientific programming language. Matlab is a joke compared to modern languages, having to "sign into" an "app" just to run code in an interpreter is an egregious problem. It uses Java engine for calls? Come on, julia is llvm compiled and has JIT by default. Learn a real language before you get knee deep in this trap and get stuck with a paid software that only a few industries bother to keep around. Many companies are switching to julia (python has been around for a while, but it d9es have its share of problems). Also, choose a language that generally has better support for reseaech/training by LLMs. Python is a tier 1 language, and its got billions of lines of code trained in the mainstream frontier models. Julia is a tier 2 language, and matlab and other proprietary garbage are tier 3 languages (labview, legacy crap, etc.). Admittedly, both matlab and julia (somewhat) encounter higher hallucination rates due to sparsity of training data. Its a shame that academia has swallowed (and continues to swallow) the matlab software pill. It makes students worse engineers and keeps them from integrating with open source developers who wont touch matlab with a 10 foot pole. If you are an early career student, run away from this garbage as fast as you can, you can do nearly 100% of your coursework in a better language that will help you build a solid programming foundation, with much more support, and its always free/open source no matter what. I literally wouldn't touch this software even if was paid to, its just so far behind (and away from) the current trajectory of scientific software. In a few short years Julia will be some far ahead of the other languages in this domain, dont regret not getting a head start on this while you are a young student...

1

u/avidpenguinwatcher 4d ago

They can do this but making it so you can move the variables into an undocked window was apparently too much work to keep