r/Python • • Aug 05 '19

Python's response to MATLAB

Post image
4.3k Upvotes

372 comments sorted by

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

31

u/Alexanderdaawesome Aug 05 '19

romans_stabbing.jpg

33

u/koobear Aug 05 '19

Meanwhile, us R users are sitting in a corner somewhere by ourselves.

23

u/Alexanderdaawesome Aug 05 '19

Virgin R vs. Chad Julia

41

u/tunisia3507 Aug 05 '19

And there you can stay.

14

u/koobear Aug 05 '19

More library paste for us!

0

u/[deleted] Aug 05 '19

[deleted]

17

u/[deleted] Aug 06 '19

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.

5

u/brews import os; while True: os.fork() Aug 06 '19

To be fair, I rather write shit in R than in MATLAB.

Like, does MATLAB even have proper unit testing and CI?

2

u/SigmaStigma Aug 06 '19

Is that who wrote R inferno?

→ More replies (3)

2

u/Deto Aug 06 '19

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

1

u/brews import os; while True: os.fork() Aug 06 '19

Go get yourself a copy of "The art of R programming" if you actually need to do proper programming in R.

27

u/TPineapples Aug 06 '19

7

u/Alexanderdaawesome Aug 06 '19

Penmenship needs work, but awesome!

1

u/five_hammers_hamming Nov 15 '19

Three months late, and the other guy did it better, but here you go:

https://imgur.com/NUfZe8b

297

u/cue_the_strings Aug 05 '19

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.

97

u/Eurynom0s Aug 05 '19

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.

30

u/cue_the_strings Aug 05 '19

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.

8

u/ergzay Aug 06 '19

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.

→ More replies (2)

2

u/Eurynom0s Aug 06 '19

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.

9

u/[deleted] Aug 05 '19

... but i, j, k are default indicies for so many functions.

That's just downright evil, I don't care who ya are.

3

u/ThereOnceWasAMan Aug 06 '19

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.

4

u/[deleted] Aug 05 '19

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

3

u/Feminintendo Aug 06 '19

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."

→ More replies (2)
→ More replies (3)
→ More replies (15)

54

u/mexiKobe Aug 05 '19 edited Aug 05 '19

The language is ugly

Not at all for numerical calculations / matrix math etc. It’s very good for that, better than Python with numpy. Look at these comparisons https://docs.scipy.org/doc/numpy-1.15.0/user/numpy-for-matlab-users.html

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

15

u/[deleted] Aug 05 '19

.mat files, .mat files everywhere, and not a database to be had.

3

u/The_UTMOST_respwect Aug 06 '19

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.

2

u/Feminintendo Aug 06 '19

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.

7

u/cue_the_strings Aug 05 '19 edited Aug 05 '19

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.

→ More replies (5)

4

u/log_2 Aug 06 '19

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.

6

u/mexiKobe Aug 06 '19

wait what? I was talking about MATLAB. Python is infinitely more portable

7

u/elbiot Aug 06 '19

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?

→ More replies (3)
→ More replies (6)

1

u/I_Feel_It_Too Aug 06 '19

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.

→ More replies (9)
→ More replies (6)

14

u/fear_the_future Aug 05 '19

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.

17

u/Zomunieo Aug 05 '19

(Lisp (would (like (a (word))))).

3

u/daishiknyte Aug 06 '19

You just described my relationship with VBA

3

u/FairlyOddParents Aug 06 '19

Simulink is a great tool for many engineering purposes

4

u/LoyalSol Aug 05 '19

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.

6

u/Yamochao Aug 05 '19

Not to mention slow, resource heavy, indexing from one (wtf) and crashing ALL THE FUCKING TIME.

Seriously, fuck you Matlab.

1

u/s0v3r1gn Aug 06 '19

I’d actually pay for a MATLAB python library. Not as much as they want for MATLAB, but still, I’d be interested.

1

u/[deleted] Aug 06 '19

Python and Haskell are the same age, both started late 1980's and both had their first specification in 1990.

1

u/Historica97 3.5, 3.6, 3.7, 3.8, 3.9, 3.10 Aug 06 '19

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.

1

u/thedjotaku Python 3.7 Aug 06 '19

It was great for some matrix work in undergrad. Then again, it was free for us then. hehehe

1

u/kamon405 Aug 06 '19

lol C++, Python, and Java are modern languages?

2

u/IcefrogIsDead Aug 06 '19

they are some of the most used ones, therefore yea - modern languages. you can always argue anything, but why would you

→ More replies (2)

0

u/[deleted] Aug 05 '19

[deleted]

152

u/kaihatsusha Aug 05 '19

Per seat. Per year maintenance.

87

u/[deleted] Aug 05 '19

