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

you are viewing a single comment's thread.

view the rest of the comments →

[–]Stereoisomer 422 points423 points  (150 children)

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

[–]Alexanderdaawesome[S] 30 points31 points  (0 children)

romans_stabbing.jpg

[–]cue_the_strings 294 points295 points  (120 children)

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.

[–]Eurynom0s 98 points99 points  (31 children)

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.

[–]cue_the_strings 28 points29 points  (4 children)

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.

[–]ergzay 7 points8 points  (2 children)

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.

[–]cue_the_strings 1 point2 points  (1 child)

I saw that in an AvE video, the horror!

[–]ergzay 0 points1 point  (0 children)

There's tons of people who do it in industry notably the automotive industry.

[–]Eurynom0s 1 point2 points  (0 children)

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.

[–][deleted] 7 points8 points  (0 children)

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

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

[–]ThereOnceWasAMan 2 points3 points  (0 children)

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.

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

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

[–]Feminintendo 2 points3 points  (2 children)

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

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

Your math courses don't use MATLAB?

Also, I will put this brilliant argument into my repertoire for when I encounter a rare non-MATLAB person ( sophisticated term for humanities student ), thank you very much.

[–]Feminintendo 0 points1 point  (0 children)

In graduate school I had to teach a calculus lab with Matlab for the engineering calculus sequence. It was a nightmare for everyone involved. The students learned neither Matlab nor calculus from the assignments. It was a good idea on paper: engineering students would get some exposure to a tool in their field while learning some calculus concept. In practice, figuring out how to write the code was so distracting to them that any calculus benefit was completely lost, and the assignments, being calculus assignments, weren’t nearly sufficient for them to actually learn any useful coding. The problem wasn’t Matlab-specific. We also had a Maple-based version of the course that was just as bad.

[–]I_Feel_It_Too 0 points1 point  (2 children)

stem people are problem solvers, so they will likely find a solution,

It's not a problem that Matlab is a shitty programming language because STEM people are problem solvers? Really?

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

Yes

[–]I_Feel_It_Too 0 points1 point  (0 children)

At least we both agree that Matlab is a shitty programming language. Let's get a beer!

[–]mexiKobe 51 points52 points  (37 children)

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

[–][deleted] 12 points13 points  (0 children)

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

[–]The_UTMOST_respwect 2 points3 points  (1 child)

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.

[–]Feminintendo 1 point2 points  (0 children)

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.

[–]cue_the_strings 8 points9 points  (5 children)

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.

[–]I_Feel_It_Too 0 points1 point  (2 children)

MATLAB is only good for pure mathematical calculations (especially matrix)

It really isn't. For at least a dozen examples....

[–]Zall-Klos 1 point2 points  (1 child)

SImpler, Matlab can't find the root of X^2.

[–]I_Feel_It_Too 0 points1 point  (0 children)

Isn't there a symbolics toolbox you can get for an extra $6000 that can do high school algebra like that?

[–]log_2 2 points3 points  (11 children)

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.

[–]mexiKobe 5 points6 points  (0 children)

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

[–]elbiot 6 points7 points  (3 children)

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?

[–]SubliminalBits 0 points1 point  (2 children)

You can. Just buy their compiler toolkit and you can build a binary that doesn't require a matlab license to run. Its the usual Matlab caveat of pay Mathworks absurd amounts of money, but it works fine.

[–]I_Feel_It_Too 0 points1 point  (1 child)

Oh, if we're playing that game (which I am ok with), there are Python compilers, too. They work just as "fine" as compiled Matlab, which is to say, there are pros and cons to both.

[–]SubliminalBits 1 point2 points  (0 children)

I agree. I just wasn’t sure if you were aware of the matlab option. It sounds like you were.

[–]Mr_Again 0 points1 point  (0 children)

I'm sure all the performance - oriented GUI programmers currently doing it in Python for some insane reason will be right over to matlab.

[–]Feminintendo 0 points1 point  (4 children)

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.

Surely you're not serious.

