MakeCode and CODAL Ease The Way To Programming Electronics
Written by Nikos Vaggalis   
Monday, 01 October 2018

Ever wanted to program electronics for either fun or profit but thought that the entry barrier was too high? Are you a teacher, a parent, who wanted to teach kids tangible coding but can't figure out where to start from? If the answer is yes, you'll find MakeCode and CODAL a much more accessible way to break into the world of electronics.

MakeCode by Microsoft, is a web app in which you can write code for micro controllers in a high level language, either block-based Blocky or TypeScript, while CODAL (Component-Oriented Device Abstraction Layer) by Lancaster University is an optimized C++ runtime which supports higher-level languages and contains  drivers for devices. Initially they were just for the BBC micro:bit but other targets include Arduino Uno or BrainPad.

MakeCode offers two conveniences for writing code for electronics.First, it does not require the user to make any installation whatsoever, the likes of compilation toolchains or device drivers;you just need a web browser as everything runs inside the browser, writing code or even compiling C++ binaries!

Second, you can program in the Blocky editor for visual block-based programming or Monaco, the code editor powering VS Code, and TypeScript. Blocky makes it easy for pupils and kids to get started, while Monaco caters for more advanced users offering text-based programming in a variant of TypeScript called STS or Static TypeScript, which:

"extends TypeScript with a type constructor for concrete types, allowing the programmer to choose between untyped, optionally-typed, and concretely typed code".

Going about it typically adheres to the following workflow:

  1. Write the program in either editor

  2. Test it online on the web based simulator provided by MakeCode

  3. Compile the code into machine code (a process taking place in-browser) and link it against the pre-compiled
    CODAL C++ runtime to produce a compiled binary

  4. Connect the micro device to the PC, note that the MakeCode compatible devices appear as USB pen drives when plugged into a USB port of the PC, thanks to yet another novelty, the UF2 file format and bootloader which allows for the simplified transfer of binaries to the device over USB.

  5. Transfer the binary file to the user's PC and then to the micro device by flashing it. 

So what do MakeCode and CODAL achieve this way?
Starting from the bottom up, flashing the device over USB compared to more traditional methods of connecting to micro devices is much much simpler.

In yet another lowering of the entry barrier, there is no installation required and, of course, there's the use of high-level languages to write programs for the embedded devices, a territory occupied almost exclusively by low-level languages close to the hardware such C and C++.

The problem from the beginning was to figure out a way of removing C/C++'s steep learning curve, but at the same time keep both the functionality and optimizations resulting from its use. By compiling TypeScript to C++ and linking it against CODAL, the optimized and efficient runtime capable of running on devices with a memory footprint as low as 2 to 32 Kb, is a feat by itself.

Sure,there's other compilers that compile higher-level languages such as JavaScript, Java, and Python to machine code, but they require the mediation of a VM such as MicroPython, CircuitPython, and Espruino. These VMs are neither performant, nor memory efficient. The benchmarks reinforce this view, by demonstrating that binaries compiled by MakeCode and linked with CODAL outperform the other approaches.

So, aspiring electronics adventurers, little or big, give MakeCode and CODAL a try. It's easy to setup and takes care of a lot of boilerplate to allow you to focus on just the one thing you should be focusing on - coding.

More Information

MakeCode
CODAL
Blocky
Monaco
Adafruit

 

 

Related Articles 

Hour of Code 2017 Introduces App Lab

Pythonroom Brings Coding to the Classroom

Learn to Code With Games

MakeCode for Lego Mindstorms Launched

Micro:bit Commando Jump Using MakeCode

The BBC Micro:bit Is An Mbed Device In C/C++ 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


JetBrains AI Assistant - A Welcome Time Saver
28/02/2024

JetBrains AI Assistant saves developers up to eight hours per week and they appreciate its help.  77% of users feel more productive, 75% express that they are happier with their IDE experien [ ... ]



Pi Day - The Great Unanswered Questions
14/03/2024

It's Pi day again, again, again... Even after so many, I still have things to say about this most intriguing number. The most important things about Pi is that it is irrational and one of the few tran [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 01 October 2018 )