Using Functional Programming for Game Development - Intro

Long time no see

Hi everyone! Haven't posted in a long while.
I've been quite busy working on side projects that regard ShaderCat, which I'll unveil when they're ready.

Meanwhile I brought my "Building a Graphical IDE in Elm/Purescript" talk to a bunch of conferences (Erlang User Conference, Codemesh, LambdaDays, Elixirconf EU) and I've been getting used to the Purescript/Haskell way of doing things.

I've been meaning to post about my longtime exploration in using FP for games for a while, but people asking me about games and FP at Elixirconf EU finally prompted me to start.

Evaluating FP for Game Development

The main issue is, you need to define your objective.

If you want to do game jams, there are multiple viable options already. If you want to make a commercial 2d game, that's also doable. If you want to do a commercial 3d game, you might not find it easy, and it may require painfully wrapping many OOP libraries.

I've been doing realistic 3d games for mobile devices professionally in the past, and my bar is possibly higher than most people.

Mobile devices are not that powerful, and they're awkward to deploy on. Making realistic looking 3d games on them can be quite difficult, even using ready-made engines, with entire teams of people dedicated to make "compile to iOS" not terribly awkward. An even trickier application which I care about, is targeting consoles. While they are generally less limited than mobile devices, they can make life quite hard for people using non-standard tech.

Even if you only care about making the occasional game jam game, if you'd like eventually to get an FP gamedev job, the ecosystem will need to be mature enough for people to be able to make money with the games they make. They need to be competitive.

Naughty Dog

If you play Playstation games you'll likely have heard of Naughty Dog. Not enough people know that Crash Bandicoot and the Jak & Dexter series were written in custom made LISPs, which compiled to the current Playstation. But they weren't Functional. They were more like a very smart assembly with great interactive dev capabilities.

So, sadly, I can't chalk up that as a win for FP, but I can chalk it up as a win for Lisp ;)

Next up

So what I'll do is, list the options, my experience with them, and what I think they're good for at the moment. Every language is Turing complete, they can all potentially be used for games, but the obstacles are mainly in the ecosystem.

The languages I have in mind at the moment are:

  • F# (some commercial use)
  • Clojure (mainly game jams)
  • LambdaCube3D (focused on rendering)
  • Haskell (some commercial use)
  • Elm (mainly game jams)
  • Purescript (mainly game jams)
  • Scheme
  • BEAM languages (Erlang, Elixir, etc)

If you think another language is worth a post, feel free to ping me on twitter @doppioslash or @lambda_cat.

In the next post, I'll regale you with lost tales of F# deploying on Playstation Vita.