FRP on a game engine. Is it worth it?

frarees picture frarees · Nov 30, 2011 · Viewed 8k times · Source

Today, I've read about FRP (functional reactive programming). However, I don't know how much this fits in the engine itself.

After reading Gerold Meisinger's article, my question is, if it's worth it to use FRP instead of a component-based architecture. Is this the near future of game engine architecture design? It's just a simple approach on solving small problems component-based architectures do? I'd appreciate any article, explanation, personal opinion, etc.

Think about an engine for a commercial game, specially shooters or racing genres (3D games). Don't think about a 2D platformer or other simpler (talking about engine complexity) ones. I'd use C/C++ (I noticed people using FRP rely on Haskell, due to its nature. However, I saw this document and prefer to stand on C++, as the "industry standard").

Answer

Paul Manta picture Paul Manta · Nov 30, 2011

C++ isn't naturally suited for FRP; any libraries you use (Boost.Phoenix is a good one) will carry some overhead that you most likely don't want to deal with in a commercial 3D game.

Not only that, but FRP isn't a very well developed technique for games, not even in Haskell, afaik; do you want to make a game or do you want to develop a technique for making games?

Component-based entity systems have been around for quite a while and are a proven concept. They do have their limitations, most notably, how do components communicate with each other? — one solution is to have two types of components, attributes and behaviours; the latter can access any attribute, but they cannot access each other.

If you want to make a game, go with CBS. If you want to help develop FRP in games, then do that.

Btw, you're so very wrong to say that 2D games have simple engines. :)


2014 Update

A new language has since appeared that make extensive use of functional reactive techniques and is aimed at web development, called Elm. It is very similar to Haskell and is supported by Prezi, afaik. The language designer had a pretty good presentation in which he made a small game using FRP. Anyone interested in how FRP should be handled might want to look at that video.