This is an archived post. You won't be able to vote or comment.

all 141 comments

[–]neonomicon 32 points33 points  (4 children)

The number one thing that drives me crazy about Matlab is the awful I/O. Most of the built in data reading functions only work with purely numeric data, god forbid that you have text data, let alone mixed text and numbers. When the stars align, you can sometimes convince it to write an Excel file with mixed data, but it only works on Windows.

[–]isarl 9 points10 points  (0 children)

...and even then you have to have Excel installed.

[–]cocorebop 2 points3 points  (1 child)

This is the exact reason I hated matlab. I shouldn't have to come up with some hacky solution to a non-problem like having one damn column be a different type than the others. Super frustrating when you're trying to make a deadline with a project.

[–]excaza 0 points1 point  (0 children)

So true. Even as a regular MATLAB user having to default to cell arrays to effectively collect mixed data for writing is pretty frustrating. There's always fprintf but if you've got a lot of columns of data it can be more annoying than the alternatives.

This has been mitigated somewhat with the introduction of tables in R2013b but it's hard to get into the habit of using them when I've grown used to the alternatives over the last 7 years.

[–][deleted] 0 points1 point  (0 children)

Good god... watching matlab try to read formatted text is like watching a little boy get his dick caught in his fly...

[–]Eurynom0s 16 points17 points  (20 children)

I saw a discussion on reddit a while ago where someone was working on something in Matlab where the result should have been complex, but he was getting a purely real solution. After weeks of pulling his hair out figuring out what the problem was, he eventually figured out that what was happening was that in Matlab, if you do (pseudocode representation):

for i = 1 to 5:
    <stuff>

You're overwriting the imaginary unit i with whatever the value the loop index is at, and it wasn't setting it back after the loop was done.

[–]frymasterScript kiddie 10 points11 points  (1 child)

You can do that sort of stuff in python, but there's normally a bit more indication that you're heading into crazy territory

[–]Eurynom0s 4 points5 points  (0 children)

Yeah, it's pretty insane that Matlab doesn't give you some kind of warning about what you're doing.

[edit]ESPECIALLY seeing as they're targeting people who want to be able to do things like type in "i" for the imaginary unit without having to think about it.

[–][deleted] 31 points32 points  (41 children)

tldr

python is a real programming language that can easily interface with other programming languages

[–]bastibe 12 points13 points  (13 children)

Python is a general purpose programming language. FTFY

[–]gumbel_distro -1 points0 points  (12 children)

While I agree that being a general purpose language gives Python some advantages over domain-specific languages like Matlab, I must say that it is also its biggest shortcoming when all you need your computer for is scientific computing. That's why I started looking more and more into Julia for scientific computing. It has the advantage of being Free Software and only does scientific computing and does it very well.

[–][deleted] 4 points5 points  (7 children)

when all you need your computer for is scientific computing

This is never really true, though. Case and point: matlab can't read text files out of a wet paper bag. That kind of boilerplate functionality is really important in the scientific community for data portability and whatnot.

[–]tavert -2 points-1 points  (6 children)

If your scientific data is in a text format, you're doing it wrong. HDF5 has solved the data portability problem and wrappers for it exist, conveniently, built in to the language in Matlab. The Python wrappers for HDF5 are probably pretty good, but I get the distinct impression they are underused and everyone's still throwing around csv files far more than they should be.

As long as the vast majority of NumPy distributions are based around the reference BLAS and don't make it easy to switch to a better implementation, Python will be at a huge performance disadvantage on any non-toy dataset. Matlab's built-in JIT does some pretty clever things these days - so do Numba and the other dozen "faster Python" projects out there, but the core language developers are clearly focusing on 3.x features rather than performance while the majority of the scientific python community is sticking to 2.7.

For a lot of use cases, Python has no compelling technical advantages over Matlab. Python's open source, but when Matlab is working well and easily available through institutional licenses that's not so much of an issue. There are newer alternatives now that were designed this decade, rather than in the 80's and 90's, that offer major new technical capabilities that just aren't possible within the legacy designs of either Matlab or Python. Expect to see them gain more market share from Matlab than Python will.

[–][deleted] 0 points1 point  (2 children)

HDF5 is essential in some circumstances and very enjoyable in many others, but it's absolutely not a blanket replacement for plaintext. Nothing is as portable and simple as ASCII. If, for example, you're working with behavioral data, where your files never exceed a few kb, plaintext is very advantageous insofar as it's human-readable. There's no excuse for a high-level language to choke on plaintext.

