There’s a Clear Winner Between Matlab vs Python

This is the rare coding language comparison where there’s an obvious answer, no matter what the context

Zulie Rane
Towards Data Science

--

Photo by Ruca Souza from Pexels

My college class was the first year that students were taught R over Matlab because our professors believed R was a more useful language. And when I wanted to learn a new language, I couldn’t choose Matlab because I couldn’t afford it. Python was the natural choice.

Matlab and Python both can do quite different and incredible things, which makes Matlab versus Python an interesting question. The better question is more nuanced. When considering Matlab vs Python, which is best for you?

If you’re learning computer science online with any language, you’re already in a great place. Coding is a hugely valuable skill, no matter which language you go with. But with such a wide variety of programming languages available, picking the right one is tough.

No matter if you’re just starting out coding and trying to decide which language is best to pick up, or you already have five languages under your belt and you’re wondering which should be the sixth, it can be hard to choose the right one to pursue. There are new awesome languages coming up all the time, like Rust. There are more niche languages like R that are expanding their capabilities. And of course, there are Matlab and Python to choose between as well.

If you find yourself in that boat, this article is for you.

A Brief History of Matlab
A Brief History of Python
Which is best for beginner coders?
Which is best for productivity?
Which is best for a job in computer science?
Which is best for image processing?
Which is best for machine learning?
Which is best for data science?
Which is best for deep learning?
Which is best for speed?
Which is best for the future?
Which is best, full stop?

A Brief History of Matlab

Matlab, which is an abbreviation of Matrix Laboratory, is a programming platform that is designed for engineers and scientists to create and analyze systems and products. Originally, it wasn’t even a language at all — it was a simple interactive matrix calculator. It’s also a commercial product and comes with its own working environment. This is one of the advantages of Matlab over other languages.

It’s not an open-source product, which means you don’t have access to the inner workings of its proprietary code. It dominates in academic settings, where its computing power makes it popular for fields with a numeric component. However, it can be extremely expensive for people to buy a single license.

Originally developed by math magician and computer programmer Cleve Moler in the 1960s, Moler didn’t sell it originally. At the time, it was distributed for free to universities. It wasn’t until the 1980s when it was released as a commercial product.

A Brief History of Python

Python is a very different language. It is officially defined by Wikipedia as “an interpreted high-level general-purpose programming language.” It’s open-source, which means anybody can access it, dig around in the guts to see how it works and even create their own packages for it. This is one of the major advantages of Python over Matlab.

Python was ideated in the late 1980s and was first implemented in December 1989. It’s been around since then, growing more popular, and consistently ranks as one of the most popular languages today. It’s got a huge and growing functionality. It’s good for simple tasks that beginners might be interested in, and complex tasks that organizations might want.

Matlab versus Python: Which is best for beginner coders?

I’ll start with an easy question — if you’re a brand-new coder and you’re wondering whether you should go from Matlab or Python, which is best? (This is assuming you have free access to Matlab through your University or other organization.)

A case could be made for both. Matlab is good for beginners because of the built-in integrated development environment and debugger. Honestly when you get started coding, one of the hardest things is getting to grips with the environment. Python has a steep learning curve especially for people who have never coded a line before.

However, Python is also great for beginners. On any coding survey, Python typically comes out on top as the best language for beginners to learn. The benefits of Python include tons of free resources to help you learn; the simple grammar and syntax that reads like English; and the rapid gratification in creating your first functional program, which can happen in just a few minutes.

Both Matlab and Python are good for beginners.

Matlab versus Python: Which is best for productivity?

What about productivity? If you’re a coder (or want to become a coder) who takes their output seriously, you may wonder whether Matlab or Python is better for that.

If you’re a beginner coder and you care about productivity I would recommend Python. The clean syntax is easy to read and write, which means you can get more done.

It’s possible that as you get more advanced or more specialized in the mathematical and technical computing world, Matlab might help you become more productive. It comes with a really clean interface and familiar mathematical notation. Matlab can also create C and C++ code.

If you’re a beginner, Python will help you be more productive. If you’re specialized in the technical computing world, Matlab’s tidy interface will boost your productivity.

Matlab versus Python: Which is best for a job in computer science?

Many new programming students pick up a keyboard because they want to get into computer science. If that’s the case for you, then there’s only one answer for which is best between Matlab and Python: Python is considered the lingua franca for computer science. If you want to get a job in computer science, scan any of the job postings and you’ll see most if not all require some knowledge in Python. Hardly any will mention Matlab as even a benefit, let alone a requirement.

Plus, Matlab is mostly used in schools and ucniversities. This means that if you want to learn Matlab once you’ve left school, you’ll find it really expensive. Python, meanwhile, has a much wider array of courses and tutorials that can teach you anywhere from the basics to pretty advanced stuff.

Python is indubitably best for getting a job in computer science.

Matlab versus Python: Which is best for image processing?

Image processing is a method to extract or enhance an image. While it was first used to enhance lunar images in the 60s, today it has a much wider use range, including image correction, social media filters, medical technology, computer vision, and pattern recognition.

Matlab is really good at designing and fine-tuning algorithms. It offers a bunch of tool boxes that can help you process images. The toolbox for image processing in Matlab means you can use it for image data segmentation, extraction, and analysis.

Python does offer some external packages for image processing, like Numpy and SciPy. AnalyticsInsight.Net found that while both Matlab and Python were able to produce the same results, Matlab was faster.

While Python can handle image processing, Matlab has native tool boxes designed for image processing, and it’s faster.

