What is the Best Programming Language for Robotics?
Posted on Mar 14, 2016 7:00 AM. 12 min read time
Need to program your robot but don't know which language to choose?
Don't know what languages are available?
There's no simple answer, but here are the top 10 most popular programming languages for robotics.
Which is the best programming language? It's a question that a lot of new roboticists will ask at least once in their career, but there's no simple answer.
But, it's a very reasonable question. After all, what's the point of investing a lot of time and effort in learning a new programming language if it turns out you're never going to use it?
If you're new to robotics, you want to learn the programming languages which are actually going to be useful for your career.
Why you'll never get a simple answer from roboticists
When I published the first version of this article in 2016, I knew it was going to be a controversial one. Since then, the huge number of comments below and many copycat articles published elsewhere on the web suggest that I was right…
… many people disagree as to what is "the best programming language for robotics.”
Unfortunately, you will never get a simple answer if you ask "What's the best programming language for robotics?" to a whole roomful of robotics professionals (or on forums like Stack Overflow, Quora, Trossen, Reddit or Research Gate).
Electronic engineers will give a different answer from industrial robotic technicians.
Computer vision programmers will give a different answer from cognitive roboticists.
In the end, the answer which most intelligent people agree on is "it depends."
This is the most realistic answer. It depends on what type of application you want to develop. It depends on what system you are using. It depends on your personal preferences.
But, it is also a pretty useless answer for the new roboticist who is trying to decide which language to learn first. You're probably reading this article because you want to start programming robots and don't know which language to choose.
Which programming language should I learn first?
My advice is not to ask which programming language is the "best". A better question to ask is: Which programming language should I start learning now?
You will still get differing opinions, but a lot of roboticists can agree on the key languages.
But first, be clear on your justification for wanting to learn robot programming:
1. If you just want to get one robot up and running
If you're only using a single robot for your business, the best language to learn is the one that will get you up and running as soon as possible. In this case, you might not even need to learn a programming language. For example, with hand guiding technology you can move a collaborative robot around manually. No text-based programming required.
2. If you want to start a career in robotics
The most important thing for career roboticists is to develop "The Programming Mindset" rather than to be proficient in one specific language, as I explained in the article about essential robotic skills.
In many ways, it doesn't really matter which programming language you learn first. Each language that you learn develops your proficiency with the programming mindset and makes it easier to learn any new language whenever it's required.
In this case, learn whichever language makes the most sense for your next project.
How I drew conclusions for this article
The original version of this article — one of our most popular articles ever — was based on both my experiences in robotics and those of my colleagues combined with many opinions that I had found in online forums.
For this updated version of the article, I've brought in some more objective data about the most popular programming languages among engineers and the most common programming languages at the time of writing. I've also researched the newer languages that have been popping up since the first version of this article.
This new data has changed some of the items on the list, but not much. The same programming languages remain as popular as they were when I wrote the first version.
Top 10 Popular Programming Languages in Robotics
There are over 1500 programming languages in the world, which is far too many to learn.
Here are the ten most popular programming languages in robotics at the moment. If your favorite language isn’t on the list, please tell everyone about it in the comments! Each language has different advantages for robotics. The way I have ordered them is roughly in order of importance from least to most valuable.
Pascal was one of the first programming languages that I ever learned. However, that's not why I've included it here. It is the basis for several of the industrial robot languages (see number 8 below). As a result, it's still quite a good starting point if you are going to be programming industrial robots.
Pascal is a basic language (literally based on the language BASIC) and was designed to encourage good programming practices.
These days, Pascal is too outdated to be good for everyday use. However, it can be useful if you want to become familiar with other industrial robot languages without becoming tied to one particular robot brand.
A brand new entry to this list, Scratch is used by thousands of budding roboticists around the world every year. This visual programming language is specially designed for new programmers — targeted at users aged 8 to 16 — and is often the language of choice in school technology classes and robotics clubs.
Although you're probably not going to write any industrial robot programs in Scratch, it's an incredibly good and popular language for complete beginners and is paving the way for many of our future robotics engineers.
8. Industrial Robot Languages
Almost every robot manufacturer has developed their own proprietary robot programming language, which has long been one of the problems in industrial robotics. You can become familiar with several of them by learning Pascal. However, you are still going to have to learn a new language every time you start using a new robot brand.
ABB has its RAPID programming language. Kuka has KRL (Kuka Robot Language). Comau uses PDL2, Yaskawa uses INFORM and Kawasaki uses AS. Then, Fanuc robots use Karel, Stäubli robots use VAL3 and Universal Robots use URScript.
In recent years, more general-purpose programming options like ROS Industrial, manufacturer agnostic offline programming, and hand guiding have started to provide more standardized options for programmers. However, if you are a technician, you are still more likely to have to use the manufacturer's language.
Artificial Intelligence (AI) has really been gaining in popularity recently. This means that AI programming languages like LISP and Prolog are starting to make their way back into people's programming toolkits.
LISP is the world's second oldest programming language (FORTRAN is older, but only by one year). Parts of ROS (the Robot Operating System) are written in LISP, although you don't need to know it to use ROS.
Prolog is a logic programming language and allows programmers to represent "knowledge" in a form that an AI algorithm can understand. Prolog was used as part of the programming in IBM's Watson AI.
It is also possible to program artificial intelligence using some of the other languages on this list and more that are not listed. However, LISP and Prolog remain at the core of some AI implementations and certainly deserve their place on this list. It's also worth remembering that robotics and AI are not the same thing.
Hardware Description Languages are basically a programming way of describing electronics. These languages will be very familiar to electronic engineers who create the low-level electronics of robots.
HDLs are commonly used to program Field Programmable Gate Arrays (FPGAs). These devices allow you to develop electronic hardware without having to actually produce a silicon chip, which makes them a quicker and easier option for some development tasks.
If you don't create prototypes of robotic electronics in your job, you may never use HDLs. Even so, it is important to know that they exist as they are quite different from other programming languages. For one thing, all operations are carried out in parallel, rather than sequentially as with processor-based languages.
MATLAB (and its open-source relatives like Octave) is very popular with some robotic engineers for analyzing data and developing control systems. It is used extensively in research and data processing. It's also used extensively in some university courses.
For robotics, there is also a very popular Robotics Toolbox for MATLAB. I know people who have developed entire robotics systems using MATLAB alone. If you want to analyze data, produce advanced graphs or implement control systems, you will probably want to learn MATLAB.
C# is a proprietary programming language provided by Microsoft. I include C#/.NET here for two reasons:
- It is the primary language of the Microsoft Robotics Developer Studio. If you are going to use this system, you're probably going to have to use C#.
- It is used as the basis for some Virtual Reality engines, like Unity, which are growing in popularity right now.
If you come to robotics from a computer science background (and many people do) you will probably already have learned Java first.
As an electronics engineer, I have never understood Java. I've always preferred languages that allowed for lower-level programming and more control, like C. This is a good example of how people from different disciplines within robotics have different programming preferences — just because I don't like it doesn't mean you shouldn't.
Like C# and MATLAB, Java is an interpretive language, which means that it is not compiled into machine code. Rather, the Java Virtual Machine interprets the instructions at runtime, allowing you to use the same code on many different machines.
Java is quite popular in some parts of robotics. It's apparently one of the core languages of several modern AIs, including IBM's Watson and AlphaGo.
Python is on a roll at the moment. According to statistics it is has grown rapidly to become one of the top languages.
One of the reasons for its popularity in robotics is probably that Python (and C++) are the two main programming languages found in ROS.
The prime focus of the language is ease-of-use. Many people agree that it achieves this very well. Python dispenses with a lot of the usual things which take up time in programming, such as defining and casting variable types. Like Java, it is an interpreted language.
There are also a huge number of free libraries for Python which means you don't have to "reinvent the wheel" when you need to implement some basic functionality. And since it allows simple bindings with C/C++ code, the performance-heavy parts of the code can be implemented in these languages to avoid performance loss.
With more and more robotics-friendly electronics now supporting Python "out-of-the-box" (e.g. Raspberry Pi), we are likely to continue to see a lot more Python in robotics.
Finally, we reach the Number 1 programming language in robotics!
Many people agree that C and C++ are required languages in robotics. Why? Because a lot of hardware libraries used in robotics use one of these languages. These libraries allow interaction with low-level hardware, allow for real-time performance and are very mature programming languages. These days, you'll probably use C++ more than C, although C remains one of the most efficient programming languages available.
C/C++ are not as simple to use as, say, Python or MATLAB. It can take quite a lot longer to implement the same functionality using C and it will require many more lines of code. However, as robotics is very dependent on real-time performance, C and C++ are probably the closest thing that we roboticists have to "a standard language". This is true even despite the growing popularity of Python.
If you take away just one thing from this article…
Many people have used this article to say that they should learn C/C++ or Python first.
This conclusion may be true…
… however, let me give you just one piece of advice:
Learn whichever programming language makes the most sense for you right now.
The most important thing is to develop your "Programming Mindset". Learn as many programming languages as you can. The more you learn, the better you will be at programming. Just because I've listed these ten languages doesn't mean that you have to learn all of them, or indeed any of them. The most important thing is to find a language that feels natural for you and fits with your robotic hardware.
And if you really want a recommendation…
If you must push me for a recommendation, I would suggest that you want a language that allows you to develop programs quickly and easily, so that you can focus more on developing functionality.
For this reason, I would recommend learning Python first. This is just my own personal opinion. If another language makes more sense for you, then learn that instead. However, Python is an amazingly straightforward language to learn and hugely powerful thanks to the many, easily-accessible libraries.
I have heard many accounts from (already experienced) programmers who learned Python in a couple of days and were immediately converted to it for almost all of their programming needs. As one guy said, "I can produce usable code in Python as fast as I can type."
After you've gotten reasonably proficient using Python, I would personally recommend learning C, followed by C++. You will need it to interface with a huge majority of robotic hardware drivers.
And if you're under 16 years old and/or have never programmed before… learn Scratch first. It's great!
Have we left out your favorite programming language? Which programming language did you learn first? Which do you use most often when programming robots? Tell us in the comments below or join the discussion on LinkedIn, Twitter or Facebook.