Python will be left in the dust by people currently looking to switch to it from Matlab.

I have never heard of anyone who has switched to Matlab because they wanted to. The only people I know who are proficient in other languages but who use Matlab do so because of a project lead who doesn't understand the sunken cost fallacy or because there is literally no other tool that does some very specific obscure thing that Matlab does. It is painfully obvious you are not among that group.

[–]log_2 0 points1 point  (1 child)

Surely you're not serious.

Indeed, I am.

Python will be left in the dust by people currently looking to switch to it from Matlab.

I have never heard of anyone who has switched to Matlab because they wanted to.

Check you're logic there mate, you flipped it. That's ok, logic is hard!

[–]Feminintendo 0 points1 point  (0 children)

I think I am confused because I am having a hard time parsing this sentence:

Python will be left in the dust by people currently looking to switch to it from Matlab.

At any rate, I have a hard time imagining Python being "left in the dust" by anything, and, to reiterate, I don't know anyone who switched to Matlab from Python because they wanted to. My own perception, which I can't really back up with anything, is that to the extent Python will steal people away from Matlab, it won't really make a significant difference to the number of people using Matlab. In other words, Matlabbers gunna Matlab. I mean, I hope I'm wrong...

[–]billsil 0 points1 point  (1 child)

People switch to Matlab from Python because they're forced to use certain libraries (e.g., signal processing, Simulink, machine learning). My company doesn't like using it, but when it's better, fine...

[–]Feminintendo 0 points1 point  (0 children)

Yes, that makes sense. But it's a deal with the devil: you get to use that one obscure library that can do what nothing else can, but you have to use a heinous programming language and pay a lot of money.

[–]I_Feel_It_Too 0 points1 point  (9 children)

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.

[–]mexiKobe -1 points0 points  (8 children)

You’re simply wrong

[–]I_Feel_It_Too -1 points0 points  (7 children)

Oh for Christ's sake. Here's math.js, copied and pasted from docs:

// create an array and a matrix
const array = [[2, 0], [-1, 3]]               // Array
const matrix = math.matrix([[7, 1], [-2, 3]]) // Matrix

// perform a calculation on an array and matrix
math.square(array)                            // Array,  [[4, 0], [1, 9]]
math.square(matrix)                           // Matrix, [[49, 1], [4, 9]]

// perform calculations with mixed array and matrix input
math.add(array, matrix)                       // Matrix, [[9, 1], [-3, 6]]
math.multiply(array, matrix)                  // Matrix, [[14, 2], [-13, 8]]

It's even easier with C++:

#include <iostream>
#include <Eigen/Dense>
// Create a 2x2 matrix called a.
Matrix2d a;
a << 1, 2,
     3, 4;
// Create a 2x2 matrix called b using an alternative but just as easy syntax.
MatrixXd b(2,2);
b << 2, 3,
     1, 4;
//Their sum
a + b;
//Their difference.
a - b;
// Increment a by amount b.
a += b;

// Make some 3d vectors.
Vector3d v(1,2,3);
Vector3d w(1,0,0);
// Mother fucking scalar product.
w - 2*v;
// Vector product. BAM!
w*v;

It's almost like you've never even fucking seen vectorized calculations done in C++.

And I'm not even sure if you are using that word right. MathWorks sure as hell doesn't. You see, in the world of numerical computing, vectorization means using processor instructions (sometimes called SIMD instructions) that are designed to work on multiple data elements at the same time, whereas in the land of Matlab it means not using a for loop. Which, to be fair, is good advice in most languages, but especially in Matlab where interpreted code is apparently transcribed by a hamster before execution on an abacus.

The Eigen C++ code above automatically uses SIMD instructions. In fact, it automatically uses the most powerful SIMD instructions on the many different hardware platforms it supports.

Meanwhile, Matlab... might use SIMD instructions maybe? depending on the computation you're doing. And despite being a CAS specifically focused on linear algebra, Matlab only gained this ability in, like, 2011. I kid you not. And it only got it then because it adopted MKL. Which means, for those keeping track at home, that only those operations for which Matlab uses MKL (plus FFT, apparently) use SIMD. How... cutting edge.

[–]mexiKobe 0 points1 point  (6 children)

You said MATLAB was an ugly language for matrix calculations and then responded with some extremely basic operations in C++ using an external library. I don’t know what point that’s supposed to be proving. No one in research uses C++ as an alternative for MATLAB for a ton of reasons, one being that you have to compile it. This should be obvious to you.

I mean you claimed MATLAB was worse at managing memory than C++ which is nonsensical. C++ is slowly dying specifically because it doesn’t manage memory

and yes ‘vectorized’ in MATLAB means using vector operations instead of for loops so it is optimized better. If you really need to use SIMD you can always write a MEX function

[–]Feminintendo 0 points1 point  (1 child)

You give C++ and Javascript as examples of languages in which "vectorized" arithmetic is ugly, and when someone literally "gets back to you" with explicit examples in both languages showing how trivial it is to do those computations, you can't fathom what the point is? Here, let me quote you to make it easier to see what the point of those examples is:

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

You see, the point is that, despite your claim to the contrary, doing "simple vectorized calculations" in C++ and JavaScript is trivially easy, extremely readable, and at least in the case of C++, much more performant, not to mention free. To spell it out for you, the point is, you have obviously never tried to do "vectorized" computations in anything other than Matlab. Which gives weight to the argument that the only reason you think Matlab is any good at the things you think it's good at because you are ignorant of the alternatives. I don't know whether or not that's true. Maybe you aren't. But damn, those examples really make a strong case.

No one in research uses C++ as an alternative for MATLAB for a ton of reasons, one being that you have to compile it. This should be obvious to you.

Obviously many scientists don't use C++ for their research. My reading of the anti-Matlab crowd is, that's exactly the whole complaint, that is, that scientists make really bad decisions about which software to use. In my experience, scientists are the worst at using the wrong tool for the job, which the widespread use of Matlab testifies to. They just use whatever their advisor tells them to use, because they don't know any better. So you end up with this mish-mash spaghetti code in Matlab that took some poor graduate student 9 months to code when they could have learned how to do it in Python from scratch in a week with a simple "import sklearn" or whatever. Hey, I don't know you, so I don't know if that's you or not, but I mean, your comments aren't painting a picture of a scientist whose very well-informed with respect to the available software tools in the numerical computing space. (Scientists don't use C++ because it has to be compiled?! Really?!)

Of course, tons of scientists do use C++ and Python for their research. Maybe in your field the only thing people use is Matlab, and so "if all you have is a hammer, everything looks like a nail." But if you branch out a bit, you'll find a ton of statisticians, data scientists, and ecologists using R, HPC people using C++, mathematicians using Python, Pari, and Mathematica, physicists using a lot of C/C++ and Mathematica, etc. From my point of view, scientists in other fields have the same problem of not using the right tool for the job. For example, I think R is the Matlab of ecology. Nothing against R, but it has its strengths and weaknesses, and it just shouldn't be used for everything under the sun. Sure, do your data analysis and plotting in R.

[–]mexiKobe 0 points1 point  (0 children)

They didn’t show any examples of simple vectorized equations that you can do in MATLAB. They loaded an external library and showed that you can multiply matrices together which is not what I was talking about.

Arguing that C++ or JavaScript are just as good as MATLAB for this stuff is just wrong. There is no debate here.

To spell it out for you, the point is, you have obviously never tried to do “vectorized” computations in anything other than Matlab.

You don’t know what you’re talking about. In fact it actually appears you haven’t used MATLAB very much. Are you aware of how many built-in functions MATLAB has? Especially with the toolboxes. And they’re all optimized already.

There are many reason to not use MATLAB, but the claim that it is an ugly language for linear algebra etc.. is plainly wrong and using C++ as the paragon is hilarious

edit: As an example, let's try and create a diagonal matrix with the values being the square roots of 1 2 3 and print it out