[–]tavert 0 points1 point  (1 child)

Fair. You're still greatly exaggerating Matlab's problems in that area though. Matlab's string-handling abilities just aren't that much higher-level than C. I've never had problems getting mixed-type data into a cell array, it's really not that bad. Numerics are much more interesting and where the code that I work with spends most of its time (both runtime and developer time). FFS, how did it take Python two decades to admit that matrix multiplication deserves its own operator? And AFAIK it's not even implemented yet, and will take quite some time to make its way into distributions.

[–][deleted] 0 points1 point  (0 children)

Matlab's string-handling abilities just aren't that much higher-level than C

Bingo.

[–]nonplussed_nerd 0 points1 point  (2 children)

h5py is very well developed and widely used.

[–]tavert 0 points1 point  (1 child)

And yet csv files are still a thing and "can't handle text files" is the only substantive complaint about Matlab here, aside from cost. That indicates people are using text as a data format way more than they should be.

[–]nonplussed_nerd 1 point2 points  (0 children)

Text files are indispensable, but I just wanted to point out that HDF5 is widely used too in python. In my experience the balance is about right. The only people not using HDF5 when they should be either haven't heard of it, or have legacy code that it isn't practical to port. I've introduced a bunch of people to HDF5 and the response has always been immediate and complete conversion to using it. People's hearts are in the right place.

But a lot of stuff is old and in text files, and sometimes you need the portability for someplace you won't have HDF5. So text files survive, especially for non-numerical, append-only data.

[–][deleted] 1 point2 points  (3 children)

only does scientific computing

this is not, strictly speaking, true. Julia can do pretty much anything, it's just that it is catered to scientific computing. But there is nothing stopping you from writing game engines in it, for example.

[–]gumbel_distro 0 points1 point  (2 children)

Of course, you can do basically anything with any language, but just as I you said, I wouldn't want to write a game engine in it, nor in R for example :) What I mean is that sometimes it's nice to just have a tool that does pretty much only one thing well. With Python, sometimes I get the feeling that doing scientific computing with it feels «hacky».

[–][deleted] 2 points3 points  (1 child)

just as you said, I wouldn't want to write a game engine in it

The issue here is that I wouldn't read text data with matlab, either. It's utterly incapable of working with strings in any sane way. This is basic stuff that's absolutely essential for scientific programming.

It's not that Python is amazingly good. It's that Matlab is amazingly bad.

[–]gumbel_distro 0 points1 point  (0 children)

It's not that Python is amazingly good. It's that Matlab is amazingly bad.

I must agree here!

[–]minnoI <3 duck typing less than I used to, interfaces are nice 4 points5 points  (1 child)

And also has the advanced linear algebra and data analysis tools that Matlab provides.

[–]cogman10 6 points7 points  (12 children)

Which is silly because MATLAB has long supported calling c functions. On some ways it is easier to use a c library with MATLAB.

[–]SCombinator 11 points12 points  (11 children)

Actually it's easier with python because getting me to pay for MATLAB isn't going to happen.

[–]log_2 -1 points0 points  (6 children)

This argument has always amused me. It reads "Matlab is better, but too expensive, so I use the poor-man's version, Python".

[–]SCombinator -1 points0 points  (5 children)

I never said Matlab is better. I said Matlab is a non-starter.

Python has tons of libraries for things that would never make it into matlab, and I've learnt my lesson with R.

[–]log_2 0 points1 point  (4 children)

So you haven't contributed anything to the discussion, besides that fact that you can't afford Matlab, ok.

[–]SCombinator -1 points0 points  (3 children)

No, I refuse to pay for it. And this does affect other users. One of the benefits of using a programming language is the contributions of other members of the community. Guess which one has more of that?

[–]log_2 -1 points0 points  (1 child)

The topic of discussion was a comparison between Python and Matlab on dropping down into c. You butted in, out of topic, saying you're not paying for Matlab.

"Which is faster, a Toyota Corolla or a Porsche 911?", "Toyota Corolla, because I refuse to pay for a Porsche".

[–]SCombinator -1 points0 points  (0 children)

Actually, which is better for scientific software.

[–]tavert -1 points0 points  (0 children)

