Programming language for engineers

In summary: Fortran, use lambdas to make async tasks more readable in Python, and so on.In summary, a beginner should start with Python or C/C++.
  • #1
Im starting my bachelor degree in mechatronics engineering this semester, i have very little knowledge in programming and so want to start learning a language. Ideally a language that would give me the upperhand for employment or one that is most relevant to engineering.( maybe they all are i don't know)

I have done a little bit of research into which languages are requrired in job advertisments some which pop-up include MATLAB, Labview, simulink, Solidworks, PLC, scada, dephi, c, c++, and others.

Basically which programming language is most suited for a beginner to learn that will be useful to the course I am doing?

Help is greatly appreciated.
Physics news on
  • #2
In order:
  • #3
I would say in this order:
  • #4
I'd say learn Python or C/C++. Once you've got that down, picking up Matlab, Verilog/VHDL, etc. later on will be easy.

Starting out learning Matlab before you've taken any classes is not going to be very fun. You can do a lot more educational and 'fun' things with Python or C. Most Matlab books are going to offer dry examples that will be over your head. Not to mention you'll have to either pay or pirate (not recommending this!) Matlab software, while C and Python compilers can be had for free!
  • #5
I would recommend C++, with it you'll be able to easily understand MATLAB as well as C (for embedded programming). Then you can teach yourself assembler (perhaps for an AVR microcontroller) and you'll be good. Alternatively you could consider consider C# or Java (yuck).C# is kind of cool, I haven't had much time to do anything with it, but it looks very good.
  • #6
Note that whereas it is true that Matlab can be used to as a programming language it can also be used as a sophisticated calculator, and that is how most people use Matlab at first.

Most Matlab programs are just very simple scripts and unless you are doing something fairly sophisticated there is no need to use things like if-blocks, while loops etc. At most you might use a For loop to assign values to a matrix and a few functions. Hence, you do not really need to know how to "program" in the usual sense of the word in order to write useful Matlab scripts.
In fact, in the "old days" before version 6 it was best to avoid all loops and control statements since they made the programs VERY slow (in more recent version is JIT compiler is used so now it is ok to use loops).
This still affects the way most Matlab programs are written.

My point is that writing Matlab scripts is VERY different from writing programs in e.g. C.
Pythin (with Scipy) is the only programming language that I have ever used that reminded me of Matlab (which is sort of the point with Scipy).

Hence, knowing Matlab is -in my view- more a "math-related" skill than a "programming-related" skill. It is very useful if you are e.g. modelling physical systems etc; but there is no point in learning Matlab if you are planning to e.g. design hardware; then you are better off learning VHDL etc.
  • #7
He just started his engineering degree this semester - learning VHDL is going to be basically impossible. I would never recommend that for someone as their first language (f95toli - I realize you didn't recommend he learn VHDL first, I'm just saying this so he doesn't go off and try to do it).

I agree with what you said about Matlab, I think he's better off just picking that up during his courses.

Go with Python or C/C++ for your first language. It's not always a great idea to start off with C/C++, but since you're only going to be tinkering to get some background in programming I don't think it will hurt.
  • #8
This is going to be a little tldr; but I have some strong opinions about this.

The correct guidance depends on what you want to get out of learning to program. If you want to have the bare minimum of understanding for practical programming as an engineer, then you could probably learn a little C++, maybe some Fortran and Matlab, and leave it at that. However, this would be a great disservice to you!

If you want a real understanding of programming from a deep perspective, I would recommend you learn 1 language from each of these categories:
Procedural (eg: Fortran)
Object Oriented (eg: Java/C++/Python)
Functional (eg: Scheme/Lisp)
Declarative: (eg: Prolog/Regular expressions)
Math/Array-based: (eg: Matlab)
Assembly (Choose some embedded cpu in an interesting application and learn how to program it)

Java is a good place to start because it is pretty newbie-friendly and you can make little games and such without as much hassle. Python might also be a good place to start.

In each of these cases, try to use the language's strengths to solve your programming problems - use array operations instead of loops in Matlab, use recursion rather than looping in Scheme, use object-oriented structures in C++, and so forth. This is basically what the first few CS-for-CS-majors classes will do at top universities. Now This is a big task, but if you do it then you will have a great depth and understanding of programming in general. Even though you may never use a functional programming language again, just knowing it will make you a better programmer in whatever other language you use. You will be able to pick up the fundamentals of any other language in a weekend or so.

Ok just a note because you mentioned it: Solidworks is not a programming language, it is a CAD program. You use it to draft 3D models of mechanical parts and assemblies, similar to how you would build a model in 3d animation programs (Maya, Max, Lightwave, Silo, Blender, Rhino, etc), except it is aimed at engineering applications. The main difference is that models are precisely specified parametrically, and in return there is less low-level mesh control. It's all point-and-click, there is no programming involved.

If, by the initial post, you want to learn a CAD program, Solidworks is a great starting point. I would recommend not doing AutoCAD. A lot of people just use AutoCAD because it has big name-recognition, but it is a fundamentally 2D program. They started with 2D many decades ago and tacked on 3D aspects as computers became powerful enough to handle it. If you start with AutoCAD you will develop a lot of bad habits. SolidEdge and Inventor are pretty good alternatives to SolidWorks. Modern parametric modeling programs are all very similar so if you know 1 you know them all.
  • #9
Thanks for the helpful input!

Looking at the course outline more closely it shows that the first computer-related course I am taking involves Matlab.

These are the books they recommend for it:
Highly Recommended

Palm W.J., Introduction to Matlab 7 for engineers 2ed, 84.50


Chapra S, Applied Numerical Methods with Matlab for Engineers &, 121.46

I guess i have to take MATLAB as my first language, i was thinking of learning c++ first(until found out that I am using matlab) do you guys think that I should self-teach c++ while doing MATLAB at uni in the same time? or is that too much and will it get confusing? or should i just stick with matlab?
  • #10
Matlab is kind of an unusual language to start with, but it might work? Post back in a few months and let us know how it goes, I'm actually curious.

C++ is a very powerful but dangerous language. If you're not careful it might bite you in the face. Having a beginner start with C++ is like having a toddler play with a set of knives IMO. It also has a lot of weird little idiosyncracies that are not present in other languages. But a lot of people started there so it must be OK.
  • #11
My opinion is that long term it's probably more useful to learn to program than any specific language. (And being able to cobble something together that happens to run is not what I mean by learning to program).
  • #12
I'll stick by Matlab first. The guy is studying to be an Engineer not a programmer. Having said that, knowing C or C++ is probably also required in a career sense. Employers stick it in resume requirements and expect it. It's use in hardware design in very small; in terms of things like DSP signal processing is common. But then a lot of assembly language diving is also done.
As illustrated above, being truly competent in programing is a full college major. If in addition signal processing is including that's even more of a burden. When the study concentration is on programing, the actual engineering is short-changed. I have seen good engineers hack together extremely bad programs and most programmers (with few exceptions) make a hash of actually doing programs that deal with engineering.
I take engineering as dealing with real world functioning; whereas programing is trying to construct things in a realm where you get to make up the rules out of clouds as you go along:):)

