Atom is an open source language, embedded in Haskell, for writing embedded real-time software. It was originally designed and deployed at Eaton Corporation to improve development times and ease of verification of hydraulic hybrid systems in buses and trucks. It has been open sourced, and is starting to be used for other embedded systems programming tasks.
Atom uses ideas from conditional term rewriting to compile atomic transition rules into C code with guarantees of constant memory use and execution time.
The productivity benefits were impressive from April 2009:
- 5K lines of Haskell/atom replaced 120K lines of matlab, simulink,
and visual basic.
- 2 months to port simulink design to atom. – 3K lines of atom generates 22K lines of embedded C.
- Rules with execution periods from 1ms to 10s all scheduled at
compile time to a 1 ms main loop.
- Atom design clears electronic/sw testing on first pass.
- Currently in vehicle testing with no major issues.
Atom compiles Haskell source to C (so you can use it for writing regular old C programs). Here’s an example Atom kernel by Lee Pike:
atom "computeFib" $ do cond $ value runFib cond $ value i >. 0 decr i snd <== (value fst) + (value snd) fst <== value snd
Examples are included in the Atom source.
It is available for Arch Linux:
- yaourt haskell-atom
Resources for Atom Programming
- Tom’s CUFP talk about Atom (PDF slides)
- An Atomic Fibonacci Server (generating C from Atom)
- Programming the Arduino with Atom: Part 1
- Programming the Arduino with Atom: Part 2