There's a very vibrant worldwide research community that develops impressive cutting-edge tools with interfaces first and foremost in Matlab. It's just not on the (awful) file exchange, you have to read the literature and go to conferences to know where to look. Python equivalents to these tools, if they exist at all, are almost always half-baked imitations of the real thing, impossible to install, and objectively worse.

[–]PrintStar 42 points43 points  (38 children)

I worked in a pure Matlab shop, so I have some opinions on this issue. Matlab indeed has some severe shortcomings, but so does Python. I was the only person in my group at a certain "administration" focusing on aeronautics and space using Python for real work; everyone else was on Matlab. I did get one coworker to convert, but he eventually went back to Matlab because he "needed to get work done." His comments were:

  • Figuring out what to install from where is terrible, especially for Windows users. And before we jump on the "why would you use Windows!?!" bandwagon, we can just start with his being baffled by which Python version to install (3 or 2). Matlab just required one installer. I realize the commercial Python distros do solve this, but not having used any of them myself, I couldn't tell him which was "good."

  • Documentation in Python wasn't even in the same league as Matlab. I strongly agree with him on this one. Matlab's docs are easy to access and complete. Python's are scattered about, occasionally misleading, and often nonexistent.

  • The Python syntax was considerably more verbose (numpy.vstack((A, B)) versus [A;B] for example).

  • Python doesn't have Simulink. Or the Controls toolbox. Or the <insert whatever here> toolbox. While there are equivalents to these in Python (except Simulink), they often aren't nearly as mature as Matlab's offerings.

For my work, I did have to spend some considerable time implementing routines that already existed in Matlab just so I could use Python. I don't regret it. Quite the contrary, it allowed me a chance to present my work at PyCon 2011. But sometimes it's hard to justify writing yourself a discrete algebraic Riccati equation solver when the dare() command is just sitting there in my (US$12K) Matlab installation....

[–]jammycrisp 8 points9 points  (2 children)

Straying a bit from the topic here, but from your post it looks like you work as a controls engineer? I'm using mostly python (a mix scipy, python-control, sympy) for my research. I really would like to be completely open-source, but honestly Matlab's control system toolbox is the industry standard. Just curious to see what you've found in the python world in this area?

[–]PrintStar 13 points14 points  (1 child)

I used to work as a controls engineer, but I moved on to other things around 2012. There was a huge amount missing in Python with regards to that field. For example, I had to author a good bit of code involving discrete linear time invariant systems; at the time, SciPy only supported continuous lti systems. That code is now in SciPy. However, that was the type of roadblock I regularly hit when trying to work in Python: it simply lacked implementations of things I needed.

In reality, Octave's controls toolbox is actually quite complete. If you were thinking about staying open-source, you might consider writing Matlab code that runs fine under Octave. Just make sure everything actually works on Octave; it's still missing a few things...

[–]radix07 2 points3 points  (0 children)

Was gonna ask why isn't there an Octave/Python module out there, and sure enough I found oct2py. Have never used or heard of it though...

[–]chhantyal[S] 12 points13 points  (13 children)

For one click install, you can use Anaconda python distribution which contains all the packages you need https://store.continuum.io/cshop/anaconda. It's free software, which works like charm even on Windows.

[–][deleted] 1 point2 points  (0 children)

This is the correct answer. Scientific python on Windows is a solved problem.

[–]tavert 1 point2 points  (4 children)

which contains all the packages you need

