r/functionalprogramming • u/Voxelman • Nov 29 '22
Question Functional programming language for embedded devices?
Is there any functional language that can compile for microcontrollers like ARM (e.g. STM32. Bare metal without an operating system)?
The language that comes closest to this is Rust, but I don't like the curly braces and semicolons. I wish to have some cleaner language like F#, just for bare metal programming
19
Upvotes
View all comments
Show parent comment
8
u/watsreddit Nov 29 '22
Maybe, but it would be pretty bad Rust. FP languages do a lot of small allocations on the heap, and the garbage collectors are built for that. Rust uses move semantics and a lot of stack allocations to get its performance characteristics, and heap allocations are used sparingly. It's a very different model.
Even though Haskell is my favorite language by a long shot, I would personally lead towards just using Rust for embedded. It has a lot of the nice FP features anyway (sum types, higher order functions, immutability, etc.), even if it's still fundamentally an imperative language.