Jump to content
  • Advertisement
Sign in to follow this  
klrr

Unity Functional reactive programming?

This topic is 2145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I recently started writing a game using the Reactive-banana FRP library for Haskell. I realized that there actually exist FRP libraries for several mainstream languages, so I thought I might ask here and see what the perception of this fairly new paradigm is.[1,2,3]

 

Okey, for those who are unfamiliar Functional Reactive Programming is a new programming paradigm invented at Microsoft Research in late 90s. It initially was meant for animation (hence, the first paper was named "Functional Reactive Animation"[4]) but has been used for games, robots, audio, GUI, etc. Essentially it introduce time-varying values called events and behaviours(also called "signals"). Events are discrete time-varying values and behaviours are the continious equaliant. For example, an event could represent a mouse click and a behaviour could represent the position of a moving ship. The difference between these and mutable data or impure function calls is that you decleare its properties when you define the event/behaviour. You do not later mutate it and when its being called its not mutating anything(except for some primitives that needs to be hooked into the pure network of events and behaviours).

 

So this lets you declaritivly define games, which is awesome. It makes everything much easier than having to mutate some state or pass state around(as you would have to do in functional languages). I want to ask what this community's opinion is on this new paradigm is? I personally think its really good but I just got started, and my experience in game development is not that big so I don't have much to compare to. I only know of two companies who uses FRP, so it's still a young paradigm.[5,6] Also, feel free to ask me any questions too!

 

1. C++ FRP library https://github.com/kentuckyfriedtakahe/sodium/tree/master/c%2B%2B

2. Java FRP library https://github.com/kentuckyfriedtakahe/sodium/tree/master/java

3. JS FRP library https://github.com/baconjs/bacon.js

4. First FRP paper http://conal.net/papers/icfp97/

5. Mobile game development company using FRP http://ipwnstudios.com/

6. Web presentation software company using FRP http://prezi.com/

Share this post


Link to post
Share on other sites
Advertisement

Functional reactive programming is a good idea. But in fact it is very similar to MVVM , and I guess it is a more popular term used in game industry? I found several MVVM library for Unity. However, I have no idea about the adoption of this design paradigm in the industry. 

 

Share this post


Link to post
Share on other sites

I've been learning the FRP paradigm in Scala.  It's tremendously appealing to me both to my sense of "cleanliness" and as an intellectual puzzle.  Naturally my thoughts have turned to it's applicability to C++ game programming.

 

Since I started, I've begun to use "const" more then ever and taking better advantage of functional composition that's helped me solve some previously tough problems (RPG spell effect system in particular).

 

It would be interesting to apply the paradigm to large scale systems, but I'm very worried about the runtime cost of many small memory allocs and frees necessary to maintain data structure immutability.  C++11 move semantics and/or careful application of (mutable) memory pools may help amoritize it somewhat but that feels too much like I'm fighting the language rather than working with it.

 

My current experiment is with using immutable, overservable, memory pooled data streams (based on RxCPP) for marshalling data across systems in batches.  The results are promising so far, but has a long way to go before production use.

Edited by xenobrain

Share this post


Link to post
Share on other sites


I want to ask what this community's opinion is on this new paradigm is?
After reading the (scarcely informative) links I've googled I'm afraid I don't really get the whole point. The PDF is probably what I'm looking for. It doesn't seem to be something I want to quickly skim over. Considering the paper was awarded "most influential in '97" and the small amount of links found, I'm not inclined to invest much time on it.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!