Good resources on using functional programming in game development?

Viewed 7234

I'm quite new to that functional programming paradigm, but so far I like it. Since I'm into game development, I want to try it out in writing some games in purely functional programming style. I don't mind the language - be it Erlang, Haskell, Lisp, or even Ruby (I found out it supports functional programming traits).

Well, it is obvious that to learn functional programming (in fact, anything) the best advice would be just to learn functional language and program a lot in it. But what I'm looking for are some resources on using functional programming in games and game engines (2D or 3D).

So, do you know of any functional programming articles/books/blogs/whatever about using it in actual games, or designing simple game engines with functional programming languages, and all the interaction between the game and game engine in this functional environment?

Please, don't suggest something like "just start programming simple stuff in functional and gradually it will come to you". As I said earlier, it is obvious, but what I'm asking here are some resources on the topic, if there any. Thanks!

9 Answers

Well, you could do worse than studying the code of some of these haskell games.

Some of these use FRP (functional reactive programming), which some people are working on as a pure, high-level technique for games and other things. But most are a typical haskellish mixture of effectful and pure functional code.

Bloggers with relevant content include James Hague.

Note FunGEn at the first link - though not actively maintained it is a 2D game engine with working examples.

There's also the Clean language with it's game library and nice screenshots.

Well I am mostly a Haskell programmer so I can only suggest to try Haskell libraries such as Gtk2hs. Its mostly for 2D applications and for user interfaces but its good to get you started :) An even easier library is HGL but its slightly bugged and outdated. If you want to try out messier (but cooler!) stuff then go for Haskell's OpenGL library which can be found here. I never tried working with Haskell and OpenGL but if you check out the answer submitted by Simon Michael there are example games in Hackage's Game Section which use OpenGL.

Sorry about not linking all the libraries but I'm a new user and I'm not allowed more than one hyperlink. If you google them they should come up easily though.

If you are interested in the networked side of games, Joel Reymont has written about his experiences coding up an online Poker server. I think he did at least three different implementations (Lisp, Erlang, Haskell). Unfortunately, his material is scattered across the Internet. Here are two pointers you might find useful:

EDIT:

Here are some follow-up pointers and links from the above documents that have changed.

EDIT II:

Joel has apparently sold his poker code since, hence it is no longer available as open source.

A little dated, but this is the first in a series of posts on how to use F# with the XNA game development framework. You might also find the blog F# for Game Development has some useful material.

Frag is a 3D first person shooting game written in Haskell, by Mun Hon Cheong. It is licensed under the GPL. The design and implementation of Frag is described in Mun's undergraduate thesis, Functional Programming and 3D Games.

Wings3D is the Erlang package that is used in to draw wireframe shapes. I think it is used in games, but that's not my bag...

Well, I'm not sure how much this helps, and you've probably heard of it already, but seems like an obvious start: here's an article on Jak and Daxter.

Related