r/functionalprogramming • u/Voxelman • Jul 16 '24
Question Which functional language for Raspberry Pi?
Which functional programming language is best suited for Raspberry Pi (3..5) in terms of memory consumption and performance?
It should definitely be a statically typed language from the ML family.
10
Upvotes
7
u/Bavoon Jul 17 '24
This likely isn’t what you’re considering primarily, but you might also be interested in Elixir and the “Nerves” project.
It gives a very nice toolchain to boot a minimal Linux and language VM, then you have a system for running a high level language that can still interface with everything low-level. Including things like over the air (signed) updates.
3
u/pthierry Jul 16 '24
Roc is not very mature yet but it is designed to be very efficient while still safe thanks to static typing. It might be perfect for your use case, but I don't know if they already target Pi's CPU.
7
u/epfahl Jul 17 '24
Rust is at least inspired by the ML family, it’s statically typed, but it’s not strictly functional.
16
u/yawaramin Jul 17 '24
It's got to be OCaml, no? The runtime is small and efficient, iteration speed is fast (speedy compiler), and reasonable selection of packages. And obviously an ML-family statically typed FPL.
11
u/ganjaptics Jul 16 '24
Statically typed language from the ML family means Ocaml, F#, or Standard ML. Hardware doesn't matter since all run on rpi just fine. Take your pick.
7
u/pthierry Jul 16 '24
Haskell tends to produce pretty efficient code as runtime goes.
Developing with it can be quite memory hungry if you work on a big enough project with the HLS running, but I'm not sure how compiling an existing project on Pi would fit or not.
2
u/nrnrnr Jul 17 '24
I use Moscow ML on a Raspberry Pi 3. It’s stretching things a bit. You might be better off with
ocamlopt, if the Arm back end is good (which I don’t know).MLton gives great performance but is very slow to compile on the Pi. Good supplement to Moscow once your code is stable, though.
2
u/[deleted] Jul 17 '24
I believe if you cross-compiling to run the code on Pi, most static type language are suitable since the type information mostly thrown away (no need runtime type check as in dynamic type language)
But if you mean do programming on Pi, I have no idea.
3
u/[deleted] Jul 16 '24
tbh for performance reasons im tempted to say rust. obv not purely functional but statically typed and ml family, and you can write it purely functional if you want quite easily and squeeze out substantially more performance than anything garbage collected most of the time