Why we need to retire the blinking LED as the entry into embedded programming

Something that was true since 1985 changed in Q4 of 2018 and we are yet to feel all the repercussions.

* * *

Every ThinkPad, iPhone, Kindle…every Alexa, Nest, Homepod…every DJI Drone, Go PRO or Tamagochi,  every Fitbit, every Pebble…every Xbox or Nintendo…every Walkman, every Game Boy, every C64, Amiga or Tandy.

Every piece of electronics which we geeked out about, used, abused, eventually bricked then forgot…

Each and every one of them hails from the same embryo.

The blinking LED. 

It used to be the classic “Hello World” of the embedded world.

But for a while now it has been due for an update. An update that would reflect the vanishing boundaries between different domains of software development, as brought on by IoT. Consider Gartner’s prediction: by 2020, 20.4 billion devices will be connected to the Internet. It’s time to replace the LED blink with a “Hello, Cloud.”

We could have spent a few more years debating about it but a major turning point happened in the last quarter of last year, giving us a perfect excuse.

What happened in Q4 of 2018 is that Python became the most popular programming language, according to a 5-minute video that recently went viral. To become number one, Python toppled Java. Java sat on the top spot since 2000 after dethroning C, which in turn knocked down Pascal in 1985.

C and Java are related so the transition between the two is not as interesting as the rise of Python. How did a scripting language replace a comparatively low-level language as the most popular in the world? Will Python seep into all aspects of programming from supercomputers to embedded systems the way C did? And will it have a 33-year run on the top like the c-family of languages?

It’s impossible to tell, of course. But whatever skeptics and detractors may say, Python is more diverse than given credit for. It has only started to show its potential for programming embedded systems. What it lacks in efficiency and speed of execution, it makes up for in speed of development and deployment. And in the world of 32-bit microcontrollers, and short, Agile-based development cycles, this is often a welcome trade-off. 

To demonstrate the beauty and elegance of Python in embedded applications, I want to show you the “Hello Cloud” example of Zerynth, a company I work with. Zerynth offers a Python toolchain for embedded and IoT programming.

In just 12 lines of readable Python code, you can connect your device to the cloud and send a message.

In this example, I am sending a “Hello Cloud” message from a Xinabox CW02 board (figure 2) to the OKDO Cloud (one of many possible board and cloud vendor combinations supported by Zerynth):

Copy to Clipboard

You can see the result here and in figure 1.

Figure 1: Screenshot of the OKDO Cloud Dashboard showing the message. In this example, the OKDO dashboard is publically shared. The platform also allows users to configure private dashboards.

Figure 2: The Xinabox set used in this demo

A total of 12 lines of code to connect your device to the cloud! 

Compared to this, the classic LED blinking example of the embedded world looks as feeble as a gesture of a man who just woke up from a coma and is told to blink once if he is conscious.

And to think that back in the ‘90s, I had to learn assembler to blink my first LED.

Even if you wanted to do it in C, you’d need to do it differently depending on the target microcontroller. 

In contrast, the Zerynth tool-chain adopts Java’s “write once, run anywhere” approach to the embedded world, through its Virtual Machine firmware.

Does Python provide an equal degree of low-level access to the underlying hardware the way C does?

Certainly not.

But the beauty of Python is that it’s the perfect “glue language.” The Zerynth tool-chain takes advantage of this by implementing a hybrid Python/C approach.

This means that experienced embedded developers sacrifice nothing, while newcomers to the embedded world can put their Python powers to good use in a brand new domain.

In that regard, Python is the glue in more than one way. It breaks barriers and brings together domains of software engineering that have been separated ever since the dawn of the PC revolution. 

If Python can bring us closer to the atmosphere of that homebrew-era of IT, before the compartmentalization and uber-specialization of developers, when the biggest innovations took place — then I am rooting for it to keep its top spot among the most popular languages for decades to come.