I ditched them at an HPC center when they wanted to charge per core on a supercomputer.

Nonsense. @Matlab, your business model is broken.

152

u/Stereoisomer Aug 05 '19 edited Aug 06 '19

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

42

u/[deleted] Aug 06 '19

Good!

15

u/seismic_swarm Aug 06 '19

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.

18

u/Ferentzfever Aug 05 '19

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).

13

u/acousticpants Homicidal Loganberry Connoisseur Aug 06 '19

that's an Oracle level move right there. next financial year they'd be changing to charge you per CPU cycle. guaranteed.

→ More replies (2)
→ More replies (1)

22

u/UristMcDoesmath Aug 05 '19

Octave is FOSS and does everything I need it to do.

4

u/Raiptwice Aug 06 '19

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?

→ More replies (4)

3

u/YarmoM Aug 06 '19

People tend to forget this important detail...! Get stuff done

2

u/[deleted] Aug 06 '19

End of story

0

u/[deleted] Aug 05 '19

[deleted]

17

u/cue_the_strings Aug 05 '19

I had it in my head that Haskell was from the 80s for some reason.

26

u/bakmano Aug 05 '19

Perhaps you've confused Haskell with Pascal.

24

u/[deleted] Aug 05 '19

The rascal!

(sorry)

15

u/LoyalSol Aug 05 '19 edited Aug 05 '19

It's ok, it's a BASIC mistake.

(Ok I'm going to go hide after that one)

→ More replies (6)

3

u/cue_the_strings Aug 05 '19

Nah, I just thought it was older than it is. I'm only superficially familiar with it, learned a bit of it so I could modify Pandoc of all things.

→ More replies (1)
→ More replies (1)

1

u/fmthoma Aug 06 '19

Ahem. Actually, Haskell is older than Python (although not by much).

→ More replies (2)

6

u/dillmon Aug 06 '19

Matlab is ubiquitous for engineers because every engineer undergraduate program uses it to teach coding.

11

u/Rostin Aug 05 '19

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.

3

u/[deleted] Aug 05 '19

I've never heard anybody say this.

8

u/Stereoisomer Aug 05 '19

Oh you sweet summer child.

Matlab is still the dominant language in a lot of fields like mines (neuroscience). It’s fighting an uphill battle trying to convince them to switch

2

u/Gabe_Isko Aug 06 '19

Its dominant in neuroscience? All the neuroscience research I hear about is fone in python... what do you think the breakdown is?

2

u/Stereoisomer Aug 06 '19 edited Aug 06 '19

Probably 60/30/10 Matlab/Python/R

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

→ More replies (1)

3

u/[deleted] Aug 05 '19

In my experience, a programmer saying they actually like MATLAB immediately attracts every python dev in a five mile radius

It just feels like that because there are so many python developers.

5

u/eattherichnow Aug 05 '19

...wow, so many Python folk eager to help you prove this hypothesis.

FWIW I find it a bit hard to justify using Matlab/Octave/Scilab in 2019, but that might be my drifting away from real programming universities.

2

u/midnitte Aug 05 '19

Man, I wish America loved science that much.

1

u/GoofAckYoorsElf Aug 06 '19

Can confirm. Am Python developer and kinda also like Matlab. Sort of. Depending on the use case

125

u/[deleted] Aug 05 '19

Why would matlab feel bad for python?

405

u/Alexanderdaawesome Aug 05 '19

Because Python needs to type

import numpy as np

Before doing anything MATLAB can do.

6

u/Oxyriser Aug 05 '19

*for free

2

u/Alexanderdaawesome Aug 05 '19

ya but those extra chars make a carpal tunnel

17

u/stoirtap Aug 05 '19

Hi, Engineering newb here.

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.

Does Python have something like that?

30

u/sssmmt Aug 05 '19

Install Pycharm (pro version is free if you're a student) and activate Scientific Mode.

https://www.jetbrains.com/help/pycharm/matplotlib-tutorial.html

16

u/Alexanderdaawesome Aug 05 '19

Can verify, I do ALL of my function prototyping in Pycharm for its (and jetbrains in gerneral) debugging features.

77

u/djingrain Aug 05 '19

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

8

u/GuybrushThreepwo0d Aug 05 '19

You are not locked into an IDE with matlab. I use vim as my editor and run scripts from the command line.

9

u/ThwompThwomp Aug 05 '19

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.

→ More replies (2)

48

u/tikael Aug 05 '19

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.

3

u/SerHiroProtaganist Aug 05 '19

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

7

u/Zizizizz Aug 05 '19

Open up a Jupyter notebook

→ More replies (1)

4

u/FewerPunishment Aug 05 '19

Check out pycharm

→ More replies (2)

11

u/Linkguy137 Aug 05 '19

I mean I use Spyder and it is in there

7

u/Blazerboy65 Aug 05 '19

In Python you'll usually get that kind of functionality using a debugger or a client like Spyder.

6

u/gmclapp Aug 05 '19

Basically any IDE besides IDLE

3

u/[deleted] Aug 05 '19

Hm, pretty sure the python IDE spyder has this function. If I recall correctly, pycharm does too.

3

u/Salyangoz Aug 06 '19

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.

2

u/Meorge Aug 05 '19

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.

2

u/lillystoolooo Aug 05 '19

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.

1

u/FlukyS Aug 05 '19

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.

→ More replies (2)

4

u/krazybug Aug 05 '19

And Matlab is so HEAVY !

https://xkcd.com/353/

→ More replies (40)

20

u/FlagrantPickle Aug 05 '19

Because the monetization angle hasn't been worked out in over 25 years.

→ More replies (1)

0

u/[deleted] Aug 05 '19

[deleted]

13

u/[deleted] Aug 05 '19

Hi Matlab sales! How's your day going?

3

u/PlusImagination Aug 06 '19

Companies pay for Matlab because the algorithms are verified as being what they say they are and supported by a staff of full time PhDs

Which algorithms are you talking about?

Post a question on stack exchange for python and maybe you'll get some advice, maybe it's relevant, and maybe it's right.

What questions are you talking about?

Not trying to poke at you, genuinely curious why some institution continue with Matlab.

→ More replies (6)

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

6

u/Alexanderdaawesome Aug 05 '19 edited Aug 05 '19

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.

2

u/Antouziast Aug 05 '19

Thank you for this comment, really useful!

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!

3

u/Alexanderdaawesome Aug 05 '19

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!).

→ More replies (1)

1

u/I_Feel_It_Too Aug 06 '19

Matlab has better 3d plotting than python

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.

1

u/Alexanderdaawesome Aug 06 '19

I rarely use it, so lack of experience?

→ More replies (1)

27

u/absolutelynoartist Aug 05 '19

Try Spyder via anaconda

11

u/[deleted] Aug 05 '19

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.

3

u/Antouziast Aug 05 '19

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!)

