Deciding on the programming language for an embedded system may be the most important building decision you make. I've built thousands of embedded systems, using a range of languages. Here’s my advice on using and picking languages, and tips from other development experts.
In this article:
An embedded programming language is a programming language that developers use in embedded systems. In general, the languages offer low-level access to the device hardware. Developers use several common programming languages for embedded systems.
Some people also call these embedded coding languages. But programming involves much more than coding.
Developers use a variety of programming languages in embedded systems. The most used languages include C, C++, Python, MicroPython, and Java.
Programming languages that developers frequently use in embedded systems have some key advantages. Most languages also have drawbacks. Here are the advantages and limitations of popular embedded programming languages.
CDevelopers also use other languages for embedded systems with specific needs. These languages are not common across all embedded systems but are popular in specific cases and perfect for some systems.
Ada
Download comparison matrix of top embedded software programming languages.
A couple of languages that some people may refer to as programming languages are actually "hardware description languages," or HDLs. The two primary HDLs are Verilog and VHDL.
HDLs allow engineers to simulate an electronic circuit while the simulation remains independent of that circuit. Engineers use HDLs for design, testing, and debugging of systems and doing timing analysis of systems.
Qt's Embedded Product Planning and Requirements Guide feature details and a comparison chart on the top five embedded programming languages. The chart compares key traits of the programming languages.
C | C++ | Java | Python / MicroPython | JavaScript/ HTML5/CSS |
Rust | |
Strenghts | Embedded, bare-metal, IoT |
Embedded, bare-metal, standalone apps, IoT |
Web, cloud | Cloud, data science | Web | Embedded, bare-metal |
Ease of development | ★★★ | ★★ | ★★★ | ★★★★★ | ★★ | ★★★★ |
Expressive power |
★ | ★★★★ | ★★ | ★★★★★ | ★★★ | ★★★★ |
Ease of maintenance | ★★★★ | ★★★★ | ★★★★ | ★★★ | ★ | ★★★★ |
Longevity | ★★★★★ | ★★★★ | ★★★ | ★★★ | ★ | ★ |
Runtime efficiency | ★★★★★ | ★★★★★ | ★★★ | ★★ | ★ | ★★★★ |
Library/module availability | ★★★★ | ★★★★ | ★★★ | ★★★★ | ★★★★ | ★★ |
Low-level interface | ★★★★★ | ★★★★★ | ★★ | ★★★ | ★ | ★★★★ |
Connectivity support | ★★ | ★★★/★★★★★¹ | ★★★★ | ★★★★★ | ★★★★★ | ★★ |
Graphics support | ★★★★ | ★★★★★ | ★★★ | ★★★ | ★★★★★ | ★ |
Developer community |
★★★ |
★★★ | ★/★★★★² | ★★★★ | ★★★★★ | ★★ |
★ is the lowest ranking while ★★★★★ is the highest.
1 Provides high level of connectivity and networking support when platform libraries included
2 Java Developer community exclusive of Android (low) and inclusive of Android (high)
When selecting a programming language for an embedded system, experts say you must understand the strengths and weaknesses of each language. It’s equally important to know the limitations and goals of your system.
For many embedded systems, C or C++ will be the best choices. In part, that’s because they are “compiled” languages and extremely efficient. In compiled languages, the machine (or embedded device) directly translates the code, which means the language is fast and stable.
Devices that have minimal memory or power will often require that efficiency. So, programmers often use C or C++ in those devices. C or C++ are frequently used in microcontrollers and in embedded devices that use real operating systems. Those systems also demand the speed and efficiency that C and C++ provide. You’ll also find C and C++ in several other embedded systems. Some experts estimate that about 80% of all embedded systems use the C programming language.
But your embedded system might also work just as well, or better, with an “interpreted” programming language. With an interpreted language, the embedded device does not directly translate the code. Instead, another interpreter program running on top of the device executes the code. For some embedded systems, the advantages of interpreted languages will be critical. Unlike compiled languages, interpreted languages are easily portable from one OS to another. They are also much easier for programmers to learn, read and write.
Python and JavaScript are examples of interpreted programming languages. Since interpreted languages require extra processing, they often operate more slowly than compiled languages — though their speed is improving. If your embedded device uses machine learning, Python and MicroPython have significant advantages.
Ada is a programming language you may want to use if your device requires extraordinary security and stability (as in medical devices or aviation or military equipment).
Experts also state that you must realize the capabilities and experience of your programming team. "I always tell people to look at the skill set of their engineers," adds Beningo. "I try to push a lot of people to use C+ now if they can. But for engineers that know C well, the transition to C++ can sometimes be difficult. So, it's really looking at the experience and the skill sets of the team that helps dictate that." (Learn more about skills that embedded engineers need.)
And Burkhard Stubert, an independent software developer and consultant specializing in embedded systems, explains that companies often don't have much choice in the programming language they use. The existing system or related systems may be using a programming language that means they’ll need to use a specific language.
"Normally, you don’t pick the language, but the language picks you," Stubert shares. "With embedded systems, this is typically C, C++, or Python. Then, you go from there."
Every embedded programming language has its pros and cons. Some languages work better than others with graphical user interfaces. Just as you spend time researching the language you want to use, you’ll also want to consider the GUI when you pick the language. For example, if your system uses GUIs, you likely will want to use an interpreted language like JavaScript.
Sometimes, there is a clear-cut way to tell which language best suits the needs of your embedded project. Quite often, the choice comes down to what the developers are proficient with and personal preferences. Qt aims to give you the freedom to create software in the programming language you like best. The Qt Company supports C++, QML (Qt's easy-to-use declarative language), and Python, while even more languages like Rust and Go are backed by the community.
Learn more about designing your system's user interfaces with Qt QML and how to use other Qt products to build the best embedded system in a range of languages.