Find out which of many programming languages are commonly used in robotics.
Programming languages are an inherent part of a computer’s performance as thanks to them, the device can properly and efficiently execute its tasks. There are many programming languages out there but we’re going to focus on the ones that are most commonly used in robotics, especially in mobile robots like the Leo Rover platform.
C is a major general-purpose programming language used in the field of robotics. It’s commonly applied to develop operating systems, databases, embedded systems, micro-controllers among many other things. It comes with a broad array of libraries, tools, and features handy in robotics. A lot of programming languages that were developed later, such as Java or JavaScript, rely on syntax or features borrowed directly or indirectly from the C programming language.
Among the key features of C are the following:
C++ was developed as an extension of the C language in order to incorporate object-oriented paradigm. This aids in creating extensible and maintainable programs. C++ is an imperative and compiled programming language, which contributes to the speed and safety of its execution. It’s good for a program’s efficiency and little memory usage. Since it’s derived from C, the syntax and structure code of both is nearly the same.
Other notable features of the C++ programming language include:
The use of the C++ programming language can be found, for example, in operating systems and systems programming, browsers, cloud/distributed systems, game engines and graphics, database engines and the like.
C++ can be used to interface with ROS through roscpp – the most widely used ROS client library.
Python is a clear and potent object-oriented programming language. Compared to other leading languages, Python uses fewer lines of code which makes it much easier to write in. In addition, it contains an array of libraries for basic functions. It’s suitable for writing algorithms for high-level features that don’t need to be written efficiently, but readably. The language’s key goal is to ease and speed up programming.
Python occupies a high position among the best programming languages for robotics as in it, each element can be made, altered, or deleted. To complete a command, Python uses new lines, unlike other programming languages that often use parentheses or semicolons.
Other noteworthy features of Python include:
Python is widely used in web development, machine learning, web framework, image processing, and also in technologies applied in the software industry. Python is well tailored for beginners, but is also in common use by experienced programmers.
Alongside C++, Python is the other main programming language used in ROS, having its own ROS client library – rospy.
Java is a powerful, general-purpose programming language. It includes all the high-level features required in the robotics industry, particularly those related to AI. It enables to create very efficient algorithms used for machine learning, language processing, and so on.
Some major features of Java are as follows:
Compared to Python and C++, it can be said that Java lies somewhere in between. Java programs tend to run faster than their equivalent Python programs but slower than the C++ ones. Similarly to C++, Java performs static type checking while Python doesn’t.
Java is used for developing desktop and mobile applications, embedded systems, big data processing, games, web servers, database connection and so on.
C# is a modern, general-purpose, and object-oriented programming language. It’s one of the languages in the Common Language Infrastructure. C# runs on the .NET framework and is highly flexible.
C# comes with an array of exceptional features including:
The C# programming language is mostly used for web and game development and Windows apps among other things.
Rust is a general-purpose, multi-paradigm, statically-typed programming language. It was designed for performance and safety, in particular, safe concurrency and memory management. Originally, Rust was developed as an open-source project at Mozilla Research.
The language’s syntax is similar to that of C++. A key advantage of Rust is that it addresses the issues that C/C++ developers have been struggling with for a long time, such as concurrent programming and memory errors.
There can be pointed out 3 main strong assets of Rust:
Recently, Rust has gained notoriety and is getting more and more popular with the robotics developers, slowly becoming a substitute for C++.
JavaScript belongs to one of the key web technologies, right next to CSS and HTML. It’s a versatile, dynamic, lightweight programming language with object-oriented capabilities. It’s also considered an interpreted programming language as the compilation is performed at run-time.
JavaScript is used both on the server and client sides. When it comes to the server side, node.js is used. On the client side, the code is executed and displayed by the browser.
Some of the JavaScripts key features include the following:
JavaScript is mostly used for creating dynamic webpages and network-centric applications. All leading web browsers run on a dedicated JavaScript engine to execute the code on user’s devices.
Given that the languages listed above are widely popular in robots, you won’t be surprised that some of them found their use in the Leo Rover robotic platform. Let’s see which ones :).
The Leo Rover’s user interface, about which you can read here, is written in JavaScript along with CSS and HTML.
The firmware, i.e. the code that is running on the motor controllers LeoCore or Husarion CORE2 (depending on the Rover iteration you have), is written in C and C++.
Various other components developed by us that run on the Raspberry Pi are written primarily in Python. In instances where speed is critical, the components are written in C++.
Also, a lot of software used in Leo Rover is provided by open-source packages available in the ROS ecosystem that we contribute to when needed.
Knowing your way around programming is a must in robot development. And the more programming languages you know, the more doors to a career in the robotics industry you can open for yourself. Even if you're programming just for personal needs, it’s always good to brush up your skills so that your machine can perform even better. And if you’ve just started your adventure with robotics, check out our article on challenges with robot development :).