Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>FRP is a very general technique and could almost certainly be used to implement anything that would normally use events. In the classical rendition of FRP, one of the core abstractions <em>is</em> the event. The difference is that instead of operating on events individually with callbacks, you operate on <em>streams</em> of events. </p> <p>You should be able to render any normal event-driven code in terms of streams of events; the only difficulty would be in binding your streams with existing, external code like a GUI toolkit; however, this is more tedious than tricky. So I don't see any fundamental issue preventing you from using FRP anywhere you would use events in a different language.</p> <p>In fact, I've had some good experiences using FRP for exactly what you call "lighter": simple GUI programs. I've used <a href="http://www.haskell.org/haskellwiki/Reactive-banana" rel="noreferrer">reactive banana</a> with wxWidgets to write some very simple little graphical programs. I found the resulting code to be much simpler, easier to write and easier to read than the equivalent callback-based code would have been.</p> <p>Reactive Banana can also be used for things like <a href="http://www.haskell.org/haskellwiki/Reactive-balsa" rel="noreferrer">music</a>, so it's clearly widely applicable. I haven't tried anything except GUI programming with it, but others have so it has to be possible.</p> <p>Additionally, you should check out Elm which is an ML-style language for implementing web apps with FRP. It generates everything you need: HTML, CSS <em>and</em> JavaScript. I believe it even handles communication with the server. I haven't tried it, but it looks very nice.</p> <p>So, people are clearly using FRP in a wide variety of domains, including ones that aren't "heavy". But this does not mean you should use it everywhere!</p> <p>For one, it is possible to get unpredictable space and time behavior. I know that the creators of both Reactive Banana and Elm put a lot of effort into reducing these, but I suspect there is still some risk. I know I had some very odd space leaks when playing around with Reactive Banana WX, so it's certainly something to look out for. It might be harder to deal with these with FRP than with event-drive code you're used to working with. Of course, I've had inexplicable memory leaks with standard JavaScript, so non-FRP code isn't immune to this either!</p> <p>Another consideration is that FRP may not be the best or clearest abstraction for your particular task. While it's great for things that have to be fully reactive, what about code that is very simple, like a web server? (I mean simple as in different requests probably do not interact too closely with each other.) I imagine having a web framework that handled large amounts of requests using a programming model based on FRP would be possible; I just don't think it would be <em>optimal</em>. </p> <p>In fact, my understanding is that the GHC IO system is actually already event-driven under the hood, so you can write web servers in a standard programming style and get the benefits of using events for free. So, for web server code, a simpler underlying abstraction may be a better choice. I believe that's what existing frameworks like Snap and Yesod do--neither uses a reactive programming style, but both are still pleasant to use.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload