HACKER Q&A
📣 Eugeleo

Elm, PureScript, or ReasonML for a FP course?


Beginning this March, I'll lead a new high-school functional programming course, consisting mostly of writing simple 2D games. I can't decide which of these three languages would be best suited for it. Does anybody have experience with any of them? What did you like? What did you not? What should I use?

The students are a bunch of talented high-schoolers, however they only picked up programming this September. That means good tooling and a friendly compiler are paramount, because they'll often be leaning on both.

I don't have experience with any of the languages, but I write Haskell and Typescript for living, so I should be able pick these up rather quickly. Because I know Haskell so well, I lean towards PureScript, but I don't want to base my decision only on this.


  👤 aszen Accepted Answer ✓
I have experience with elm, and since you are teaching students I would suggest you to go with it.

There is no beating it's compiler for error messages, tooling and extensive beginner friendliness.

Elm is how I learned functional programming and to build 2D games there are many libraries to choose from, you can use the simplest one of them created by the elm author himself

Elm playground https://package.elm-lang.org/packages/evancz/elm-playground/...

Speaking of typeclasses not being in elm, I think one can appreciate them better when the things they provide have to be manually written.


👤 kinow
There were some similar questions on r/functionalprogramming subreddit. Maybe there's something useful there? Search for "teach" or "class" I think, e.g.

- "How would you teach a group of 9th graders functional programming?" https://old.reddit.com/r/functionalprogramming/comments/avcr...

- "I want to teach programming via functional paradigm to someone with no background" https://old.reddit.com/r/functionalprogramming/comments/egzz...


👤 WorldMaker
Is the aim to teach functional programming as a paradigm or specifically "functional programming languages"? For High School, I would assume the first may be more important than the latter, and you may have good benefit from teaching FP as a paradigm in a language they are taught elsewhere or might have other reasons to use. You can spend less time teaching syntax and more time focused on patterns/practices.

Which is to say, maybe start out in Typescript itself? There are a lot of great more functional paradigm-focused libraries out there in "Fantasy Land" [1] and "Static Land" [2].

A benefit to starting in Typescript as well would be that you could move to Elm or PureScript if there is time/interest and reuse many of the same libraries and/or even some of the earlier TS code/projects.

It obviously seems like a trade-off that using a language that isn't "strict" or "native" to the functional paradigm, students might be tempted to avoid learning the functional paradigm and fall back to old habits. But on the other hand, that can still be a useful escape hatch to avoid frustration, especially with High School students who might have enough other stuff on their plates that some leniency might be handy/warranted (and for High Schoolers they shouldn't have that many "old" habits to fall back on anyway). It could be good teaching praxis to start with "Why did you fall back to doing this imperatively/OO/what-have-you? Did you try X? What if you explore Y that we discussed in class?" You and the students might learn a lot from dialogs like that.

Just some thoughts. There's probably no "perfect" language, but sometimes the best language is the one people already know because that gets a lot of the basics out of the way and out of the focus.

[1] https://github.com/fantasyland/fantasy-land

[2] https://github.com/fantasyland/static-land


👤 amw-zero
I’m a big fan of ReasonML. It’s the best combination of practicality and conceptual ideology. Yes, it’s functional, and encourages you to write pure logic that operates on values. But it also allows you to mutate state when you want. The type inference is also incredible, though similar to Elm and PureScript.