2

u/[deleted] Aug 05 '19

That's the only use I've found for it - education or explaining code. However I assume based in its popularity people use it for more than that.

→ More replies (2)

1

u/ashesall Aug 06 '19

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.

→ More replies (1)

10

u/[deleted] Aug 05 '19

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.

1

u/ChemistBuzzLightyear Aug 06 '19

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. :/

1

u/Antouziast Aug 05 '19

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!

1

u/[deleted] Aug 05 '19

Second everything here.

My transition from Matlab was greatly enhanced by Enthought Canopy. I don't use it anymore, but at the time it was wonderful.

9

u/tunisia3507 Aug 05 '19

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 pyenv
curl https://pyenv.run | bash

# restart your shell however you like

# install whichever versions of python you like
BEST_PYTHON=3.7.4
pyenv install $BEST_PYTHON

Then whenever you start a new project

# create the virtual environment
pyenv virtualenv $BEST_PYTHON myproject

# automatically activate that environment whenever you're in this directory
pyenv local myproject

# install some dependencies
pip install ipython numpy matplotlib

# save them so you can rebuild the environment easily
pip 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.

3

u/Antouziast Aug 05 '19

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.

4

u/PeugeotWaterface Aug 06 '19 edited Aug 06 '19

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:

  1. Anaconda (or miniconda) with conda environments to control your packages

  2. cookie cutter to create organized project directories

  3. 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.

2

u/Antouziast Aug 06 '19

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.

Is debugging easy when using this setup?

2

u/PeugeotWaterface Aug 06 '19

For me, debugging with spyder is identical to how I did it with Matlab.

→ More replies (3)

1

u/TheBlackCat13 Aug 06 '19

You want to use the jupyter notebook, then. It to designed for this sort of interactive date exploration and plotting.

4

u/I_Feel_It_Too Aug 06 '19

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.)

1

u/Antouziast Aug 06 '19

Hi! Yes it can read csv and other ASCII files actually. There's a menu called "Import data" that helps you do it and generate a script to automate it.

Thanks for the advice, based on yours and other answers I'll give Spyder another go!

2

u/I_Feel_It_Too Aug 06 '19

Must be new. Haven't used it in ~5 years.

→ More replies (3)

3

u/el_beso_negro Aug 06 '19

Anaconda + the conda cheatsheet + Sublime.

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.

2

u/Antouziast Aug 06 '19

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

2

u/el_beso_negro Aug 06 '19

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.

3

u/Astrokiwi Aug 06 '19

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.

5

u/ad_abstract Aug 05 '19

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!

