Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I was discussing F# and Functional Programming with a friend last night and he brought up an interesting question to me. How would you do embedded software in functional? I mean this seems like a fairly natural fit in terms of stateless code but embedded also entails being very frugal with memory and I'm not sure of the story for functional in that regard.

Any suggestions about languages or packages for embedded with functional?

share|improve this question
This link could help you ftp.cs.york.ac.uk/pub/malcolm/thesis.html. Download the postscript file and read it. –  Ubermensch Mar 2 '12 at 14:07
@Ubermensch thanks but I'm getting an error when I try to access that link. –  Onorio Catenacci Mar 2 '12 at 14:27
Please take a look at this SO question. It appears to be very closely realted to what you've asked. And this page dealing with programming the Arduino with Haskell.Atom –  Bhargav Bhat Mar 2 '12 at 15:28
@BhargavBhat thank you. –  Onorio Catenacci Mar 2 '12 at 15:29
You may also be interested in reading Using Haskell for sizable real-time systems: how (if?)? –  Mark Booth Mar 5 '12 at 12:16
show 2 more comments

3 Answers

up vote 2 down vote accepted

Forth is an excellent choice for embedded systems programming. Being a stack language, it can be analysed in terms of function composition (concatenative programming). I see no reason why such a language with more functional aspects could not also be implemented efficiently, but as yet no such thing (to my knowledge) exists.

share|improve this answer
Concatenative programming is a very different paradigm to Functional programming, but there is a functional forth (funforth) which implements some simplified aspects of the Haskell functional language language. –  Mark Booth Mar 5 '12 at 12:14
@MarkBooth: Not so different; concatenative programming (pretty much by definition) makes heavy use of higher-order combinators, and many functional concepts translate directly into concatenative code. –  Jon Purdy Mar 6 '12 at 19:09
add comment

One option is Erlang. From the wikipedia page:

Erlang is a general-purpose concurrent, garbage-collected programming language and runtime system. The sequential subset of Erlang is a functional language, with strict evaluation, single assignment, and dynamic typing. For concurrency it follows the Actor model. It was designed by Ericsson to support distributed, fault-tolerant, soft-real-time, non-stop applications. It supports hot swapping, so that code can be changed without stopping a system.

While threads are considered to be a complicated and error-prone topic in most languages, Erlang provides language-level features for creating and managing processes with the aim of simplifying concurrent programming. Though all concurrency is explicit in Erlang, processes communicate using message passing instead of shared variables, which removes the need for locks.

The first version was developed by Joe Armstrong in 1986.2 It was originally a proprietary language within Ericsson, but was released as open source in 1998.

share|improve this answer
add comment

Scala and clojure have both been used on android. See http://blip.tv/clojure/daniel-solano-g%C3%B3mez-clojure-and-android-5953832

share|improve this answer
Used on Android true but were they used on embedded android? It's not a trivial difference. –  Onorio Catenacci Mar 2 '12 at 20:30
I depends on what you mean by embedded. They've run it on phones. Startup time is really bad for clojure, but that's because they're compiling everything on demand. Scala works pretty well I think. Some overhead over plain java, but that's to be expected. –  maxpolun Mar 2 '12 at 20:35
I didn't even think clojure could be compiled to Dalvik byte code--thought the dynamic typing presented some sort of issue. –  Onorio Catenacci Mar 2 '12 at 20:39
Go take a look at the talk I linked to, they got it working, it was just very slow to startup. –  maxpolun Mar 7 '12 at 4:05
It looks like That Blip has sailed (404 on the page you linked to). –  Mark Booth Apr 11 '13 at 9:41
show 1 more comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.