Programming Languages for Embedded Systems 101: Background and ResourcesMay 26, 2017 by Chantelle Dubois
A brief guide to some useful programming languages used in embedded systems design—and where you can learn, practice, and master them.
Here's a brief guide to some useful programming languages used in embedded systems design—and where you can learn, practice, and master them.
You don't need a formal education in computer science or engineering to hone your programming skills. There's a plethora of resources available online to help you learn and improve your skills, providing an alternative pathway to becoming an embedded systems programmer.
But figuring out which programming languages to invest your time in can be difficult. This guide can help guide you on your way.
According to a 2016 survey by IEEE Spectrum, C and C++ took the top two spots for being the most popular and used programming languages in embedded systems. This is unlikely to come as a surprise to seasoned engineers, scientists, and hobbyists who are almost guaranteed to have used one or both of these languages to a large extent at some point.
C was created in the early 70s by Dennis Ritchie as a high-level programming language in UNIX operating systems. At the time, the Assembly language was largely used, which required many lines of code to accomplish a task. The B programming language was then created to accomplish these tasks with fewer lines of code, but it did not have data types or structures. C was then created, which implemented features missing in B. C then became the standard programming language in UNIX systems.
C++’s genesis began in the late 70s by a PhD student named Bjarne Stroustup, who was using a programming language called Simula. Eventually, he switched to C, which was much faster and allowed low-level programming. But then Stroustup began to add features found in Simula to C. The hybrid became “C with Classes” and, in 1983, was renamed to C++. The ‘++’ in C indicates an increment, so C++ is a nod to the C foundation in the language.
The difference between C and C++ is generally that it is that C is a procedural language meant to be used in system programming and is more “lightweight” (requires less memory), whereas C++ is more general and object-oriented.
Learning C or C++ is a great way to get started in embedded systems programming. Some say that if you can learn C, you can learn any language. It also doesn’t hurt that it’s so widely used, even to this day.
The Arduino platform can be used with C or C++. Image courtesy of OpenHomeAutomation.
Just as C++ is to C, Rust is to C++. Rust is an open-source, general-purpose programming language developed by Mozilla Research, primarily focusing on safety and integrity.
Rust began as a personal project by Graydon Hoare in 2006 and is a relatively new language, released in 2015. It has quickly gained popularity and was voted as 2016 and 2017’s favorite language by the Stack Overflow community.
Rust’s features include algebraic data types, type inference, and pattern matching, just to name a few.
There is some expectation that Rust will eventually overtake C++ in widespread use.
While not traditionally associated with embedded systems, Python is beginning to be taken more seriously in embedded systems applications. It is often the first language students will learn in a computer science degree program and you'll find all sorts of interesting Easter eggs and nods to popular culture hidden in its nomenclature.
Python was created by Guido Van Rossum in the 80s and was named after “Monty Python’s Flying Circus”. It’s a general purpose, multi-programming paradigm language which focuses on readability and writability, eliminating as much unnecessary writing as possible for straightforward code.
Out of the box, Python might not be as useful for embedded programming as C or C++, but with numerous libraries available, it's easy to implement features that make it just as useful. It is excellent for automating testing, and collecting and analyzing data.
VHDL and Verilog
Hardware Description Languages are used a lot in FPGAs and in parallel programming applications. They are quite different from many other types of languages in that they are usually based on hardware, hence “hardware description”.
Verilog was invented in the early 80s as one of the first HDLs, used primarily in the modeling of electronic systems. The language name is a shortened version of “VERIfication of LOGic”. The program is based off of a hierarchy of modules to be able to describe a system. Verilog may be easier to learn if you already have experience with programming in C.
VHDL was developed by the US Department of Defense in the late 80s, initially as a way to better understand ASIC behavior. It eventually evolved into becoming an HDL, based off the Ada programming language. VHDL is used frequently in industrial applications.
The MIMAS V2 board with a Xilinx Spartan-6 FPGA is excellent for practicing HDL. Image courtesy of Numato Lab.
From All About Circuits
- Learn C - Free Interactive C Tutorial [C]
This interactive tutorial has everything from beginner challenges to more advanced tutorials on topics such as data structures and pointers
- HackerRank [C++, Python]
Hackerrank has thorough tutorials, organized by core computer science concepts (algorithms, data structures, mathematics) and skills (artificial Intelligence, databases, security). It also has resources for coders preparing for job interviews and regularly has hackathons for all levels of programmers to compete.
- CodeFights [C++, Python]
CodeFights makes learning to program fun, with an interactive “story” with challenges that progress in difficulty as you move along. You get to choose your language of choice when you sign up but you can switch whenever. You can also participate in challenges directly against other users, compete in tournaments, and prepare for job interviews.
- Rust by Example [Rust]
Rust by Example is a tutorial which walks you through a series of tasks with increasing complexity. The tutorial is quite comprehensive and completing it should give you a head start on being able to use Rust in real-world applications.
- Verilog In One Day [Verilog]
While the website may look dated, it is a treasure trove of useful information for those venturing to learn Verilog. There are multiple tutorials that range from the basics to testing and links to resources to help you further your skills.
- VHDL Tutorial: Learn by Example [VHDL]
This is a comprehensive guide on VHDL programming with examples, tutorials, and resources to help get you started.
- Nandland [VHDL, Verilog]
Nandland ran a Kickstarter campaign to produce an FPGA board which can be used while going through their Verilog and VHDL tutorials. Of course, you can use any FPGA for the tutorial. The website also offers a fairly thorough explanation of what an FPGA is and enumerates many features (or quirks) that are helpful to know when getting started in FPGA programming.