Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is there any game engine using a functional programming language similar to Scheme, Common Lisp, Clojure or JavaScript?

I've tried Unity3D but their "JavaScript" is not actually JavaScript, is strongly typed and is not functional.

share|improve this question
2  
I'm using ThreeJS, but, while it's full of awesomeness, it's lack of an active community and documentation are a serious problem. –  Dokkat Dec 27 '12 at 10:39
5  
Why would you want to program in a functional programming language? What is the problem you are facing? Please be more specific. As it stands, this question is too general to yield one correct answer and it is prone to generate a list of (all equally "correct") answers like this: - How about Clojure combined with any Java game engine? - How about adopting a functional programming style in a language that is not functional per se? (Read Functional Programming in C++ by Carmack.) - etc. –  Eric Dec 27 '12 at 11:12
2  
Unity3D's Javascript is as functional as regular Javascript, you just need to use C# 4.0 types, something like: var add : Func<int, int, int> = ... –  fableal Dec 27 '12 at 12:34
2  
See the FAQ about "Which technology to use" questions. This question, as the answers show, is just generating a list. It's not constructive since there's no single correct answer (other than "Yes there is"). This isn't the place to compile lists. –  Byte56 Dec 27 '12 at 15:20
2  
This is sort of a "right tool for the right job" problem. Functional programming is strongly focused on minimizing, and eliminating wherever possible, mutable state. That may work well for certain classes of applications, but it's completely antithetical to the way just about any game works. –  Mason Wheeler Dec 27 '12 at 18:37
show 3 more comments

closed as not constructive by Byte56, Trevor Powell, bummzack, Josh Petrie, Tetrad Dec 28 '12 at 20:55

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

I don't have an answer to the question as written, but I believe you are possibly trying to ask "why aren't there more functional game engines" rather than looking for a specific one to use. If that's correct, you should rephrase the question. If not... ignore me. :)

A pure functional approach is not a good fit for games. Games (and graphics, and physics, and AI) and basically all about state changes. The correct functional approach to these problems would be to compute an entire new state once per loop, which will have a very severe performance penalty compared to coding more directly to how actual hardware works.

It is for that reason that you don't see any functional-style game engines in production. It is simply the wrong programming paradigm for the majority of problems a game engine is meant to solve. It is the wrong programming paradigm for the majority of problems that need to be solved in higher-level scripting and game logic code, too. While it is almost certainly possible to make a functional game engine, it would be slow, difficult and cumbersome to use, and would serve no real purpose other than being a neat demo/toy to show off.

That's not to say that functional programming doesn't have a place somewhere in games. I use a very functional style of coding (where appropriate) in C#, Unity JavaScript, and even C++11. Some very specific problems are best or at least most easily solved with a functional style, and most of the popular languages today support that form of programming, albeit in a more cumbersome manner than "real" functional languages. Usually these problems solved with functional approaches are not in the core engine code, nor in code that runs in the game itself. Functional coding can be quite beneficial for tools and offline data processing (baking models and other assets, for instance). It's also arguable that GPU programming is vaguely functional in how algorithms are written, even though the actual coding is done in a hardware-efficient procedural manner.

Of course it can still be best to avoid functional approaches outside very specific circumstances since you want these offline tools to be as fast as possible. Functional languages excel at parallelism, which is good for some problems, but the abstractions from the hardware tend to lead to very inefficient single-threaded performance. (Languages like LISP do well here because they are not pure functional, and in fact Common LISP is multi-paradigm.) The absolute single worst thing for a game engine or related toolkit is to be a bottleneck for content iteration. A fancy engine with a lot of features that takes artists or level designers hours to do what could be done in 5 minutes (or ideally, near-instantly) will just lead to low quality games or cancellation due to budget escalation.

share|improve this answer
    
See: Clean Game Library (Clean) and Nikki and the Robots (Haskell). –  Andres F. Apr 16 '13 at 17:07
    
This answer is mostly wrong and appears to be based on a very poor understanding of actual functional languages. –  C. A. McCann Apr 16 '13 at 17:29
    
Do you have any actual counter points? –  Sean Middleditch Apr 16 '13 at 18:34
2  
... How much experience do you have shipping industry-quality games in functional languages? If you have experience, share it. Make statements with explanations and justifications, not appeals to expertise or authority, or personal accusations. The likelihood of this kind of indignant arguing and personal bickering is exactly why this question was closed. –  Sean Middleditch Apr 16 '13 at 23:15
2  
You're putting words in my mouth. I'm not stating my experience level because your opinion of my expertise is utterly irrelevant to the topic. Don't claim you have no time to state facts while having time to attack personal skill levels. You probably have real corrections, but you need to state them. "That guy is wrong," is not valuable answer feedback for anyone. I can just claim that you are wrong, and then we have an endless and pointless cycle of bickering. Please say why an answer is wrong. –  Sean Middleditch Apr 17 '13 at 18:42
show 3 more comments

The Naugthy Dog company used List on its Game Engines and it was called Game Oriented Assembly Lisp.

Some information can be found here: http://en.wikipedia.org/wiki/Game_Oriented_Assembly_Lisp

Some code samples: http://web.archive.org/web/20070127022728/http://lists.midnightryder.com/pipermail/sweng-gamedev-midnightryder.com/2005-August/003804.html

It is not available for public usage.

share|improve this answer
    
If you look at Wikipedia's description, it quickly becomes apparent that GOAL was hardly a functional language, LISP ancestry notwithstanding. –  Mason Wheeler Dec 27 '12 at 18:35
add comment

There is LambdaCube which is written in Haskell (it's not exactly game engine but more like graphics engine).

share|improve this answer
1  
This might also be of interest to you (general comentary from Tim Sweeney from Epic) –  tumdum Dec 28 '12 at 10:17
    
Interesting link, there's a ppt here –  bobobobo Jul 5 '13 at 4:49
add comment

You can always use f# or iron python (yes i do know, python isn't functional) or any other .netified language with XNA on .net platform.

http://fsharpgamedev.codeplex.com/ http://www.ironpython.info/index.php/XNA_Example_with_a_Bouncing_Sprite

edit: One more engine, written in Lisp: http://code.google.com/p/blackthorn-engine/

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.