Categories
Computing

Sharing my work

I’ve got to a place with my Yarg-Lang project that I want to start talking about it with others.

Categories
Computing

Yarg-Lang: A Microcontroller Language Project

After some initial experiments, I’m putting a lot of time into a project that I hope to develop into a practical language. Yarg-Lang is an attempt to create a dynamic language that explicitly targets microcontrollers.

I find microcontroller software development both satisfying and frustrating by equal measure. Satisfying in that there is often a direct connection to a problem someone needs solving, and frustrating because the technology can sometimes feel surprisingly archaic or limited. Much of my software is written in C, which I feel show’s it’s age when I have to think about starting a project in it. I often find there is a lot of boilerplate that more recent languages allow me to skip. More recently, I also have used Micropython (or CircuitPython). It is very rewarding to iterate in a dynamic language, and one that takes care of some tasks for me, like memory management.

On the other hand, MicroPython can feel like a bit of a tease – when I want to re-use some python library, it may depend on features not present in Micropython, or use algorithms that assume they will run on a general purpose computer with many orders of magnitude more memory and CPU power. Sometimes the practical next step (deploying conveniently, or adding some particular hardware) needs work in C, and knowledge of the low level details of the python implementation.

It was an ‘aha’ moment to realise that a recent microcontroller has more than enough RAM and CPU cycles to spend a few on tasks like interpreting code and running a garbage collector. Something like the RP2040 has a ~100Mhz 32bit ARM, and over 250K of RAM, and can be sold on a $4 development board. It seems reasonable to expend some of those resources supporting the software applying itself to the problem at hand.

Yarg-lang is an attempt to explore a set of questions: What if there was a dynamic language that was specialised for Microprocessors? Could it support hardware directly in the language, without needing C extensions, or knowledge of the language implementation? Could it develop an ecosystem of libraries that sit well on smaller systems? Could it support language features like coroutines and memory management on a microprocessor device?

This feels like the start of an interesting journey!

Categories
Computing

Current Project: Microcontroller Language

I’m putting a lot of time into learning and experimenting with languages for Microcontrollers. I’m ‘between jobs’ at the moment, and this seems like an interesting technical space to explore with the available time. I read ‘Crafting Interpreters‘ over the Christmas holidays, and was inspired to see if I could get the language running on a microcontroller. I’ve also experimented a few times recently with Raspberry Pi Pico’s, and I have been struck by how powerful they are, and how pleasant it is to program them in a dynamic language.

What you see here is a Raspberry Pi Pico wired up to a 4Tronix Led Cube. Power is supplied by a 2.5A Raspberry Pi USB adapter.

The software is an interpreted language based on ‘Lox’ from Crafting Interpreters. I’ve extended the bytecode vm, the compiler and so on to enable access to the gpio pins on the Pico. I’ve ‘hard coded’ a PIO image in to drive the WS2812 leds on a GPIO pin.

The 4Tronix Cube supplies a 40-pin connector for the ‘classic’ Raspberry Pi computers (I started experiments with this using a Pi Zero). This is jumpered across to power the Pico, and connect the ‘WS2812’ LED string to GPIO 18. The breadboard hosts a zener diode in the power line (so you can plug in USB to the Pico without issue), and a reset button for the pico.

I’m calling my language Yarg (for now), after the Cornish cheese. It seems a nice small name, and food related like Lox. I enjoy the cheese!