views:

1181

answers:

8

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!

+1  A: 

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...

Gordon Guthrie
The github.com/dgud/esdl/tree/master library is used in wings3d, but the author recommends using wxerlang to get to opengl.
Christian
+1  A: 

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.

varzan
Even though GOAL was a Lisp, I don't think it was very functional. All the code samples look imperative and somewhere I remember reading about how they managed memory manually because the GOAL garbage collector was too slow. (However, the article does summarise many other advantages of Lisp--macros, runtime evaluation, etc.)
Nathan Sanders
Another game that used Lisp was "Abuse", which is now public domain. Though, again, probably not the most functional use of Lisp.
Ken
Lisp is not that much of a pure 'functional programming language' anyway. Usually it is multi-paradigm and supports the inclusion of many other paradigms (logic, rules, relational, constraints, agents, ...). So any real Lisp program will happily mix imperative, functional, object-oriented and other programming styles.
Rainer Joswig
I actually did read this article, long ago, so long that I've forgotten what it was all about :)
Irwin1138
+11  A: 

Well, you could do worse than studying the code 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.

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

[edit: There's also the Clean language with it's game library and nice screenshots].

Simon Michael
Thanks, this is exactly what I was looking for.
Irwin1138
+3  A: 

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.

mattnewport
+1  A: 

Try this Casting SPELs

Gutzofter
+5  A: 

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.

Andrew Calleja
+3  A: 

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:

ThomasH
I'm sorry for the outline links, but all my attempts to have them inline failed: While the edit preview always looked just fine, as soon as I posted single links streched over multiple lines or showed up as half-baked HTML href's :-(
ThomasH
that last link seems to have confused the hell out of the parser. hopefully i didn't screw it up that bad by not referencing the web archives.
nlucaroni
Thanks for the edit help. Your alternative devmaster.net link looks exactly like the original blog post, so that's even better than the web archive. Hope there will be suitable alternatives the next time the parser chokes ;-). (Shouldn't somebody raise this on meta?!).
ThomasH
Maybe you could have just used tinyurl or something like that :)
Irwin1138
@Irwin Right you are, and that's what I'm going to do next time. I was just too baffled, esp. since the editor preview looked fine every time, that I thought it was me doing something wrong. Now that I was over at meta I learned that it "works as designed". Hope they enhance the editing process so that others won't hit the same issue all over again, but use tinyurl right away :-).
ThomasH
+3  A: 

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.

hiena