Between MATLAB, C#, and Python (Why MATLAB stands for Matrix Laboratory)


Matlab is the first programming language that I learned. I started learning MATLAB three years ago, when I was in my fourth year of my undergraduate studies. Because of its versatility, I used it for every programming related problem that I’ve been dealing with, either it was just for a simple calculation, or for complex GUI based application, or even for hardware control. I was very fond of it and fortunately became quite good in using it.

However, starting in the last two month, my project forced me to use, hence learn other programming languages, C# and Python. I have to use C# for my image processing work, while I use Python to create plugins for X-Plane. Since the projects are tight on deadline, I have no choice but to learn those languages in a maybe-not-perfectly-right-but-what-the-hell-as-long-as-the-job’s-done kinda way. So, now, I kinda get some grasps of those two languages. However, I have to admit that when I learn and write some code on those two languages, I can’t help but complain because of several things in those two other languages because I compared them to MATLAB. So, from that complains, I’m writing this post to tell you why now I love MATLAB even more after I learn C# and Python. My opinion about those two maybe wrong because of my insufficient time for learning those languages. Nevertheless, I just want to express my opinion regarding those two languages compared to MATLAB.

So, here goes…

MATLAB_C#_Python

For the sake of fairness, I admit that both C# and Python has their own advantages over MATLAB. First of all, they are low level (or at least lower than MATLAB, as I knew it) language, thus are more easier to be compiled into executables or some dll. They are also be able to access and control some system-related resource relatively easier compared to MATLAB. Especially for Python, I really like how you can write code using any text editor (as long as you name it with .py) and doubleclick on file explorer to run/debug the code. In my case, I’m using notepad++ to write my python code. On the other hand, writing C# is somewhat quite confusing for me because of a lot of stuff that exist in the IDE (I uses Visual Studio for my C# IDE). I don’t know about other IDE, though.

Confuesed Man

On the other side, while both MATLAB, C#, and Python are both be able to do OOP, C# forces the programmer to code everything in object-oriented style (Python also but it is more flexible than C#, I think). While I know OOP is very useful when it comes to complex programming, it is quite hard for a beginner to learn or understand. Consequently, some people are using the format (such as #include, void main, const, etc) without knowing the purpose behind me. At least that’s what happened to me when I was learning Python and C#. After some time then, I finally get the idea of what is that syntax is really for.

I also think that debugging in both C# and Python is a little bit harder because they don’t have any feature to show the variables values. I have to print out everything when I want to check if I made a mistake. This also makes data visualization in C# and Python harder. Thus, this makes me think that writing simple code for a simple calculation/simulation in C# and Python does not worth all the pain.

However, those things that I mentioned above is the main reason why I love MATLAB even more. The main reason is (drumroll) matrix/array operation.

Matrix Operation

In MATLAB, matrix operation is somewhat very convenient and simple. For example, you can just type A+3 to add all elements of matrix A by three, or type A*B to do matrix multiplication between matrix A and B, or type A.*B to do element-wise multiplication between Matrix A and B, or so many other syntax such as logical indexing, and so on. To tell you the truth, I never appreciate this feature very much and just continue using it without any care about it. But all changes when I switch to C# and Python (and maybe in other programming languages). I don’t know if I’m learning C# and Python the wrong way or I lack knowledge about these languages but I can’t seem to find any library in C# and Python for matrix operation or stuff like that. Consequently, I ended up using for loop just to add a constant to a matrix (and also other matrix operation stuff).

When I was using Python, I ended up does not use a lot of matrix multiplication, so this matrix operation thingy is not a problem, but when I was using C#, this became a very big problem. The first is that my code became way too long because of the for loop that I use every time I want to do any matrix operation. I was also worried that I made one tiny mistake in one for loop and then I ended up spending a lot of time to debug it. Thus, to avoid that, I ended up making a simple function library for all matrix operations and logical indexing. Although the code will still be long, at least it will save me some trouble from checking all those loops one by one.

So, when I was writing the function library for all those matrix operations, suddenly all clarity clearance came into my mind. Yeah, in MATLAB, this stuff is a lot simpler and easier. Matrix operation can be done easily as if it is a scalar. I also does not need to write all this ‘boring’ function about matrix operations and other stuff related to matrix. Suddenly, it became clear to me, why MATLAB stands for MATrix LABoratory. I know from the beginning that MATLAB stands for MATrix LABoratory instead of MATh LABoratory like a lot of people was thought. But, it is not until recently that I found out why.

Unfortunately, now, I still have to continue doing something unfinished using C#, so I have no other way but to stick with this misery:D. However, I’m still glad that I was learning MATLAB first. Although it made me kinda weak when it comes to OOP stuff, I have a deep understanding of the programming flow control. Thus, although this post is not intended to promote MATLAB or demote C# and Python (Truthfully, I have no connection or whatsoever to MATLAB other than a loyal user:D), I’m gonna close this post with a quote to make me look cool (:D). Here it goes…

“Learning MATLAB first is like driving auto transmission car first. Once you are good at it, you don’t want to change to manual.”

Regards,

0X_R

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s