MECHANICAL ENGINEERS SHOULD LEARN PYTHON
originally posted on Quora in response to the question “Which programming language is most suitable for a mechanical engineer?”
So the other answers here, while good, I think gloss over some nuance.
In general, as Shreeyash Lalit alludes to, there are 4 main classes of computation that mechanical engineers are involved in. Computer Aided Design , Finite Element Analysis, Data Acquisition, and Numerical Analysis. You will do well to be competent with the relevant tool in your industry for each one of these, but know that their domain is deep and that people have made entire careers being experts on just one of them.
But let’s look at each a little closer
CAD/FEA
That said, your question asks about programming languages, and neither CAD nor FEA is a programming language. I mean, most of them offer API’s of some sort (accessible via either visual basic, python, or perhaps a home-grown scripting language), but you won’t be “programming” at least in the traditional sense.
Data Acquisition
When it comes to data acquisition, LabVIEW is really the only choice. Strictly speaking it is a programming language, but it’s domain is relatively niche and it is unlike all other programming languages in that programs are written graphically as opposed to in a text editor. In my experience, this value of this language has been inversely proportional to the size and complexity of a program, as well as my desire to reuse code.
Numerical Analysis
This is probably what your question was about all along and, in my opinion, it boils down to two options: MATLAB and Python. Do not bother learning FORTRAN until you need to (again, unless your industry demands otherwise… most don’t).
So… MATLAB v Python. If you want to be able to put something on your resume that will help you in getting a staff engineering position in a large company, put MATLAB. A large company is not (currently) going to have institutionalized python, but is likely to have done so with MATLAB. MATLAB also has great customer service, a bunch of free seminars, and their “toolboxes” of extra functionality (which you pretty much need to do anything cool), while expensive, are pretty comprehensive.
All that said, I would still go with Python Why?
There are more resources for learning it
It’s free
Between NumPy and SciPy it has virtually everything MATLAB’s core package has
Speed has, in my experience,been very comparable.
There are many python modules available (for free) that have just as good, if not better, functionality than MATLAB
There is a world of people, inside and outside of academia, using Python.
If you’re interested in Robotics, many really compelling robotics tools (which are virtually all written in C++ or C) have python bindings (ROS,OROCOS,OpenCV).
MATLAB is currently trying to provide compatibility to some of those robotics tools, meaning they are lagging behind python in that sense (it’s tough for a company to keep up with the masses)
Many MOOC’s use python as a programming language of choice, again making it easier to learn.
It’s a general purpose programming language. Much of what you learn could be used to build a web application, or almost anything.
Embedded Linux platforms like the BeagleBoard and Raspberry Pi ship with Python, so you can control them right out of the gate in that language… try doing that with MATLAB and it will get expensive.
So I pick Python, and you should as well.