Matlab versus Python: Which is best for machine learning?

Machine learning makes the internet you use a lot more user-friendly. It makes internet search engines more relevant, it helps email filters for that spam, and it also plays a big role in websites selling you personalized recommendations. I’m writing this article using voice to text, which uses machine learning. All this to say, it has a lot of uses, and I expect it will only have more as time goes on.

This section has an easy answer: Python is the winner over Matlab. Python has tons of libraries and packages for both old school and new school machine learning models. Plus, Python is the most widely used language for modern machine learning research in industry and academia. Manie Tadayon said it best in his article:

“[Machine learning] is the area where Python and R have a clear advantage over Matlab.”

Matlab can be used for machine learning. Matlab has a large collection of algorithms that can offer immediate visual feedback. But remember, those algorithms are proprietary. There’s very little code portability. While it’s easier to get started with machine learning, it doesn’t really have a future unless you only work with other people who use Matlab.

Matlab can be used for machine learning, but Python is both better and more portable.

Matlab versus Python: Which is best for data science?

Data science is such a wide field that you can find convincing arguments for Python being best, or Matlab being best, or both being terrible. Even this section could be its own article because once again, it depends on what you want to do with data science.

For example, this article tells you that python has a really steep learning curve. Matlab, by comparison, is better for fledgling data scientists. Again, it depends on what you want to do with the data science products you produce. Do you want to show them to other people? You won’t be able to do that with Matlab. It also doesn’t really explain how you can get access to Matlab if you’re not part of a university. Remember, proprietary licenses are expensive.

If you’re currently going to school somewhere where you have access to Matlab, and you just want to get your feet wet with data science concepts, I can see how Matlab would be a great option for you. However, if, like a lot of future data scientists, you find yourself wanting to learn data science after you leave school, the only real option is Python. And it’s a great option!

Python is comparatively easy for beginners to learn. It’s open-source, which means there’s a rich array of tutorials and examples that other people have created for you to walk through. There are tons of Python projects for beginners you can do if you really want to get invested in learning a language. The community is diverse and very varied. When choosing Python vs Matlab for data analysis, Python wins.

While it may be tougher to pick up Matlab, I still consider Python a great option for data science.

Matlab versus Python: Which is best for deep learning?

Deep learning is considered an evolution of machine learning. According to Zendesk’s helpful blog post, deep learning “uses a programmable neural network that enables machines to make accurate decisions without help from humans.” You can consider it a subfield of machine learning. Theoretically, deep learning models should be able to determine on their own if predictions are accurate. Machine learning requires more human guidance.

That’s part of the reason I consider Python the best option for deep learning. Because Matlab is proprietary, it means innovations are slower. Python is open-source, which means anybody can create packages that become widely adopted by the Pythonista community. Packages like PyTorch, Tensorflow, Caffe and so on are widely used for deep learning. If you have a look at most deep learning online courses, they all feature Python.

In summary, Python is better than Matlab for deep learning.

Matlab versus Python: Which is best for speed?

I alluded to this above, but MatLab is really fast. There are a couple functions that are known to slow down Matlab, like `fitlm`, but as long as your code avoids those functions, Matlab is indubitably faster than Python.

However, it’s worth noting that Python does compare favorably to Matlab with the ability to use more than 12 processing cores when running jobs in parallel. I loved Rob Hicks’s writeup of the question where he ran time-consuming econometric problems in Python and Matlab. He wrote all the code, so you can check it out for yourself.

Matlab is faster than Python, but Python is better at running multiple jobs in parallel.

Matlab versus Python: Which is best for the future?

Programming languages come and go like empires. Even those that seem permanent can still start to lose sway, and newcomers challenge existing languages all the time. Despite the fact that this causes learning languages to be more complicated, because you never know if wasting 5 years learning Rust is a good idea or not, I think this is a good thing. Innovation, especially in fields like computer science and data science, is absolutely critical for progression. If a language comes along that can do something better than Python, even though I love Python, I would still be happy to see that.

That’s why considering a language’s future-proof-ness is really important to me. While Matlab has been around longer, I humbly believe that open-source languages are the future. Paywalled languages and interfaces won’t go far as data science and computer science become more democratized. We see this in the acceleration of applications for Python — MatLab just can’t keep up because it’s not open source.

Python has demonstrated its ability to overcome a lot of obstacles, including the Python 2 to Python 3 fiasco, the retirement of its benevolent dictator for life, and the rise of trendier languages that challenged its throne. Matlab, meanwhile, has waning influence even in the areas where it once dominated like academic circles.

My college class was the first year to be taught R over Matlab because our professors believed it was a more useful language. And when I wanted to learn a new language, I couldn’t choose Matlab because I couldn’t afford it. Python was the natural choice.

Python is here to stay. Matlab will only become less relevant.

Matlab versus Python: Which is best, full stop?

I normally try to avoid being too decisive in these types of articles, because the truth is there rarely is one best language over another. But I believe this is one of the few cases where one language is clearly superior over the other for a variety of reasons. Matlab has a couple of specific useful applications that make it a good choice for a very narrow group of people. Python, meanwhile, is only growing more useful to more people. There are only going to be more tutorials and more guides to learn it and use it.

I’m not saying you shouldn’t learn Matlab if you get the opportunity. (And if you’re really sold on Matlab, there’s even an option to use Matlab for Python!) But I think most people won’t have that chance. when it comes to choosing between Matlab versus Python, Python wins.

--

--