Haskell for micro controllers

I wrote a little rant on my employers blog the other day, lamenting the need to develop embedded applications in C or C++. I've written C and C++ professionally, and I'm not planning to do it again, unless it's directly towards the goal of not writing C in some new problem domain in the future. I've done some Arduino programming recently, and it amazes me how painful it is.

I looked at loads of options for embedded development, specifically targeting some cheap ARM based boards: the STM32 Discovery line. eLua looked OK, and there's Espurino, but neither are up to the task of handling interrupts, and hence writing drivers. If the drivers don't exist for your platform, or you need to extend them, your back to C. Also, a lot of interpreted systems use precious RAM to store programs, when they should be in ROM, which tends to be more plentiful.

I should say that eLua does have an interrupt handling mechanism, but it's not all that fast, and throws interrupts away when it doesn't keep up. This might not be a problem in reality, so I may yet come back to eLua. I specifically bought a board it supports: the STM32F407 discovery. eLua can also execute byte code directly from Flash - another big plus.

A better answer might lie in a compiled language, however. D, Rust, and OCAML all seem like possibilities, but the language de jure seems to be Haskell. Once you know that, all kinds of things show up. This strikes me as odd, because Haskell is lazy, and this means it's not terribly memory efficient. Anyway, I can see what makes it easier to use Haskell: it has an excellent optimising compiler which generates C, so it's easy to use existing embedded tool chains to produce executables. It's also good at domain specific languages, and I'd begun to wonder if the best way to handle interrupts was using a restricted set of an existing programming language, perhaps one that was easy to compile to C, and didn't allow dynamic allocation, for example.

The trouble is, I don't know Haskell, and Haskell is a big investment. Still, it sounds like it's a useful language to have learned, even if you don't use it.

Here are a few things I found using Haskell running on micro controllers:

  • SMACCMPilot is a software platform for UAVs. I find this one particularly interesting, because it's based on two DSLs, one of which is for low level programming - i.e. interrupt handling.
  • AJHC is a branch of an experimental Haskell compiler which targets arm cortex boards.
  • Copilot

So in fact, it's mostly not Haskell but DSLs that require you know Haskell, and which are possibly eager. Which may mean all my questions will be answered, once I know Haskell.

Popular posts from this blog

3D Printer ramblings

Balance Bot V2

Robot arm