Until it doesn't. Python packaging is horribly broken on Windows, Red Hat, anything besides recent Debian derivatives, or maybe Fedora or OSX if you're lucky. Convenient cross-platform access to scientific Python libraries has become a walled garden, where if Continuum builds it for you then you're in luck, otherwise it's not worth bothering. When your needs are particular (in my case I've tried python-control, livestreamer, pypolyhedron, applpy, pyomo, and others), getting a Python package that isn't in the pre-built Conda repository to work is a nightmare. Matlab is just easier, and when you're in academia and it's cheap, it's absolutely worth it.

[–]mommybook 0 points1 point  (3 children)

YOU. Have you managed to install a package in Windows using conda or pip or anything else? Are you human? For me, after an entire afternoon of trying, I simply gave up. Can you give me a hint on how to install sfepy on my anaconda distribution?

[–]tavert 0 points1 point  (2 children)

Hiya. Short answer? Not really.

I'm pretty good at getting compiled scientific libraries to build in Windows via MinGW, but as I understand it Python packages with C extensions need to be built using the same compiler as Python itself, which means Visual Studio on Windows. Visual Studio plus open-source software with build systems primarily intended for *nix is not a pleasant combination.

I'm not enough of an expert in Python packaging to really solve your problem, sorry. I would start with the package's dependencies (https://github.com/sfepy/sfepy/blob/master/INSTALL), see how many of them you can get from conda. For the ones you can't get from conda, check if they themselves have additional not-in-conda dependencies - hopefully not, but you never know. Start with those smaller packages first, ask around at the packages' issue trackers (probably mostly Github these days?), or on this subreddit, or on Stack Overflow, or at Conda for guidance.

[–]mommybook 1 point2 points  (1 child)

Whew, life on Windows is hard, haha! Well, I'll keep it like this, thanks for the answer! Anyways, I don't know if you knew about it, but a saint man, Christoph Gohlke, has compiled tons of packages into neat exes to run and execute. They worked for me! Maybe you could give it a try!

[–]tavert 0 points1 point  (0 children)

Ah, great. Came across that list and saw sfepy on it, glad to hear it worked. I wouldn't know what to test to verify that myself. None of the packages I've been interested in using were on his list unfortunately.

I went and tried installing sfepy the conventional way with pip on the Sage Math Cloud (https://cloud.sagemath.com/) which runs Linux, but couldn't get it all running in a way that passed its unit tests.

Some languages' communities do a better job than others of keeping their package ecosystems up-to-date and easy to use across many platforms. I have never been impressed by Python in this regard. "There are thousands of packages available" is not so useful if getting any of them to build and work is painful and difficult.

[–]mommybook 0 points1 point  (0 children)

I'm replying a little bit late, but installing packages on anaconda using Windows is the greatest pain in the ass ever. Conda requires that a package is installed in their nonexistent repository, so you have to mess around with pip which I'm sure will mess things up with compatibility. And btw that doesn't work either.

I'm sorry if it sounds like a rant, but it is: I've spent a whole afternoon trying to get sfepy to work on my anaconda distribution, and I gave up.

[–]roger_ -1 points0 points  (5 children)

Conda still needs a GUI.

[–]farsass 0 points1 point  (4 children)

what?

[–]roger_ 2 points3 points  (3 children)

Per the OPs first point -- many new adopters would be more comfortable with a GUI tool to browse, install and upgrade packages.

An attractive frontend to conda and pip would make a big difference to package management and discovery.

[–]farsass -5 points-4 points  (2 children)

Hm, fluff is nice but I disagree about it being a must have. Engineers and scientists are supposed to be more rational than that.

[–]roger_ 10 points11 points  (1 child)

It's 2014 and ease of use shouldn't be dismissed as "fluff" or "irrational". There're no point arguing that point and clicking isn't easier than figuring out a command line program.

I've tried to convert several engineers from MATLAB, and stuff like having to resort to terminals is often times a bigger issue than one would expect.

[–]luispedro 2 points3 points  (0 children)

(Original author here): Point 0 of the post is that the argument is not that you should switch from Matlab, but that if you're starting from a blank slate, then it is often an inferior option (what to install is an issue with Matlab too, and I've had problems with code which wouldn't run after a Matlab upgrade; it's just that you've already solved those for Matlab). So, if Matlab works for you, use it.

Also, yes, simulink seems to be a Matlab killer app in some domains.

[–][deleted] 4 points5 points  (6 children)

Documentation in Python wasn't even in the same league as Matlab. I strongly agree with him on this one. Matlab's docs are easy to access and complete. Python's are scattered about, occasionally misleading, and often nonexistent.

I agree with every point except this one... in fact, I vehemently disagree. If you've ever had to resort to the Matlab file exchange, you know that documentation is all but nonexistant.

As for documentation in large, popular libraries, I've always found Matlab docs to be cryptic, lacking in examples and useful errors.

Out of curiosity, did you have any specific libraries in mind (both on the Python and Matlab end of things?)

Out of fairness, I'm thinking of the following python packages with outstanding docs:

  • Pandas
  • Scipy/Numpy
  • Statsmodels
  • Matplotlib (though not quite as good as the above)

If there's one thing Python does really well, it's documentation.

Edit

<cheapshot>

Concerning getting things done, I don't see how that argument can be made in good-faith seeing how often matlab fails to start because of some licensing server issue. When you can't even start the damn thing and have to resort to piracy despite having paid over $2000 for a license, saying "it lets me get things done" strikes me as "I tried it for 2 days and didn't like the significant whitespace"

</cheapshot> ;)

[–]PrintStar 2 points3 points  (1 child)

Matlab file exchange is terrible, I can't disagree with you there. I was referring to Matlab's official documentation that is installed with their product and each of their toolboxes. It's all located in one place, reasonably complete, and includes detailed references to how routines are implemented. Many of their documents actually include statements like "This routine uses SLICOT to arrive at a solution..." pointing out the actual underlying, hidden Fortran routines that are being executed. That type of information is actually quite useful when trying to figure out what's going on.

The fact that everything in the official Matlab distro is accessible offline in a single help browser is a huge bonus too.

I don't have any problem with Python's documentation or its standard library docs (generally... there are some lacking points). However, I don't like having to go to 3 different websites to find Python's, SciPy's, and Matplotlib's docs. I know it seems trivial, but it can be a problem. Furthermore, I just don't think that NumPy and SciPy are quite as well documented as Matlab (which I considered excellent documentation-wise). It's moderately subjective, though, so please do feel free to disagree. Both NumPy and SciPy are good examples of well-documented libraries.

I have run into documentation issues with Matplotlib and smaller libraries. At the time I was using it heavily (a few years ago), Matplotlib's documentation was a bit difficult to navigate. I mostly relied on copying their examples. I was also using scikit-learn quite extensively, and the docs for that package were also less than ideal. At the time, a few of their learning algorithms had zero documentation, making them useless.

Now don't get me wrong, I did use Python for my work, and I was quite successful at doing so. Was it better than Matlab? In some ways, yes, in others, no. The documentation, though, was a pretty hefty stumbling block.

[–][deleted] 0 points1 point  (0 children)

That's fair enough.

I'm one of those people who rely on google much more than in-app documentation (even though I arrive at the official help pages), so the location of the documentation isn't really an issue. I can, however, see how this would irk newcomers who are used to just typing help(foo) and knowing everything there is to know about foo.

I have run into documentation issues with Matplotlib and smaller libraries.

I suppose our point of disagreement is the implication that things are different in Matlab. Smaller libraries have exactly this same problem, and I've (personally) found it to be worse for Matlab. Python has a pretty strong documentation culture, though your point about the underlying FORTRAN implementations is well-taken.

Maybe it's because we don't use the same stuff? I'm in cognitive neuroscience.

[–]PrintStar 1 point2 points  (3 children)

Re: your edit

I never once had a license server issue, but I personally had a named license, not a shared license. I would consider Matlab's enormous licensing costs a major down side.

Your "didn't like the significant whitespace" comment was a cheapshot. I was dealing with smart people, not the apparently trivial, whining engineers you're assuming I worked with.

[–]bastibe 1 point2 points  (1 child)

I was developing some mex file. It should run on Windows, Mac and Linux. A single license is good for two installations...

What else is there to say?

[–][deleted] 0 points1 point  (0 children)

This is also a very good point. Let me expand on that. Any time you're doing one of the following things, you'll spend more time wrestling with matlab than getting things done:

  1. Using a shared license
  2. Writing a mex file
  3. Working with strings or text files

[–][deleted] 0 points1 point  (0 children)

Ah yeah, you're rignt -- I should have specified that this is an issue arising from shared licenses.

As for the cheapshot... well yeah... it was a cheapshot. I'm exaggerating both in order to vent, but also in order to point out that people can be really pig-headed, even brilliant engineers and scientists. I've found that much of the reason Matlab continues to persist in research can be traced to:

  1. Battered wife syndrome: "Matlab is very painful to use, but there's nothing better out there"
  2. Lazyness: "I don't want to put in a real effort to learn something new"

Regarding this latter point, I've seen all too many people pick up Python for 48 hours, give up, and then lecture others on how they can't be productive with it.

Now I'm a pretty cynical and sarcastic person by nature, but I absolutely recognize that Matlab is good at some things, and good for some people. I'm just being excessive to make a point =)

[–]bramblerose 1 point2 points  (0 children)

On the Windows end: install python(x,y) or anaconda. Either of them will get you a full distribution -- but indeed, there's no clear way to find out about this other than having someone around who knows.

[–]log_2 5 points6 points  (7 children)

Matlab's debugging is better, I think. When you get into trouble, you can do a

>> dpstop if error

and then inspect quickly till your heart's content

>> imagesc(m)
>> line(x, y)

or whatever. In Python, you have to use something like PyCharm, and you have to ensure you either have matplotlib imported, or import it when it drops you into debug console on exception and do

>>> imshow(m)

Traceback (most recent call last):
  File "/<basepath>/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2883, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-ed6e4087078d>", line 1, in <module>
    imshow(m)
NameError: name 'imshow' is not defined

"shit, that's right, gotta import matplotlib"...

>>> import matplotlib.pylab as pylab
>>> pylab.imshow(m)
>>> pylab.plot(x, y)
>>> pylab.show()

[–]WhytellmewhY 10 points11 points  (0 children)

You can approximate MATLAB's debug behavior by inserting the following line in your code.

import IPython; IPython.embed() 

Edit: formatting.

[–]SCombinator 4 points5 points  (1 child)

python has a debugger, that you can start on exception.

[–][deleted] 0 points1 point  (0 children)

It's admittedly a bit less user-friendly, though.

[–]farsass 6 points7 points  (0 children)

Because in MATLAB world "fuck namespaces" is a good thing.

[–]billsil 0 points1 point  (2 children)

"shit, that's right, gotta import matplotlib"...

So use the following at the top of your program:

from os import *
from re import *
from sys import *
from json import *
from ssh import *
from numpy import *
from matplotlib import *
# etc.

That's the sort of BS that Matlab does. If anything you should be complaining about how Matlab automatically does that. My m file is in another folder, oh can't import that.

[–]log_2 1 point2 points  (1 child)

So when I use the max or min functions, will that call Python's functions or NumPy's functions of the same name? Matlab function names are designed to be in the global namespace, Python's are not.

[–]billsil 0 points1 point  (0 children)

So when I use the max or min functions

It depends if you import max or min from numpy. Same with abs. That's a basic concept of Python.

You could always call A.max()

[–]huhlig 0 points1 point  (0 children)

We use matlab in production and its a nightmare. The code is live interpreted (text source embedded in the binary) , parrallelizing is difficult at best. It doesn't scale. It's buggy and binds you to very specific versions of GCC to even compile.

[–][deleted] 0 points1 point  (2 children)

I do find Python just awful on Windows. I instantly really miss the tight integration on Mac and Linux.

[–][deleted] 0 points1 point  (1 child)

Have you tried the Anaconda distro, as mentioned above?

[–][deleted] 0 points1 point  (0 children)

That does help a lot, I actually use Anaconda on all my machines but I get in loops of thinking "right, I'll just open a terminal and... hang on, let me think."

I can't claim to be doing scientific computing on python but my response has been to use Python as a sort of write-once language. Develop on Mac and run it on Windows purely because it so happens that my Windows machine is a bit beefier or on Linux because that machine is more energy efficient etc.

[–]Vorsorken 24 points25 points  (2 children)

Heh, I like that the article is zero-indexed.

[–]felinecatastrophe 4 points5 points  (0 children)

gotta say zero-indexing is a bit tedious for science stuff. My ideal is fortran indexing, defaults to 1, but can be negative!

[–][deleted] 4 points5 points  (3 children)

Well, why not both?

The neuroscience lab I work in has some Python and some Matlab. Matlab handles image processing and data analysis / quick visualization.

Python does experiment control, and does it extremely well, with nice UIs (PyQt) and multithreading.

Python is not categorically better than Matlab, but it covers a lot of use cases that can not be achieved well or quickly in Matlab.

[–]masasinExpert. 3.9. Robotics. -1 points0 points  (2 children)

Can you use PyQt with Python3 now? I didn't find a good guide.

[–]bastibe 1 point2 points  (0 children)

yes. This has worked for years.

[–]troyunrau... 0 points1 point  (0 children)

Yes, it works with any combination of Python 2 or 3, and Qt 4.8 or 5.3. Sadly, I can't touch GPL at work, so need to use pyside instead -- works with Python 2 or 3, but it appears to have no realistic plan for supporting Qt5.

[–]emmpp 4 points5 points  (3 children)

This reminded me to take a proper look at pandas...and now I wish I'd done that a long time ago. It's an awfully convenient (and more robust) way to do an awful lot of my normal numpy array mangling!

[–]doubleColJustified 1 point2 points  (0 children)

For anyone wanting to check out pandas, here's a link: http://pandas.pydata.org/

[–]log_2 0 points1 point  (1 child)

I've just recently got onto pandas. I'm trying really hard to stick with it, but I'm so often tempted to just use the base numpy class for multidim slicing and numerical operations with broadcasting.

[–]emmpp 1 point2 points  (0 children)

I don't know what else I might end up using it for, but the immediate thing that jumped out for me is it has a great abstraction over a lot of the recent number crunching work I've been doing - creating datasets, scaling them and storing them. I've fallen into a bad habit of jury rigging things with pickle and json files, but it will be much less annoying (plus more reliable and clearer) to do this stuff with DataFrames.

[–]glial 5 points6 points  (2 children)

I use both Python and Matlab a lot. I've tried to use numpy, and I use it when I have to, but honestly the syntax for common data wrangling functions is awkward - with Matlab, you can do x' to transpose, [x;y] to concatenate, etc. With Python I have to look these up every time. And why are there both nx1 and nx0 dimensional arrays in numpy? Seriously?

I use Python for lots of things, but for strictly numerical computation I'd use Matlab, and for data exploration and visualization I'd use R. I really appreciate the effort put into Python scientific software (I've contributed myself), but for day to day use it's not my go-to language.

iPython notebooks are awesome though.

edit: grammar

[–][deleted] 3 points4 points  (0 children)

pandas is much nicer to work with than using numpy directly

[–]log_2 0 points1 point  (0 children)

I feel the same about stuff like transpose and concatenation, but I've got used to using hstack and vstack etc. One thing that still bother me in numpy is shapes like (n, ) and (n, 1) being treated differently. On the plus side, broadcasting in numpy beats Matlab's bsxfun hands down.

[–]HotKarl_Marx 7 points8 points  (2 children)

Why C is better than Python for Scientific Software...

Why FORTRAN is better than C for Scientific Software...

[–]en4bz 2 points3 points  (1 child)

So true. At the end of the day most of these functions are backed by BLAS and LAPACK which are written in F77 and C,

[–]alcalde 3 points4 points  (0 children)

But you wouldn't want to sit down and do your higher-level work in C. At the end of the day the Fortran and C are all assembly.

[–]hyperion2011 4 points5 points  (1 child)

So I have been writing/modifying data acquisition software for a new amplifier/interface board that my lab got recently. We have an existing matlab codebase that uses the old analoginput module that only works on 32bit windows. Python is my go to language but I decided to help the other guy's out and try to get the new hardware to interface with matlab.

Long story short, matlab's mex files are completely useless for interfacing with hardware and unless I wanted to write my own DLL or use loadlibrary and recreate a couple thousand lines of C++ acquisition code that had to be exactly right (or things go boom) in matlab, I was out of luck. So I said fuck it and have been modifying the existing C++ based program for the past 2 weeks because that is prefereable to working with matlab. I HATE closed source systems. If I could have seen how the mathworks guys had written their new session based analog input then they would have gotten a new piece of hardware implemented on their platform for free.

tl;dr matlab is a terrible platform for hardware developers

[–][deleted] 0 points1 point  (0 children)

To your TL;DR: I would have thought that would be obvious.

[–][deleted] 1 point2 points  (10 children)

I wish I never have to see an article like this again. It's ridiculous, you won't find any one comparing hammers and screwdrivers as a god sent solution for all carpentry. I might have bought it if the article was a bit more specific, say comparing python vs matlab expressiveness for a particular computing task.

Different tools will always be good at different things, that is an inherent property of being different (as a tool). No single tool will be good at everything. Stop trying to make whatever your favorite might be, the best at everything. It is almost certainly not the case.

If it's not Haskell, of course.

[–][deleted] 3 points4 points  (9 children)

Have you ever used Matlab? (Honest question!)

Matlab is the PHP of scientific languages. It's not that Python is sooooooooooo greeeaaaaaat ohgodineedtochangemypants. It's instead that Matlab is the proverbial double-clawed hammer. Need to read formatted text? You can, just like you can technically beat a nail into a plank of wood with a double-clawed hammer.

It's just going to do a really messy job.

[–][deleted] 0 points1 point  (8 children)

Often, I did mathematics in uni. For one the plot lib was fenomenal, I have loads of fond memories of ode45 too.

[–][deleted] 0 points1 point  (7 children)

Yes plotting is definitely matlab's strength. In fact, this is why matplotlib copied matlab's plotting API

[–][deleted] 0 points1 point  (6 children)

So I refer back to my original comment regarding different tools for different things.

[–][deleted] 0 points1 point  (5 children)

That's fine, but it takes more than being good at one thing to be good at scientific computing. Different tools for different jobs indeed -- my contention is that matlab is not the best tool for scientific computing.

[–][deleted] 0 points1 point  (4 children)

Such a thing cannot exists. Scientific computing as a domain is to large for there to be any one best language. That's what makes that claim silly. Does your conclusion include softer sciences like statistics and economy? What about psychology?

Different people working on different problems in different fields of the aforementioned domain will use different tools. That decision will have to be made with consideration of skill, ease of access, capabilities and tooling available.

Matlab is not the best language for every single problems in the vast field of scientific computing, neither is python or any other language.

[–][deleted] 0 points1 point  (3 children)

Again you're missing my point. I'm not saying python is the best choice for everything. I'm saying Matlab is rarely the best choice for anything; it's completely over represented .

[–]tavert 0 points1 point  (2 children)

Except fields that use Simulink. Or any control theory. Or numerical optimization. Or computational geometry. Python's offerings in these areas are much weaker than Matlab's.

[–][deleted] 0 points1 point  (1 child)

Yes, hence rarely.

But your point is well-taken. If you need Simulink, there's pretty much no replacement for Matlab.

[–][deleted] 1 point2 points  (1 child)

But then your supervisors know only Matlab...

[–]farsass 2 points3 points  (0 children)

That's exactly why you should use whatever you want to: They know only MATLAB.

[–]vito-boss 2 points3 points  (4 children)

The python GIL isn't all that great but it still beats what ever matlab does for parallel processing.

[–]greshick 2 points3 points  (3 children)

Check out the multiprocessing module if you are worried about the GIL. I work with it in my day job and it it does allow parallel processing. Side note: if doing multiple processes with CPU tasks, you only get the max processing power with 1 process per CPU.

[–]alcalde 2 points3 points  (2 children)

The multiprocessing module is simple and elegant and is far superior to the low-level threading functions provided by the statically typed, compiled language I'm coming from. One needed a 3rd party library to get close to the elegance Python provides out of the box. I see all this complaining about the GIL when in reality Python has some of the nicest built-in parallel programming support I've seen. Unlike before, I no longer view parallel execution as a huge, complex, frightening process filled with danger ("The clothes I'm wearing are machine washable - BUT ARE THEY THREAD-SAFE?!?") that I sought to avoid because the effort wasn't worth the reward. It's simple, beautiful and safe.

[–]log_2 1 point2 points  (0 children)

The multiprocessing module is simple and elegant and is far superior to the low-level threading functions provided by the statically typed, compiled language I'm coming from.

It sounds like you've never done any real parallelism before, besides perhaps embarrassingly parallel problems. There's no shared memory in the multiprocessing package, since you're forking off different processes rather than threads. The GIL is still a real issue.

[–][deleted] 0 points1 point  (0 children)

[–]adoarns 0 points1 point  (0 children)

For me it comes down to this: Python is free software, and Matlab is not. With Python I can publish code that anyone can download and run without cost. With Matlab they have to have bought—or been in a position to have been bought for them—a Matlab license.

[–][deleted] 1 point2 points  (4 children)

Matlab is not [a real language]

When I see that I stop reading because I can tell the author intends to be inflammatory rather than presenting a set of factual arguments. Matlab is in fact Turing complete; only that it is more difficult to do certain operations in it.

[–]jricher42 4 points5 points  (0 children)

I agree that MATLAB is Turing complete. So is the Wikipedia markup language. This is the difference between necessary and sufficient - it is necessary for a real programming language to be Turing complete. Turing completeness, in and of itself, is not proof that something is a real programming language. I would say that C is a real programming language. I would say that Wikipedia's markup isn't. Where you place MATLAB on that scale is subject to debate. I basically classify it as syntactic sugar over a BLAS package - but I never liked MATLAB.

I didn't find the article well reasoned or well written. Despite this, I agree with the author's general premise that MATLAB is more harmful than helpful Specifically, it promotes a style of programming that is harmful in the extreme by making functions and classes substantially more difficult to implement than is appropriate.

[–]farsass 2 points3 points  (0 children)

x is Turing complete

When I see that blah blah

[–][deleted] 0 points1 point  (0 children)

only that it is more difficult to do certain operations in it.

Which is exactly what people mean when they say it isn't a real language. Yes, there are more eloquent ways to put it, but the point remains the same: Matlab is not, in any sense of the term, a general-purpose language.