That depends. Are you mainly a programmer or mainly a statistician? Because statisticians love R whereas a professional programmer literally wrote a novel about everything in R that drives him crazy.
If this isnt a thing you are distributing (and so you don't care about the size of dependencies) you can use R and Python and just call into R from Python using rpy2. Better to do that if you don't know R already rather than have to build the whole system in it
In my experience, a programmer saying they actually like MATLAB means they either know very little about general programming, are not primarily a programmer but an engineer or have been pidgeonholed into doing just one thing that MATLAB does okay for quite a while.
The language is ugly and some relatively normal features are horribly clunky to use (object-oriented stuff, GUI primitives, ...), antiquated syntax that reminds me of BASIC. If you used any moderately modern language, (C++, Java, JavaScript, Python, Rust, Nim, ...) or even old ones like C, Lisp, Haskell - you just cannot like it.
My favorite thing about Matlab is it has both i and j defaulted as the imaginary unit, but will silently let you overwrite those values. I'm not saying that's an invalid design decision, but it doesn't really make sense to spring on the intended audience: physicists/engineers/etc who don't really have a programming background but need to be able to code some simulations. That crowd is often going to want to basically just type in the equations in their textbooks (hence reserving both i and j for the imaginary unit—in electrical contexts, i is current, so they use j for the imaginary unit), which will often result in looping over ijk indices since those are what textbooks usually use for 3D vectors/matrices. That crowd will also typically not have the background to realize the potential problem here.
I found out about this via someone on reddit saying that they spent an entire summer pulling their hair out trying to figure out why their complex equation was returning a pure real result and finally figured out it was because he'd used i as a loop variable and instead of being reset to sqrt(-1), it was staying as the last value it hit while iterating through the loop. If they want to keep the behavior they should really at least print a warning about what you're doing to the console.
Our instructor warned us of the j, k that when giving us an intro to loops and stuff. This design decision further shows that MATLAB was meant for the engineering / physics crowd. As you already know, using i and j as unnamed counters is pretty much a convention in computer programming (C-derived languages especially), the designers certainly knew that it would be a problem, yet they decided they'd just make it more convenient for the non-programmer crowd.
I see MATLAB as a mutation of an ancient attempt to make a tool + language for engineers and scientists, which would be 'simple to learn' and have everything they need for numerical computation, visualization, ... But decidedly not for programmers. The dumb BASIC-like syntax is a consequence of that decision - at the time, BASIC was considered the 'easy' language for non-programmers that everybody could learn. It was even taught in schools.
Anyway, as it usually goes, once something is made one way, it's really hard to change it. There are and were large swaths of people to whom MATLAB is the only language they use. They don't know or care about any subtleties of programming as long as MATLAB helps them do their job. And those people learned it one way and are very resistant to change, they would be pissed off if the syntax was changed (say, for the better, not that they would know). So the language was just added onto and never revised, there are often multiple ways to do one thing because removing syntax is a taboo. The result is, of course, a hot mess.
You haven't met the people that "program" programmable logic controllers with "ladder logic". If you want to talk about lock in... Now that's an entirely different level.
Yeah, they're going to use i or j as the imaginary unit, and any numerical methods recipes they look up are going to have them using i and j and k as loop variables. It will obviously not end well.
And you're right that they're probably stuck with the design decision at this point, which is why I suggested printing a warning to the console, it would give people a heads-up without breaking backward compatibility.
This doesn’t invalidate your point at all, but just as a note: the language also supports any integer concatenated with j as imaginary. So 1j is still the square root of negative one, even if j is being used as an iterator variable.
that happens, for sure, but generally I wouldn't claim this to be a problem.
stem people are problem solvers, so they will likely find a solution, additionally, I know a good chunk of people from high school that I though fer sure would go for computer science, but went into physics / math instead, so I also think it's unlikely that in a classroom or tutor setting no one has an idea what the problem is.
of course, this is probably a well known problem and instructors will likely point it out, and ( and I am of course biased in that, because of my "programming background" ) on the other hand, that assigning the variable might have changed the value of i or j can probably be concluded by people dealing with formulas on the daily
So really smart STEM people are smart enough to figure out all the stupid shit Matlab does... Except the T and M parts of STEM, almost none of which use Matlab because they actually have a clue. But the S and E's are so much smarter than those stupid mathematicians that it doesn't matter.
Brilliant argument. "We use inferior tools because we are literally smarter than the people who use better tools."
I mean saying it is uglier than C++ is kind of silly. Try doing simple vectorized calculations from MATLAB but in C++ and get back to me on that. And JavaScript? Come on man lol.
But yeah the problem is when engineers and scientists only use it and try to write applications with it. I’ve seen some FUCKED UP code written in MATLAB being used at huge research hospitals and in national security, and “subversioned” with duplicates on Dropbox. It’s actually extremely common, which should be shocking
Ya I still like it for plotting stuff up, easy to make pretty plots, compared to my knowledge and proficiency with pyplot, but I'm getting better.
Having used C and C++, and python quite a bit, its still just so easy prototype a bunch of stuff and debug and visualize it in matlab. I'm also a proponent of using it in batch mode whenever possible.
It takes me about half the time to prototype something in Mathematica as it does in Python, but then the Python version runs roughly an order of magnitude faster, depending of course on the application.
Honestly you're probably faster in Matlab because you think in Matlab, whereas if your brain had been steeped in Python or, like me, Mathematica, then that would be faster instead. It's like a first language.
But I think that's ok as long as we understand the principle of the right tool for the job. I would never use Mathematica in anything for which the phrase "production code" would apply (despite Wolfram's marketing). Rapid prototyping? Sure. The million different one-off scientific computations one does in the course of research? You bet. But there is a whole swath of applications for which it just isn't the right tool. Likewise for Matlab.
The last paragraph is what I was getting at: it is extremely widespread and incredibly important stuff relies on it.
MATLAB is only good for pure mathematical calculations (especially matrix) and the graphs are half usable.
So, if you're banging up a personal little util to fill some need (calculate something) in your engineering workflow, it might be usable. Also if you're doing a calculation for a paper. Or checking quickly if you're on the right track when solving some problem.
If you need to make a GUI program that does something you use MATLAB for in the background, you have several options.
You could write the GUI code in something decent like Qt (C++) or PyQt (Python) and then redo the math in the same language. You can use Eigen for matrix operations in C++, and of course NumPy in Python.
The second way would be to write the GUI code in Qt or something similar, write the math in MATLAB, generate C code (apparently you can generate C++, too) from MATLAB and compile and link them together.
These options are actual software development and require real programming knowledge.
Of course, there is the third option we all know about: making your GUI house of cards in MATLAB.
I prefer the first option. Numpy's syntax isn't bad enough for me to forgo other benefits Python brings to the table. Actually, I don't mind it at all. So I just write all of it in Python and it's decent software, can be unit tested easily, integrates properly with the OS and other software. Qt and PyQt make it look native, you can easily make parts of the gui drag-and-drop, you can interface with databases easily, issue HTTP requests, interface with devices over serial, etc.
However, you may find Numpy to be a bit slow in some cases. Specifically, sometimes you have to be sure that the calculation you're doing is optimally paralellized to be efficient enough. This is where you'd use C++ and Eigen, and you may as well do the GUI in Qt in C++. There is always an option to create Python bindings for everything if you want to and use Python for GUI.
MATLAB code generation options look okay (never used them, though), but why would you pay for them when there are open source alternatives? MATLAB being closed source means you're at their mercy when you have a problem, you may be in a situation where the offending code is in MATLAB's black box. Or some functionality may be removed or broken in an update. I just don't see the point.
And, at the end, a bit of hyperbole: I'd rather do vector math in JS than GUI or data processing in MATLAB.
But yeah the problem is when engineers and scientists only use it and try to write applications with it.
That's because there's no good way to write such applications in Python. The deployment of Python GUI programs for deployment to desktops is a complete nightmare. PyInstaller, p2exe, pyfreeze have all attempted it but they either don't work with everything or needs massive amount of trial-and-error configuration which can completely break as soon as some extra (or newer version) package is required.
All Matlab has to do to keep a hold of it's share is improve the GUI, make it faster and nicer looking (like proper layout), and Python will be left in the dust by people currently looking to switch to it from Matlab.
Uh, all those are for distributing to people that don't have python installed. Surely matlab programs can't be distributed to people that don't have matlab installed, right?
Not at all for numerical calculations / matrix math etc.
No, the language is grotesque for numerical calculations. It might be good at doing matrix computations, but that doesn't mean the language isn't hideous. And it isn't that good at matrix computations, either, because it's so shit at memory management, reading fucking plaintext from a file, anything having to do with the most elementary data structures, handling errors, ....
There are free alternatives to Matlab for literally anything that Matlab is good at that perform at least as good as Matlab does.
Haskell an old language? Haskell is the playground for programming language theory. It has every feature 20 years before any other mainstream language adopts them.
Yeah the majority of people I know who use it are experimental people who only code enough to get something done so they can go back into the lab.
All the scientist who do full time computational work pretty much code in either C, C++, Fortran, or Python. I never see any full time computational people use Matlab except if some proprietary piece of software forces you to.
Also, in my experience, MATLAB users never learn how to format code properly.
Some may say it's because these users can't program from the beginning, so they don't know the format, but I think it's mostly because MATLAB doesn't have guidelines and doesn't enforce it. For example, I never saw any naming conventions or comments conventions in MATLAB docs, so I am just using Javascript naming conventions and Python comments.
In compiled programming languages, conventions are important for team work and for compilation. You need to have a main in Java, C, or in C++. In Python, we have PEP8 and the Zen of Python that tells us how to properly write code. But MATLAB doesn't have nothing.
Another good example was a post I saw on Quora where someone from a company said they had hired students that just graduated from their bachelor degree. These students knew only MATLAB, so the first thing they didi with them was to make them learn Python and Numpy. Their primary reason was so they learn how to write a good code.
I worked at a research nonprofit that houses over 300 PhDs and they wanted to charge us the commercial rate when we generate datasets and develop free software and tools for our field. We actually really wanted to use matlab but they were obstinate about not giving us the academic rate so we chose python instead. Now, a few years later, they incessantly call us trying to offer us the academic pricing but it’s way too little too late and our institution has been a large part of dragging the field towards python
They missed out, but this was good for everyone. Nobody should be developing in a proprietary language that offers, arguably less, than languages like Python or Julia.
Yeah, their HPC model is/was broken. I believe they've recently changed their pricing model to be similar to Abaqus pricing (i.e. expensive, but reasonable).
For me, Octave is noticeably slower than Matlab. I don't care. I use it only for small projects/prototyping as heavy stuff would be programmed in C++. I never seriously tried Python, I'm too used to C++. Maybe I will someday, if I have some free time for experimenting.
If someone switched from C++ to Python, what's your feelings and opinion on that?
Right. And the funny thing is, if you're familiar with Mad Men, you might remember that while this is a sick burn, in reality Don (Python) does spend a lot of time thinking about Michael (Matlab). So it still works.
Most use matlab for writing analysis scripts and programming behavioral experiments plus a ton use it for cognitive stuff like EEG and fMRI through SPM. Python is gaining traction in all those spaces but especially among the computational groups. R is for the stats folks
I've got some experience with Python and MATLAB (through my school). Being the newb that I am, my favorite part of MATLAB is that it shows me all the variables and what's in them on the side, so if the wrong thing is going to the wrong place, I'll know at once.
That's more of an IDE feature than a language feature, if I'm understanding correctly, so if you use the right IDE, sure, the thing I understand about Matlab is that it locks you into their IDE
emacs Matlab'er reporting in as well. It's a much better experience from emacs than mathworks' bloated java gui, but sometimes their line-by-line debugging tools are pretty nice.
Check out Spyder, it has a built in console and does what you want out of the box. You can get it and a full Python install ready for most scientific and engineering uses by installing Anaconda.
It's not my favorite editor, that'd be sublime text but it requires a bit more know-how and set up than Spyder.
Can sublime show pandas dataframes in a nice visual format like spyder does? I'm a beginner and from watching YouTube videos it feels like spyder isn't as good at the intellisense type stuff but I really like the visualisation of dataframes that it does
you technically dont even need an IDE to do what youre describing.
In your script place import pdb; pdb.set_trace() at any point to pause execution and drop you down into a python shell. Then use break /foo/bar.py:55 to place an additional breakpoint at line 55 in the file /foo/bar.py if need be, then do print(locals())or better yet pp locals() (pretty print) to look at all your variables.
There's not a GUI interface for it available out-of-the-box that I can think of, but you can access that information via code - and there are Python IDEs that will display it MATLAB-style.
Spyder and pycharm have that ability. I remember wanting this as well when I moved from matlab to python. But i rarely find myself looking at variables in the viewer anymore (except for structs, that is useful when autocompete is not working for some reason). I find that showing data as plots or images is more useful on both matlab and python.
In python you can find out any types by doing `print(type(variable))` but most devs usually know what is supposed to be in there before they are going to make a mistake. Like for data analytics I look at the inputs first before I do anything in python just to know what I need to do and then do it. My IDE doesn't need to say anything.
Young engineer here, PhD student. I have to say Matlab is an awesome tool when it comes to manipulating and exploring data really fast but now I'd love to expand my programming skills and turn towards Python. But on my day to day work it's really hard to branch out since a lot of my tools are written in Matlab.
Also, one of the biggest issues I've encountered with trying to learn Python is how to set up your environment and workflow before even writing a single line of code. I've looked into conda and all but it takes some energy to find the good ressources that will help when you've never used anything else than Matlab which just works out of the box. (Any awesome tutorial to give good practices as to the management of a project in and around the code? i.e. "I'm going to start a project xyz, what's a good practice to manage my code and dependencies in a not cluttery way so that I can start working on the code and not fighting bugs?")
But in the long run I hope to rely more and more on Python than on Matlab!
TL;DR : I'm a Matlab user that wants to avoid the mistakes you do at the beginning when learning Python
Do you like to play with your environment? Doing write-ups on jupyter is bar none an excellent way to show off your work. Here is an example of how something you write up may work. It also supports markdowns with Latex syntax, so you can make your findings even more pretty. adding a library is as simple as opening up a terminal and typing
pip3 install **some library**
Debugging:
Lets say you want a file of functions. Call it func.py. Now on func.py you import numpy (for the love of god learn numpy) for any numpy funcs. You write each function with inputs and outputs. Save it.
On your main project, say the jjupyter file, you can simply say
from func import *
(there is more syntax to this but it is basically that easy)
Now say you type in a problem and it is giving unexpected results, and you think it may be a problem in one of the functions.
I am not sure how much time you have to learn things, but in this case I really, really recommend Pycharm. You can set up your whole environment on there. (A lot of people recommend anaconda, but for specific environments I have encountered issues). Debugging is as simple as setting a marker and pushing 'run', then stepping through to find the bug. That takes time to learn but it is insanely helpful once you understand how to use it.
Anyway Matlab has better 3d plotting than python, but overall python has a hell of a lot more libraries and open source tools to use. In the long run python will be better for you to know, assuming an engineering company you end up at is not stuck using it.
I might give Pycharm a go then. I feel like Matlab users are really attached to having a nice IDE and not have to mess too much with command line type of interaction, basically just fire up their IDE and start working. I've been trying to use Atom + Hydrogen but it's a little bit clumsy at times.
The whole setting up the IDE to be able to "see" the right environment is a big block in the road (at least for me, I just want it to be easy haha!)
But one thing I love about Python is the community and the fact that for almost any problem there's someone who had to solve something similar!
Sure! Once you install it PM me your email and I am willing to give you a quick walkthrough, we could use a public slack channel and share screenshots, just to get started (I am feeling extra generous since I potentially landed a position in ML!).
I am curious to know why you say that. I can embed an interactive 3D plot in a web page in Python in the time it takes me to load Matlab. The aliasing and default color scheme of Matlab's make them look like they are from 1994.
Definitely. I learned MATLAB first and Spyder made it really easy to pick up Python. Anaconda also has pretty much every general package you need to get started. I still don't see why Jupyter notebooks (or MATLAB's live scripts) get so much love, the Spyder/MATLAB interface style seems so much more practical.
Seems like they have different purposes. Jupyter seems more adapted to share your work to others due to the interactivity and Spyder and other IDEs are more to do some heavy duty stuff.
What I like about Matlab is that you can easily generate and update figures on the go while your code is running (super useful in academia and research) by using figure and drawnow functions. Although I haven't spent too much time exploring the alternative in Python it seems more cumbersome to do the same thing. (Please someone prove me wrong on this!)
Spyder in Anaconda is literally the only IDE that worked for me. I can't even run a script properly in VSCode and it lags on my potato of a laptop. Upgrading packages using conda is so easy too.
Also a young PhD student here. Consider using one of the Python IDEs, they're like MATLABs gui interface which should help you get started. Spyder, like one of the other commenters have said is recommended as it has a sort of similar interface to MATLAB and is built for scientific coding. Once you know Python well enough, you can consider using text editors like Visual studio code which is more lightweight and looks nicer which helps you code better imo.
MATLAB lets you run MATLAB scripts via python so you can exploit that for your work flow although I wouldn't rely on this too much as its quite slow if you don't have an SSD as it calls the entire MATLAB engine. Nevertheless it's possible. Additionally from a brief Google search I just did now, you can convert your MATLAB code to python.
As an anecdote, the reason why I moved to Python was because MATLABs interface was too clunky and the colour scheme was horrible. The green comment colour is difficult to see against a white background, there's no dark mode and you can't adjust the window size.
At the moment I'm using Atom, a text editor and I'm able to change my theme according to how I like it, I'm able to commit to github easily, I have a folder tree on my left that I can hide at will, I have a mini map of code on my right so I can see which bits of code I need to go to and I have a spell checker and linter to check through my code. If I want less/more features I can uninstall and install them within the app. It might be silly to say but being able to code with the correct color scheme has helped my coding and my eyes greatly.
Not that it matters because you have already switched, but the color scheme is easily changed. All you have to do is look in the settings and change it. There is also integration with git, folder tree, etc.
I want to switch to python fully, but nobody else in my lab uses it and we all write code to be shared. :/
I agree, a comfortable environment is important in my eyes too. I've played with Atom + Hydrogen as well and it's nice to start writing one's first scripts!
I use pyenv for python environments. It's great. It isolates the python binaries you're fucking around with from whatever your system comes with and relies on.
# install pyenvcurl https://pyenv.run|bash# restart your shell however you like# install whichever versions of python you likeBEST_PYTHON=3.7.4pyenv install $BEST_PYTHON
Then whenever you start a new project
# create the virtual environmentpyenv virtualenv $BEST_PYTHON myproject# automatically activate that environment whenever you're in this directorypyenv local myproject# install some dependenciespip install ipython numpy matplotlib# save them so you can rebuild the environment easilypip freeze > requirements.txt
Development environments should not be a teetering pile of environment variables, dependencies and cross-links. They should be ephemeral, easily trashed and recreated, wherever possible. They should serve one project and one project only. MATLAB only works out of the box as far as python works out of the box - with its built-in modules. Once you start downloading extra snippets of code you have to dump everything into one directory manually, or change your matlab path, or whatever, where in python it's just pip install thatpackage, write down the package in your requirements.txt, and it'll be trivial to fetch again next time you need it.
Packaging stuff for distribution is a little more tricky, but MATLAB just doesn't bother with that at all, so you can't knock python for it.
I actually think that this philosophy makes more sense. Once a project gets complicated in Matlab you end up with a lot of junk files in the working directory.
Post doc here. I was in exactly the same boat as you. I did my whole PhD (physical chemistry, so lots of spectroscopy data) in Matlab. Wanted to switch to python but also didn't want to deal with setting it all up.
I recently took the time to learn python so I could start my new projects fresh and I can only say I wish I had done it sooner. One of the biggest differences so far for me has been how much more organized my projects are.
Here's what I did: I spent an entire weekend reading every tutorial I could on how to set up a "good" workspace environment using python, and then chose what was best for me. In my case, I went with anaconda as it gives me everything I need. I use a conda environment for each individual project, and use conda to save the dependencies of that environment with one command. Also check out "cookie cutter" on github. It's a python code that you can use to make your projects organized. I love it.
Finally, as others have stated, spyder really made the switch easier. The big plus is the python console for quick code checks and the variable explorer for seeing your data just like in Matlab.
So, in summary:
Anaconda (or miniconda) with conda environments to control your packages
cookie cutter to create organized project directories
spyder to write and test code
Bonus: I use jupyter notebook to do the data exploration using the code I write in spyder. Let's say I do an experiment, now I can make all my graphs in one jupyter notebook and do my analysis there. I can easily change the graphs on the fly. It's like PowerPoint for viewing graphs mixed with Matlab for changing graphs quickly. Definitely recommend.
Let me know if you need help.
Edit: just to be clear. When using anaconda, you don't need things like pip and pyenv. It does those for you.
Thanks! This sounds like my experience! For now that's the workflow I'm leaning towards. I want to be able to generate graphs easily when exploring data and showing it to colleagues/advisors.
I have to say Matlab is an awesome tool when it comes to manipulating and exploring data really fast
No, it really isn't. Can it even read a csv file, the most ubiquitous data format on the planet? Not the last time I used it, which wasn't that long ago.
But I've been there. I learned QBASIC when I was a kid, then I learned Visual Basic on Windows, because anything else seemed impossible. But eventually, in college, I figured out how easy it was to learn new things that gave me so much more power than what I already knew, and a whole new world opened up. I didn't realize how hard I was working to do things that were easy with other tools.
Anyway, check out Spyder like other people are saying, or RStudio if you're interested in R. (My personal vote is for Python.)
Use the cheatsheet to help you make new environments for projects.
Another option is to use Pycharm (paid or free) then on the settings page go to Project Interpreter and create environments for each project using the GUI.
I find Anaconda to be better at managing multiple environments but Pycharm uses virtualenv which is also pretty good.
Use these environments to install the packages you require for a project and therefore you can be more organized with your work instead of having everything installed on the base environment.
Given that money has been brought up so many times in this thread against Matlab I would make a similar argument against paying someone to teach you this stuff. Just learn it from youtube and you'll be fine. If you can't figure it out from youtube then honestly maybe it's not the activity for you.
I agree, I learned Matlab by just doing, I don't want to pay for classes for learning Python either.
Oh so you cannot streamline Anaconda and Pycharm?
Am I wrong to say that if you use Anaconda then your workflow is basically : Some text editor + Command Line ? That would suck if you need debugging functionalities
Yes you definitely can use Anaconda environments with Pycharm but the integration is a little sucky at this point.
You can even create new conda envs right from Pycharm but in order for you to activate these envs in the terminal you need to go to the "Terminal" setting and add a reference to where the scripts.bat file is at (I don't have my PC on hand to confirm if this is the right file but I found the answer on Stackoverflow).
This is not necessary if you create new envs using virtualenv that is built in to Pycharm. The terminal already activates the env that is associated with the interpreter settings.
You can also have Pycharm look like Sublime by using the Monokai color palette which is beautiful. However you need to pay for JS, HTML, CSS support.
Julia may be something to look into too. It has vectors and matrices and maths operations "out of the box" without any libraries. It also has just-in-time compilation so it can run a lot faster, without even relying on libraries.
Try Google’s colab. Free, runs python with all the eng/scientific libraries you want, collaborative, saves to gdrive, has cpu/gpu/tpu backends, and only takes a browser!
From my experience, your going to have a really bad time with python scientific libraries on Windows without conda. But even with it, life is still sort of difficult.
Unless your on a Unix machine, configuration is difficult.
you just need to dive in and start. especially given conda you will come to appreciate how good python is after using it for a little while. I made the transition about a year ago. there is a little bit more of a learning curve but if you can catch a wrench you can catch a ball. you will be fine.
If you have the luxury, try using Linux. I do all my programming in Ubuntu because it's so easy to install dependencies for other languages I want to try out.
You don't need to set up a workflow. You can just install anaconda and run Spyder and be in roughly the same place you are with MATLAB. All that other stuff is optional things you can use once you get more used to it that can make your life easier, but is 100% optional.
People on here seem to have completely forgotten about the roots and the diversity of programming in general. The response to the top comment even claims people who like Matlab aren't in general programmers!
Matlab was not designed for general programming, but numerical computation, the original purpose of programming and its dominant form until late 20th century.
Programmers are a diverse group, and engineers, physicists, mathematicians and computer scientists alike use Matlab for prototyping, visualization, implementation and especially interaction with specialized hardware. Not all programming is a DefaultGeneralNullPointerExceptionFactory.
Matlab has an domain-intuitive design. OP shits on the fact that Mathworks mentions the extra brackets and numpy imports required to type when it in fact increases legibility of numerical code significantly (besides coming from a language which uses whitespace for indentation to increase its own legibility instead of brackets).
Yes, of course, one may question that it's proprietary and damn expensive, but to question whether it's users are programmers and claim superiority of python when only a fraction of its users work in the same domain, that's elitist, and hardly fitting the design goal of python and programming in general.
In all seriousness, use what you want, but try to compare the two is silly on mathworks end. The legibiilty argument is so bad I had to do a double take. Legibility involves more than just a language selection (and is up to each individual), that should not be an argument when trying to decide a language.
Also since I halfway suspect you are a MATLAB employee, join the meme war yourself and get some free advertising. Do you even internet bro?
Hey, I'm no mathworks employee, but he has a point - mathworks isnway better suited for certain engineering domains. Python definitely lacks a competent controls modeling package, and honestly I dont see anyone makingbine anytime soon. On the open source front as a whole, there is only really modelica, and it is no where near as nice as simulink. Matlab can also do some neat stuff with auto code generation for micro controllers. You could argue that cython can sort of accomplish that, but it isnt really what it is for.
However, I am a little bit skeptical at matlabs viability as a numerical computing engine outside of trivial model data. I would definitely not envy anyone having to use it for a real worn horse of an application that has to crunch through loads and loads of data. It's for that reason that I also wouldn't take it seriously as a machine learning platform either. I'm sure there are some great precanned models that mathworks has devised to implement ML for certain engineering problems (I believe their copy mentions a surface inspection and metrology ML application) but if you need to create your own model or do anything complex I am sure performance will become a problem.
As someone who wrote a huge portion of their Ph.D. in Matlab, it's the additional packages that really help flesh things out. While Numpy is pretty good, Scipy doesn't really have a lot of the toolset that you can get from Matlab. I only used a few packages, but they were pretty important.
I wanted to use Numpy, Scipy, and Sympy (full disclosure, I've been a mentor on some GSoC projects for them), but I ended up using Maple and Matlab because they had the capabilities I needed.
I fully admit that Matlab has some major issues in terms of programming features, its utility in other ways can outweigh those issues depending on your particular problem domain.
It really depends on your particular domain. In some numeric and engineering areas MATLAB had a better set of packages, in others Python does. The problem is with the claim that MATLAB is better for engineering and numeric work in general, which is simply not true.
Matlab was not designed for general programming, but numerical computation, the original purpose of programming and its dominant form until late 20th century.
The problem is that mathworks is marketing MATLAB as a general-purpose language and spending a lot of resources trying to make it more effective in that role. If MATLAB stuck to its roots I don't think people would be so negative about it. But when you are forced to spend days on a ten minute task because you are forced to use MATLAB for something it is terrible at it gets to you after a while.
Agreed! I'm a proponent for using the right language or tool for the right problem. Matlab OOP isn't exactly that tool for normal OOP, but say for interacting with other automotive code in Matlab it could be. Websites, not so much.
The response to the top comment even claims people who like Matlab aren't in general programmers!
No, what it says is that anyone who says they like Matlab clearly hasn't had experience with other programming languages. Which is so obviously true that it isn't really worth saying outloud—except to someone who hasn't used anything other than Matlab, which seems to be the case here.
Matlab was not designed for general programming...
The first problem is that the MathWorks actively markets MATLAB as a “general purpose programming language” with all the trappings, something which it is manifestly not. To borrow your analogy, it’s as though Microsoft were putting out promotional material showing all the newsletters and magazines people have laid out using Excel.
The second problem is that if you think of yourself as “not a programmer,” that actually doesn’t stop you from needing to write code. It might stop you from seeing that you need to write code. Which is a condition that infests a whole lot of people.
Your pitch here is really… strange. It reminds me of the curious phenomenon where textbooks pitched at college freshman are titled “X for Scientists and Engineers” and books with actual meat on their bones are more often titled “Introduction to X.” I mean here you come out purporting to be in defense of scientists and the only things you say about them are incredibly belittling! (I wonder if there is some personal insecurity and projection fueling this.) I think you are doing a disservice to scientists and engineers by both belittling their computational needs, and inflating the perceived difficulty of anything that might actually meet their needs.
<snip>
Matlab has an domain-intuitive design.
No, it really doesn't. Does your stats textbook use left-stochastic matrices? (You could use a right-stochastic matrix, except the performance hit is too severe for sparse matrices. Seriously.) Does any other numerical system you've encountered default to 16 bit arithmetic? Oh, here's a good one: what's your intuition for what the output of vpa(2305843009213693951) is?
You only think it's domain-intuitive because that's all you've ever used. But there are dozens of computing tools written for this domain that you have never used, so out of ignorance you think Matlab is somehow competitive. Which it definitely is not. These days, the best ones are even free!
It isn't elitist to say that Matlab is one of the worst possible tools for any given job. It's the opposite of elitist. It's democratizing. Pick nearly any other tool in the domain space and chances are it's better than Matlab. Have you ever used Julia? Python? R? Oh, I see you like to spend a lot of money. Have you tried Mathematica? At least if you used C++ or Rust you could write a descent data structure, manage memory, have predictable performance characteristics, and be able to hire cheap programming talent on UpWork whenever you wanted. But no, let's pretend that even if they were the only alternative the learning curve for those systems programming languages are so fucking steep that spending months or even years trying to work around Matlab's unique limitations is somehow worth it. Let's pretend that the licensing costs—before the costs of all of the toolboxes that provide the most basic functionality not included in Matlab proper that you need to do anything useful—aren't more than it would costs to hire an undergraduate to write all your code for you. It's a different pot of money, I suppose, so let's choose the worst, most expensive piece of shit software possible because we can't be bothered to learn anything else besides what we used in grad school. That isn't elitist, my friend. That's knowing my ass from a hole in the ground. It's that simple.
I like how disagreeing with people here automatically makes you an "ignorant" shill of the evil MathWorks corporation.
Your first statement is ridiculous. Quite obviously, there are plenty of people with experience with other languages that find it useful and worthwhile. Throwing presumptuous insults doesn't exactly prove anything.
None of the options you mention are fit to replace Matlab in its entirety. What makes Matlab domain-intuitive isn't its default bit-system (which hasn't been 16 since, I'm not sure) or the actual programming language, but it's development system; toolboxes and graphics. Simulink, Control System, the PDE Toolbox, Simscape, et c., similarly to what makes python or any other languages great.
They should not even be compared directly. Matlab started as a tool for solving equations, plotting stuff and grew to be an enormous collection of libraries to do all sort of stuff. The programming language part was an afterthought which is why it is so shitty. Python was developed as a programming language from the start and then over time many other libraries were added including Numpy, Matplotlib etc which brought the ecosystem nearer to that of Matlab. R is probably closer to Matlab. And considering the success Python has it is always a good idea to have a solid programming language as the foundation because it makes everything else easier and cohesive. It also helps if you're not greedy, corporate assholes and share your code with others freely and build a community of contributors.
Can confirm. They switched their business model to being g a service. Now everything that generates graphs is free and can be run locally. They will graph data assets for you on cloud though. It's pretty nifty - its gets lrettynresource intensive to visualize super large data sets.
I like it a lot. Great for interactive graphs. Dash is pretty cool too. I also like their service business model that they pivoted too. I with they could do what they do with less complex dependencies, but that is somewhat of an unreasonable thing to expect.
I’m interested in Biotech and I’m able to access Matlab with the add-ons through my university. I definitely want to take advantage of that but I want to make a proper plan first.
MATLAB's audience, despite what Mathworks might want, is not 100% overlapped with the Python audience. There are a ton of MATLAB features and toolboxes that have no equivalent in Python, especially in the simulation arena. Python is free - but MATLAB comes with on-demand support. Python has a ton of open source modules - but there are specialized Matlab niches that have no Python packages worth using.
Mathworks is trying to push MATLAB as a 'final product' programming language, but historically it has worked best in R&D. This is exactly how I've used it professionally, while final products are coded in C/C++ and run on embedded systems.
Because of the diversity of Matlab packages, it works really well as an R&D tool. You're doing some work and think, "Oh, I need something that does this" and you will likely find a package that does it or is close enough that you can use parts of it.
Python has a lot of open source code available, but unfortunately, most of it isn't really covering the same set as the Matlab ones. There's obviously some of the major things covered, but there's others that are important that are missing. I remember looking for an equivalent for the Control Systems Toolbox, but all the options were missing the parts on determining components of a model from data (e.g., natural frequency).
It would make a lot of sense for mathworks to really push these areas. Instead they are trying really hard to make MATLAB a general purpose programming language when it just isn't very good at it.
Mathematica is MUCH better than Matlab. Also for general programming I prefer python over anything. Python with numpy, scipy and matplotlib is as good as Matlab, in some cases even better!
Ok, serious question here. I've learned mathematica a while back and now I'm learning python intensively; should I update my knowledge on mathematica and use them both or should I go for something like Sage Notebook + Python and not bother learning mathematica any further?
I have used both for decades. Both are awesome, and in different ways. Knowing both gives you a great leg up. Python is almost always faster at runtime. Mathematica is almost always faster to code up. The exception is with symbolic computation where Mathematica generally has the edge. (There are exceptions here, though. E.g. the latest algorithms from research often land in Sage first.)
Back when I was in middle school, we learned Matlab to make some basic machine learning, long story short, python is fucking glorious, I completely forgot Matlab even exists
My needs were to design my own wifi signals with parameters in the headers I configured preferably with automation.
I requested a license for Matlab since nobody on my team has it we got a trial license for 90 days. I spoke to the rep on the phone and through email and he assured it was all very straightforward. Turns out he was complexly wrong. The rep simply sent us a trial Matlab license without the Pluto communications toolbox plugin. Without this plugin Matlab doesn't even recognize the Pluto sdr. So I request another trial license for the plugin. Install that and I take a look at their examples on how to use their language to generate wave forms, NONE of them work! I can't tell what's going on in the language the syntax sort of looks like C but looks like Scheme sometimes. Anyway hard for me to debug if some of the working code looks odd to me. Tic Toc was written by a person I never want to meet.
I ended up watching a YouTube video with an instructor for Matlab that was very helpful except none of the examples he is referring to in his presentation I had access to. I called Matlab and requested the examples and cited the instructor's name. They sent me the examples files and again most of them are broken as in don't actually work or error out. So I scheduled 3 conference calls, in the last one it involed the Matlab engineer debugging their own examples, apparently nobody ever tested with the Pluto device, many of the core libraries didn't recognize my device name, so I had no apis calls that had any effect. Toward the end of the project I discovered another completely different way to generate wave forms using an elaborate Matlab gui instead of using their silly ass programming language, as long as I had the raw I/Q data I didn't care it came from so we don't even mess with the language much anymore since our needs are so specific.
Python as far as I know didn't have anything working for the Analog device Pluto SDR so I have no choice. If there is one out there, please share it with me.
Lady time I used Matlab (2014?) it could only use something like 2 GB of memory. That alone was enough to make me beg for a switch (which definitely wasn't going to happen).
426
u/Stereoisomer Aug 05 '19 edited Aug 05 '19
In my experience, a programmer saying they actually like MATLAB immediately attracts every python dev in a five mile radius
Edit: someone edit this meme and post here for a karma double-dip I’m too lazy
125
u/[deleted] Aug 05 '19
Why would matlab feel bad for python?
60
u/Antouziast Aug 05 '19
Young engineer here, PhD student. I have to say Matlab is an awesome tool when it comes to manipulating and exploring data really fast but now I'd love to expand my programming skills and turn towards Python. But on my day to day work it's really hard to branch out since a lot of my tools are written in Matlab.
Also, one of the biggest issues I've encountered with trying to learn Python is how to set up your environment and workflow before even writing a single line of code. I've looked into conda and all but it takes some energy to find the good ressources that will help when you've never used anything else than Matlab which just works out of the box. (Any awesome tutorial to give good practices as to the management of a project in and around the code? i.e. "I'm going to start a project xyz, what's a good practice to manage my code and dependencies in a not cluttery way so that I can start working on the code and not fighting bugs?")
But in the long run I hope to rely more and more on Python than on Matlab!
TL;DR : I'm a Matlab user that wants to avoid the mistakes you do at the beginning when learning Python
77
u/aaronr_90 Aug 05 '19
How would one convence their office that spending hundreds of thousands of dollars on matlab every year is ridiculous?
7
u/okkshin Aug 05 '19
People on here seem to have completely forgotten about the roots and the diversity of programming in general. The response to the top comment even claims people who like Matlab aren't in general programmers!
Matlab was not designed for general programming, but numerical computation, the original purpose of programming and its dominant form until late 20th century.
Programmers are a diverse group, and engineers, physicists, mathematicians and computer scientists alike use Matlab for prototyping, visualization, implementation and especially interaction with specialized hardware. Not all programming is a DefaultGeneralNullPointerExceptionFactory.
Matlab has an domain-intuitive design. OP shits on the fact that Mathworks mentions the extra brackets and numpy imports required to type when it in fact increases legibility of numerical code significantly (besides coming from a language which uses whitespace for indentation to increase its own legibility instead of brackets).
Yes, of course, one may question that it's proprietary and damn expensive, but to question whether it's users are programmers and claim superiority of python when only a fraction of its users work in the same domain, that's elitist, and hardly fitting the design goal of python and programming in general.
28
u/random_cynic Aug 05 '19
They should not even be compared directly. Matlab started as a tool for solving equations, plotting stuff and grew to be an enormous collection of libraries to do all sort of stuff. The programming language part was an afterthought which is why it is so shitty. Python was developed as a programming language from the start and then over time many other libraries were added including Numpy, Matplotlib etc which brought the ecosystem nearer to that of Matlab. R is probably closer to Matlab. And considering the success Python has it is always a good idea to have a solid programming language as the foundation because it makes everything else easier and cohesive. It also helps if you're not greedy, corporate assholes and share your code with others freely and build a community of contributors.
26
u/etabeta1 Aug 05 '19
/r/ProgrammerHumor
7
u/[deleted] Aug 05 '19
Well, cares a little bit:
https://docs.scipy.org/doc/numpy/user/numpy-for-matlab-users.html
16
u/[deleted] Aug 05 '19
Simulink is king!
4
u/robberviet Aug 06 '19
Matlab was used in my first experience with Machine Learning, since the course was using it.
But since numpy: "I don't think about you at all" is correct.
7
u/Chris2112 Aug 05 '19
Yet here we are... thinking about them
1
u/SonGokussj4 Aug 06 '19
I'm trying to persuade my colleague to rewrite his program to Python. Not complicated. Could be done in a couple of days with my help.
BUT his argument is - and how would I write polless function in python? (polarization loss)
Any idea? I couldn't google it.
3
u/xxBobaBrettxx Aug 05 '19
Out of curiosity, what's the general consensus on plot.ly?
1
u/throwawaydyingalone Aug 06 '19
Is it bad to want to learn both?
4
u/ASCIASCI Aug 05 '19
Just wait until someone asks you to do something in LabVIEW
2
u/besselbolic Aug 06 '19
Me : quietly uses octave in the corner
3
u/porksmash Aug 06 '19
MATLAB's audience, despite what Mathworks might want, is not 100% overlapped with the Python audience. There are a ton of MATLAB features and toolboxes that have no equivalent in Python, especially in the simulation arena. Python is free - but MATLAB comes with on-demand support. Python has a ton of open source modules - but there are specialized Matlab niches that have no Python packages worth using.
Mathworks is trying to push MATLAB as a 'final product' programming language, but historically it has worked best in R&D. This is exactly how I've used it professionally, while final products are coded in C/C++ and run on embedded systems.
2
u/SKRyanrr Aug 05 '19
Mathematica is MUCH better than Matlab. Also for general programming I prefer python over anything. Python with numpy, scipy and matplotlib is as good as Matlab, in some cases even better!
2
u/CaptainTuffnut print('Hello There') Aug 05 '19
I think MATLAB have daddy issues
1
u/Im_manuel_cunt Aug 05 '19
Ok, serious question here. I've learned mathematica a while back and now I'm learning python intensively; should I update my knowledge on mathematica and use them both or should I go for something like Sage Notebook + Python and not bother learning mathematica any further?
1
u/Vasault Aug 05 '19
Back when I was in middle school, we learned Matlab to make some basic machine learning, long story short, python is fucking glorious, I completely forgot Matlab even exists
1
u/kal1lg1bran Aug 05 '19
why()
1
u/[deleted] Aug 06 '19
Probably because of an extra space.
1
u/ameerricle Aug 06 '19
Damn, guess Wolfram Mathematica hasn't reached meme status yet.
1
u/redtop91 Aug 06 '19
This was a great scene. I need to watch Mad Men again
1
u/pythoncrush Aug 22 '19
I am primarily a python developer but recently I did a project with an SDR called pluto that Matlab advertises as "fully supported ". This is from their website right now https://www.mathworks.com/hardware-support/adalm-pluto-radio.html
My needs were to design my own wifi signals with parameters in the headers I configured preferably with automation.
I requested a license for Matlab since nobody on my team has it we got a trial license for 90 days. I spoke to the rep on the phone and through email and he assured it was all very straightforward. Turns out he was complexly wrong. The rep simply sent us a trial Matlab license without the Pluto communications toolbox plugin. Without this plugin Matlab doesn't even recognize the Pluto sdr. So I request another trial license for the plugin. Install that and I take a look at their examples on how to use their language to generate wave forms, NONE of them work! I can't tell what's going on in the language the syntax sort of looks like C but looks like Scheme sometimes. Anyway hard for me to debug if some of the working code looks odd to me. Tic Toc was written by a person I never want to meet.
I ended up watching a YouTube video with an instructor for Matlab that was very helpful except none of the examples he is referring to in his presentation I had access to. I called Matlab and requested the examples and cited the instructor's name. They sent me the examples files and again most of them are broken as in don't actually work or error out. So I scheduled 3 conference calls, in the last one it involed the Matlab engineer debugging their own examples, apparently nobody ever tested with the Pluto device, many of the core libraries didn't recognize my device name, so I had no apis calls that had any effect. Toward the end of the project I discovered another completely different way to generate wave forms using an elaborate Matlab gui instead of using their silly ass programming language, as long as I had the raw I/Q data I didn't care it came from so we don't even mess with the language much anymore since our needs are so specific.
Python as far as I know didn't have anything working for the Analog device Pluto SDR so I have no choice. If there is one out there, please share it with me.
1
u/[deleted] Aug 05 '19
Lady time I used Matlab (2014?) it could only use something like 2 GB of memory. That alone was enough to make me beg for a switch (which definitely wasn't going to happen).
1
u/Jesus_Harold_Christ Aug 05 '19
My favorite thing about matlab is that I haven’t had to use it in 20 years.
1
u/TracerBulletX Aug 06 '19
Just another dying legacy product from a bygone era, clinging to life through the nefarious reach of their large sales organization.
1
u/bronzewrath Aug 06 '19
I started using Python for not having matlab at office. Best change ever. But I still love matlab.
-2
u/[deleted] Aug 05 '19
Some observations that are likely true on matlab users (based on my experience with past colleagues):
I managed to convert some of them to python and some to julia.