What’s The Best Programming Language For Embedded Systems?
Is it C? Why?
As you might be thinking, there is no way to answer such a question without knowing what’s meant by “The Best”. That really depends on what is the type of embedded computer platform involved in developing specific applications and some other factors as we’ll see hereafter.
Low-End
Developing simple robotic systems, control systems, IOT, or any sort of “Bare-Metal” programming with low-end MCUs is done mostly in C. As well as Assembly for tiny tasks and parts, for loaders, start-up codes and for context switching. Occasionally, a very limited version of C++ is also used.
Examples for low-end development platforms include: {8-Bit MCUs (AVRs, PICs, etc) – Arduinos – Low-End ARM Microcontrollers (Cortex M0, M3, M4) }.
Note That: The Arduino programming language is a pseudolanguage called wiring and it’s a C++ based and compiles down to machine language using the standard avr-gcc compiler integrated within their IDE.
Microchip PIC Curiosity |
STM32F407DiscoveryBuy on Amazon |
Arduino Uno |
High-End
For developing high-end applications involving complex computations and large data structures manipulations, it’s common to see desktop programming languages like C++, Python, etc. This includes the application of Deep Neural Networks(DNN), Computer Vision, and Ai Algorithms. Running on top of an operating system.
It has been proven that Hardware Acceleration is the way to go for computationally complex Ai stuff. Hence, SOC development platforms are getting more and more familiarity in the market. Combining high-end ARM core processors with hardware-reconfigurability of FPGA chips, can tremendously accelerate tons of computational workloads. That’s why many embedded engineers do learn a Hardware Description Language(HDL) such as Verilog or VHDL. And it’s getting more traction these days.
Examples for high-end development platforms include: {Raspberry-Pi – BeagleBone – Nvidia Jetson TX – FPGA soc }, or any platform running Embedded-Linux kind of operating system.
DE-0 Nano SOC
|
BeagleBone Black |
NVIDIA Jetson TX2 |
|
Raspberry Pi 3 |
|
Programming Languages Popularity
The most popular programming language for embedded systems development has been the C language. It has been the standard option in this industry for too long. Recent statistics prove this fact to still be true for the present and the seeable future. Check this statistic by IEEE Spectrum back in 2016 to find out that the most popular programming language for embedded development is C followed by C++ and Assembly. Other language options are slowly growing in traction as we need more and more OS-Based applications.
Why C?
There are many reasons why C is still dominating in the field of microcontrollers programming. I’ll try to list some of them right now
☑ The programmers aren’t in need to know every specific detail about the microprocessor itself. Which is kind of the overwhelming things that you’ll have to deal with while programming in assembly. It gets tougher when you’ve got to work with multiple microprocessors with different architectures.
☑ C provides register-level programming and manipulation facilities on a low-level. Thanks to pointers
☑ Developing in C produces portable code and yet highly efficient.
☑ C Programming allows for resources and basic memory management.
Challenges in C
☑ Successfully compiled C-Code is not a guarantee that it’s gonna work! wrong conversions, overflows, mishandled flags, locks all can lead to nightmares that are hard to find.
☑ Pointers while being so powerful, they can sometimes cause ambiguity and confusion.
☑ Poor dynamic memory management options may not meet the needs of some real-time applications.
Resources For Further Study
[Book] The C Programming Language
[Book] C Primer
[Book] OOP in C++
[Book] C++ Primer
[Website] Learn C.org
[Website] FPGA Tutorials
[Course] Embedded Systems – Shape The World
[Course] Learn Embedded Systems Development With Microchip PIC MCUs