3

u/Antouziast Aug 05 '19

Cool! Didn't know that existed, definitely can prove useful!

3

u/ad_abstract Aug 05 '19

Seriously. It’s just as simple as going to colab.new to start a new session/document. From there it’s just an online overpowered jupyter notebook.

2

u/rhoakla Aug 06 '19

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.

2

u/_MuchUsername_ Aug 30 '19

Here is a good article about how to set up your python environment along with some best practices for ensuring code quality https://sourcery.ai/blog/python-best-practices/

3

u/ml_runway Aug 05 '19

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.

1

u/robotwhisperer Aug 06 '19

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.

1

u/Antouziast Aug 06 '19

Is a virtual machine worth it?

1

u/robotwhisperer Aug 06 '19

I have my laptop setup to dual boot, not too familiar with Virtual Machines but I've never had a problem with my setup.

1

u/robberviet Aug 06 '19

Use Anaconda, you won't have to do anything. Most people who does not programming started with this.

1

u/TheBlackCat13 Aug 06 '19

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.

0

u/[deleted] Aug 05 '19

[deleted]

2

u/Alexanderdaawesome Aug 05 '19

Dude, everyone has been awesome about these type of questions, even to that newb above. No one is actually shitting on MATLAB.

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?

78

u/Deezl-Vegas Aug 06 '19

> spending hundreds of thousands of dollars

There you go buddy, write the email

18

u/pxan Aug 06 '19

bUt ThE dEvElOpErS aRE CoMfoRTaBLe wITh MaTLaB

22

u/aaronr_90 Aug 06 '19

*engineers. The devs use c and python

→ More replies (1)

16

u/I_Feel_It_Too Aug 06 '19

Force the person making the decision to read Abandon Matlab.

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.

6

u/Alexanderdaawesome Aug 05 '19

Found the MATLAB employee ;)

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?

5

u/okkshin Aug 05 '19

It's their product after all, other than that it's like comparing python to Rust for the benefit of either.

Yes, I am in fact part of MathWork's RedditPaidTrollFactory. Oh no wait, that must be Oracle's.

2

u/Gabe_Isko Aug 06 '19

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.

3

u/tjl73 SymPy Aug 06 '19

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.

2

u/TheBlackCat13 Aug 06 '19

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.

→ More replies (2)
→ More replies (3)
→ More replies (2)

2

u/TheBlackCat13 Aug 06 '19

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.

1

u/okkshin Aug 06 '19

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.

2

u/TheBlackCat13 Aug 06 '19

MATLAB OOP is a nightmare. A complete and utter nightmare. I just have no other way to describe it.

1

u/I_Feel_It_Too Aug 06 '19

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...

This was written for you. In particular:

<snip>

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.

2

u/okkshin Aug 06 '19

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.

→ More replies (2)
→ More replies (3)

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.

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?

3

u/Zizizizz Aug 05 '19

Really nice if you use the offline plots in my opinion but I don't like that online ones are published

1

u/PeugeotWaterface Aug 06 '19

I believe with 4.0 online plots are no longer automatically public. May want to double check but I'm fairly sure.

1

u/Zizizizz Aug 06 '19

Oh that's great news I'll check it out

1

u/Gabe_Isko Aug 06 '19

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.

1

u/Gabe_Isko Aug 06 '19

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.

1

u/throwawaydyingalone Aug 06 '19

Is it bad to want to learn both?

4

u/Alexanderdaawesome Aug 06 '19

is it bad to learn

bruh

1

u/throwawaydyingalone Aug 06 '19

Not saying it’s ever bad to learn in general but would employers look down on intermediate in both vs advanced in one?

1

u/Alexanderdaawesome Aug 06 '19

Depends on the employer. If you are going into software MATLAB is basically useless. Engineering in other forms not so much

1

u/throwawaydyingalone Aug 07 '19

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.

1

u/Alexanderdaawesome Aug 07 '19

23 and me, as well as myriad genetics use python if that helps you make your decision.

→ More replies (2)

4

u/ASCIASCI Aug 05 '19

Just wait until someone asks you to do something in LabVIEW

1

u/jammin-john Aug 27 '19

I have actively avoided doing anything in LabVIEW, even if it means I have to install new drivers and wrote Python code from the ground up lol

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.

3

u/tjl73 SymPy Aug 06 '19

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).

1

u/TheBlackCat13 Aug 06 '19

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.

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?

2

u/I_Feel_It_Too Aug 07 '19

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.)

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/[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):

  1. they do not think of using hash tables (or binary trees)

  2. they do not think of dynamic arrays

  3. they do not think of using regular expressions

  4. they do not think of providing service over a network (TCP/IP)

I managed to convert some of them to python and some to julia.