3 ms·
Tons of toy compilers are written in functional languages. Standard ML or ocaml are probably the first thing that grad students would reach for when developing
by UncleMeat 6y ago
Tons of toy compilers are written in functional languages. Standard ML or ocaml are probably the first thing that grad students would reach for when developing a compiler from scratch that isn't intended for production purposes.
However, in the real world everybody is using GCC/LLVM because they have rich open source communities and your work might actually get used by humans. LLVM in particular is nicely architected to be easily extensible so you can focus on just the compiler feature you want rather than bothering with all the other stuff needed around it. So then you are bound to the architectural decisions of these platforms. GCC in particular is a bit of a spaghetti mess and was designed long before pure functional design was trendy so you just sort of need to live with it.
Immutable IR is also a big challenge since the IR tends to actually be quite large. Making copies of it is sloooow.
- g_delgado14 6y ago> in the real world everybody is using GCC/LLVM Wasn't Rust bootstrapped with OCaml? I'm sure there are additional popular(ish) languages (i.e. Elm and PureScript) that are compiled with pure FP languages.
- zanellato19 6y agoIt was, but it produced LLVM IR from the beginning, iirc