There is a free compatible program "Octave" which has been around (and improved) for a long time. The documentation is also freely available.

  • #13
I think learning a good general purpose language like python or ruby would be the best choice, while industry might still rely on those old strongly typed languages now I definitely think, especially for people who primary job is not programming that these more intuitive and easier to pick up languages like python are ruby are going to become more ubiquitous in the future. In addition programming python gets your mind conceptually ready for the other closer to the machine languages you might need to use sometime down the road. Learning a language like C++ can be a long and tedious ordeal and should probably only be undertaken if it is required.

I should note that I mean this from a general prospective as I have no special knowledge of what sorts of programming is undertaken by the typical mechtronics engineer.
  • #14
maze said:
C++ is a very powerful but dangerous language. If you're not careful it might bite you in the face. Having a beginner start with C++ is like having a toddler play with a set of knives IMO. It also has a lot of weird little idiosyncracies that are not present in other languages. But a lot of people started there so it must be OK.

I hear that every now and then...but what does it mean?
how can a language be dangerous?

and isn't c generally taught first in American Uni's rather than c++?

c is my first language btw...
  • #15
c++ all the way.

Just be careful and deliberate... use good programming practice and develop good habits. You'll be fine.
  • #16
I'll take this off-topic a bit, and ask if it's just me, or do engineering types (such as myself) swear by MATLAB (and its various toolboxes, and occasionally Simulink) while science and programming types almost always go with C++ or Fortran?

The various mentalities at play, or just vendor lock in (inasmuch as C++ has a 'vendor')?
  • #17