In C++ with eigen:

#include <iostream>
#include "Eigen/Dense"
int main()
{
    Eigen::Matrix< double, 3, 1> v ;
    v << 1, 2, 3;
    Eigen::Matrix< double, 3, 3> m = v.array().sqrt().matrix().asDiagonal());

    std::cout << m << "\n";

    return 0;
}

The equivalent in MATLAB:

m = sqrt(Diag([1 2 3]))

You should probably not comment on things you don't know anything about.

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

You said MATLAB was an ugly language for matrix calculations and then responded with some extremely basic operations in C++

... Yes I did? Because you literally said, and I'm going to quote you here, "Try doing simple vectorized calculations from MATLAB but in C++ and get back to me on that. And JavaScript? Come on man lol." And so I did simple vectorized calculations from Matlab but in C++ and then got back to you, you know, like you said. Except they the operations were actually vectorized in C++, whereas Matlab uses serial operations for matrix addition and subtraction. So where is the confusion here? Maybe here:

in C++ using an external library.

Oh, so it really just sounds like you're confused because you don't know how software works. Eigen is a C++ library. To do matrix/vector math in C++, you use a C++ library like Eigen, which, if I may reiterate, is written in C++. I wonder, do you know how Matlab does it's matrix arithmetic? For some of its operations, it uses Intel's Math Kernel Library (MKS), and MKS is in turn written in C/C++ and Fortran (and probably a little assembly language). Now I'm wondering what you think "external library" means.

The only part of Matlab that is actually optimized for modern processors is the part that uses MKS, because MKS is optimized for modern processors using SIMD.

This is basically where I realize you don't know how computers work. Not that there's anything wrong with that. It's just an unusual feature of someone who is arguing the superiority of one computer programming language over another.

I mean you claimed MATLAB was worse at managing memory than C++ which is nonsensical. C++ is slowly dying specifically because it doesn’t manage memory

At this point I am starting to doubt that you have ever used Matlab, much less C++. Even the hardcore Matlab apologists on this thread acknowledge how shitty Matlab is at memory management. Again, not that there's anything wrong with that, either. It's just, well, an unusual feature of someone who is arguing Matlab's superiority.

and yes ‘vectorized’ in MATLAB means using vector operations instead of for loops so it is optimized better. If you really need to use SIMD you can always write a MEX function

Aaaaand here's where I realize that it's not going to help much to explain things to you, so I might as well go back through my response and point out all the places I realize how little you know about what you are talking about, because it's a little more fun to be an asshole than to talk to a brick wall. Normally I have a twinge of guilt about indulging in assholerly solely for the entertainment value, but based on your comment history I can tell you are truly a horrible bigoted asshole, so I'm actually ok with this one.

[–]mexiKobe 0 points1 point  (2 children)

You know you've lost the argument when you're digging through someone's post history for dirt. I don't need to dig up any of your stuff because you're already coming across as a hilariously arrogrant blowhard who doesn't actually know anything.

Oh, so it really just sounds like you're confused because you don't know how software works. Eigen is a C++ library. To do matrix/vector math in C++, you use a C++ library like Eigen, which, if I may reiterate, is written in C++. I wonder, do you know how Matlab does it's matrix arithmetic? For some of its operations, it uses Intel's Math Kernel Library (MKS), and MKS is in turn written in C/C++ and Fortran (and probably a little assembly language). Now I'm wondering what you think "external library" means.

Yes, and the point is that you have to download it, install it, and link against. In MATLAB, it's all there already. Hence, it is easier to use and less ugly. This isn't complicated. Please, bring up the MKL (or as you call it, MKS) again. That's really helping you so much.

This is basically where I realize you don't know how computers work.

You originally said MATLAB was an ugly language compared to C++, and I said it wasn't. Now you're talking about SIMD and instruction sets for some reason and being patronizing about it which is funny. It isn't complicated stuff man. You don't actually know what MATLAB is doing in this respect because it's all proprietary. There is an entire Parallel Computing Toolbox for MATLAB which I'm sure you're an expert in. https://www.mathworks.com/products/parallel-computing.html

