New book on functional programming and games

Full disclaimer: I am an author of the book in question!

I have just finished writing a book about learning to program in F# with game development. I have gathered half a decade of teaching and development experience with functional programming and games. The main subject of the book is the F# language and its various constructs, but every single chapter is centered around a game-related problem. Each one of the first 5 chapters describes a problem, shows and discusses its solution and then discusses in depth the F# constructs used. The book has a (relatively rare) "problem-solution" approach where everything is explained because of how well it works in solving the problem, and not just "because". The 5 problems we present are:
- a bouncing ball
- the Saturn V rocket
- an asteroid field
- a large asteroid field optimized with quad trees
- a police starship that must fight off a pirate ship attacking a
cargo freighter
In the last two chapters we use XNA to build a 2D and 3D renderer for two of the samples we have seen. We show the basics of the SpriteBatch class, the Model class, input management and audio with this powerful framework. Basically, we cover the most important aspects of XNA in a simple and succint way.

The samples are all stored at:

The book is relatively short and cheap, and can be found here
or here

I will use this book as my textbook for my next course in game development at Università degli Studi di Verona and for my next course in functional programming at Università Ca' Foscari di Venezia.

I hope the book can be of interest for some people here; furthermore, I am more than willing (send me an email at giuseppemag AT gmail DOT com) to send a free copy of the book to any instructors who are interested in using it in the classroom!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

sounds good to me,

more power to you! i shall endeavour to read it.


I was hoping for some feedback here on LtU :)

I am wondering if anyone likes this approach, since I have always felt that there is a large gap in very deliberately "fun" applications of functional programming. Please let me know what you think!

i've been meaning to do more fp in my games


like an old favourite example of mine, asteroids in cal.

also, there's a set of slides i can't find, from somebody who was doing games on the ps3 where they noted caches are screwed by oo, and happier with fp.


Naughty dog started with fp,

Naughty dog started with fp, then changed to OO and then changed back to fp again because it worked better for them too.

Where did you get those slides? if possible to know.

Best regards,

When I was an undergrad

When I was an undergrad (~1992), I remember a successful game company recruiting at UW that did most of their work in Lisp. Sounds like ND, but that might have been more common back then.

That probably was and is (?)

That probably was and is (?) quite common. But, in the history of computer games, there may be only one whose retail packaging boasted that it contained the power of LISP.

maybe found them

care of google and reddit: pitfalls of oop.



there is another book using this approach but using Common Lisp "Barski - Learn to program in Lisp one game at a time". I havent read it but for the reviews it seems like the approach worked just fine.
I haven't had any contact with fp but if I were to read a book on fp -besides basic- it would have to include topics like:

- Packages for (or whatever uses the system to import)

- GUIs
- Network
- Games
- Low-level capabilities -if possible-

well, hope this helps, probably not, but who knows.

Best of lucks,

Credit where credit is due

Of course, this book is not the first time FP is used in conjunction with games: Matthias Felleisen ( has done this for years and very brilliantly.

As we discussed in a private conversation yesterday, even though he has gone along this road already, he complimented for the sophistication of the examples presented.

I just thought it would be fair to remark this!

Also, is a presentation of the book inappropriate for the front page? Who should I ask?

If any contributing editor

If any contributing editor have looked at the book (I, alas, am way too busy), and wants to post about it, they of course can.



I wanted to notify whoever may be interested that we have just added a (free) set of slides about the book. The slides do not require the book and contain a lot of stuff that is also in the books, and we are going to use them in our next semester courses in game development (Verona) and functional programming (Venezia).

The slides can be found at

We hope someone finds them useful or interesting, and if anyone has any notes or corrections to improve the work then please tell us :)