Honestly, I just don't really get Matlab. I don't find it any easier to use than C/C++. Oh well.
  • #18
csprof2000 said:
Honestly, I just don't really get Matlab. I don't find it any easier to use than C/C++. Oh well.

As a formal programming language, sure. However, I think many of us engineering types started off by using MATLAB as a glorified calculator / matrix solver, and then went on from there (usually along the lines of 'automating' a process via functions, and then MATLAB scripts, and then almost full-blown programs). And the (ab)user friendliness / tolerance is (IMO) second to none, as is the online 'help' documentation.

EDIT: Almost as if it weren't *really* a programming language.

EDIT: ...And I just remembered what my username on this forum was... :-D
  • #19
When you are presented with a programing problem once every 4-8 months, you ask what it does for you and how hard will it be to make it do what you want. Matlab, Octave, and Scilab all do a great deal of calculational programing for you. Actually APL and J do more but are a bit harder to get started in; and are not as obvious in the notation. Thus they are harder too present and get reviews for.
C++ and C easily allow a great deal more freedom in the algorithms, moving away from physical models into a intellectually (dream?) created realm (for better or worse). C++ is also supposed to be amenable to larger scale programs and portabilitity. I can't speak to "large scale" but I think the portability aspect is overblown. The only real case where I have seen it effectively used is in Linux which is basically done in C; but that is quite impressive.
Personally my programing has been along the lines of physical modeling, signal processing, control, and drivers. In these case the ease of notation involved in the scientific languages counts for a lot. In signal processing if Matlab, Simulink, Scicos, and Scilab fails in performance; it usually results in machine language code. A professional programmer did point out to me that this "failure" is the result of the compiler. He was right and this necessity hopefully fades into the past as compiler and library performance improves. I have studied Python a little and it also seems provide a great deal of engineering support; but not the notational support.
In the end; it's how much the language (or formalism) can do for you for a given task. In engineering you want computational and modeling support; in programing (say routing calls or balancing millions of accounts) you want structural support and flexibility. In both cases you must be able to get reviews of the actual code and performance in order to get verify your mind is in the right place.
Be aware; sometimes performance, maintainability, etc.. are not obvious. In my brief excursion into Prolog many years ago I found the maintainability to be quite good; something that to me was quite counterintuitive.

Standard disclaimer: Your mileage will vary.
  • #20
I don't understand why you're in such a rush to take programming classes. It's better to learn the fundamentals of your subject first. Programming, in my opinion, is the most boring subject on Earth. I took classes in C++ and hated every minute of it. It wasn't until I took a computational physics class with Matlab that I started to enjoy programming, and realized I was actually pretty good at it.
  • #21

Related to Programming language for engineers

1. What is the best programming language for engineers?

The best programming language for engineers depends on the specific needs and goals of each individual engineer. Some popular languages among engineers include Python, Java, C++, and MATLAB. It is important to choose a language that is well-suited for the task at hand, as well as one that is commonly used in your field of engineering.

2. Is it necessary for engineers to know how to code?

In today's fast-paced and technology-driven world, coding has become an essential skill for engineers. It allows engineers to automate tasks, design and analyze systems, and develop innovative solutions. While not all engineers may need to be proficient in coding, having a basic understanding of programming concepts can greatly enhance their abilities and make them more competitive in the job market.

3. Which programming language is used most in the engineering industry?

The most commonly used programming language in the engineering industry is Python. Its versatility, ease of use, and large library of scientific and engineering packages make it a popular choice for data analysis, simulation, and automation tasks. However, as mentioned before, the best language for engineers ultimately depends on the specific needs of each project.

4. Can engineers use multiple programming languages?

Yes, engineers can use multiple programming languages depending on the task at hand. For example, they may use Python for data analysis and MATLAB for simulation. It is beneficial for engineers to have knowledge and proficiency in multiple languages, as it allows for more flexibility and the ability to choose the best tool for the job.

5. Are there any programming languages specifically designed for engineers?

While there are no programming languages specifically designed for engineers, there are some languages that are commonly used in the engineering field due to their capabilities and libraries. These include MATLAB, LabVIEW, and Simulink, which are all widely used for simulation, modeling, and data analysis tasks in various engineering disciplines.

Similar threads

  • STEM Academic Advising
  • Programming and Computer Science
  • Programming and Computer Science
  • STEM Academic Advising
  • Programming and Computer Science
  • Programming and Computer Science
  • Programming and Computer Science