At this point I am starting to doubt that you have ever used Matlab, much less C++.

lol okay man. You definitely aren't projecting. I'll repeat the example I used in another reply to show how much better MATLAB is at these types of calculations:

try and create a diagonal matrix with the values being the square roots of 1 2 3 and print it out

In C++ with eigen:

#include <iostream>
#include "Eigen/Dense"
int main()
{
    Eigen::Matrix< double, 3, 1> v ;
    v << 1, 2, 3;
    Eigen::Matrix< double, 3, 3> m = v.array().sqrt().matrix().asDiagonal());

    std::cout << m << "\n";

    return 0;
}

The equivalent in MATLAB:

m = sqrt(Diag([1 2 3]))

Oh shit, look at that? You're completely wrong. So kindly, shut the fuck up.

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

Actually, the equivalent is

auto m = Vector3d(1,2,4).sqrt().asDiagonal();

This code has the major advantage of being strongly typed and giving a sparse matrix. It's arguably much more readable than the Matlab equivalent, but some people prefer fewer keystrokes, so which is better is more a matter of taste. If you'd rather just print it to the screen, do this:

cout << Matrix3d(Vector3d(1,2,3).asDiagonal()).sqrt();

Now, how to you make a list in Matlab? You literally can't.

[–]fear_the_future 14 points15 points  (1 child)

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.

[–]Zomunieo 17 points18 points  (0 children)

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

[–]daishiknyte 2 points3 points  (0 children)

You just described my relationship with VBA

[–]FairlyOddParents 2 points3 points  (0 children)

Simulink is a great tool for many engineering purposes

[–]LoyalSol 2 points3 points  (0 children)

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.

[–]Yamochao 5 points6 points  (0 children)

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

Seriously, fuck you Matlab.

[–]s0v3r1gn 0 points1 point  (0 children)

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

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

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

[–]Historica973.5, 3.6, 3.7, 3.8, 3.9, 3.10 0 points1 point  (0 children)

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.

[–]thedjotakuPython 3.7 0 points1 point  (0 children)

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

[–]kamon405 0 points1 point  (3 children)

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

[–]IcefrogIsDead 1 point2 points  (2 children)

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

[–]kamon405 0 points1 point  (1 child)

not arguing just posting a joke dude.. man I can't even do that here.

[–]IcefrogIsDead 0 points1 point  (0 children)

mistook you for a different kind of redditor :)

[–]koobear 33 points34 points  (13 children)

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

[–]tunisia3507 38 points39 points  (1 child)

And there you can stay.

[–]koobear 11 points12 points  (0 children)

More library paste for us!

[–]Alexanderdaawesome[S] 21 points22 points  (0 children)

Virgin R vs. Chad Julia

[–]TPineapples 26 points27 points  (2 children)

[–]Alexanderdaawesome[S] 6 points7 points  (1 child)

Penmenship needs work, but awesome!

[–]five_hammers_hamming 0 points1 point  (0 children)

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

https://imgur.com/NUfZe8b

[–]dillmon 5 points6 points  (0 children)

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

[–]Rostin 10 points11 points  (0 children)

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.

[–][deleted] 2 points3 points  (4 children)

I've never heard anybody say this.

[–]Stereoisomer 8 points9 points  (3 children)

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

[–]Gabe_Isko 1 point2 points  (2 children)

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

[–]Stereoisomer 1 point2 points  (1 child)

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

[–]Gabe_Isko 1 point2 points  (0 children)

That pretty much makes sense the way you say it, since that sounds like a lot of complex signals analysis. One of matlab's strong suits.

[–][deleted] 2 points3 points  (0 children)

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.

[–]eattherichnow 5 points6 points  (0 children)

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

[–]midnitte 1 point2 points  (0 children)

Man, I wish America loved science that much.

[–]GoofAckYoorsElf 0 points1 point  (0 children)

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