<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stian Veum Møllersen on Medium]]></title>
        <description><![CDATA[Stories by Stian Veum Møllersen on Medium]]></description>
        <link>https://medium.com/@mollerse?source=rss-e9afd5c4233c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*iod-yxO02VDisPHh.png</url>
            <title>Stories by Stian Veum Møllersen on Medium</title>
            <link>https://medium.com/@mollerse?source=rss-e9afd5c4233c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:12:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mollerse/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Event Driven and Functional Reactive Programming, Step by Step.]]></title>
            <link>https://blogg.bekk.no/event-driven-and-functional-reactive-programming-step-by-step-babbd8364150?source=rss-e9afd5c4233c------2</link>
            <guid isPermaLink="false">https://medium.com/p/babbd8364150</guid>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Stian Veum Møllersen]]></dc:creator>
            <pubDate>Tue, 15 Oct 2013 00:00:00 GMT</pubDate>
            <atom:updated>2017-10-30T13:53:42.700Z</atom:updated>
            <content:encoded><![CDATA[<h4>The aim of this blogpost is to explore the differences between Event Driven Programming and Functional Reactive Programming(FRP) by implementing the same set of functionality with both techinques. I will walk through the two implementations step by step explaining the process as I go along.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VwgFkgEmPxjl_MAg." /></figure><h3>Event Driven and Functional Reactive Programming, Step by Step.</h3><p>The aim of this blogpost is to explore the differences between Event Driven Programming and Functional Reactive Programming(FRP) by implementing the same set of functionality with both techinques. These two techinques, while sharing many things, offer quite different sets of tools to the developer.</p><p>Being able to compare the two approaches with a common point of reference is useful to see which key points the two approaches differ at. And also to see how the two approaches differ in terms of process and semantics, which is often hard to get a grasp on when comparing programming techniques.</p><p>What this blogpost will not cover is introductory material to either approach. Event Driven Programming is probably well known to anyone who has done javascript, either in the browser or on the server. The all too familiar .on(&#39;event&#39;, handler) is the basis of most asyncronous code in javascript. FRP on the other hand might be unfamiliar. There are many great sources of introductions to FRP and bacon.js, the liberary I will be using in this blogpost. Below are some suggested reads, if you want to get the basics of FRP before we get started;</p><ul><li><a href="https://medium.com/open.bekk.no/making-a-collaborative-piano-using-functional-reactive-programming-frp">Making a Collaborative Piano Using Functional Reactive Programming</a></li><li><a href="http://flippinawesome.org/2013/09/30/functional-reactive-programming-in-javascript/">Functional Reactive Programming in JavaScript</a></li><li><a href="http://nullzzz.blogspot.fi/2012/11/baconjs-tutorial-part-i-hacking-with.html">Bacon.js Tutorial Part I : Hacking With jQuery</a> (and its followups)</li><li><a href="http://blog.flowdock.com/2013/01/22/functional-reactive-programming-with-bacon-js/">Bacon.js Makes Functional Reactive Programming Sizzle</a></li><li><a href="https://github.com/baconjs/bacon.js">Bacon.js API docs</a></li><li><a href="http://javascriptjabber.com/061-jsj-functional-reactive-programming-with-juha-paananen-and-joe-fiorini/">061 JSJ Functional Reactive Programming with Juha Paananen and Joe Fiorini</a></li></ul><p>I will walk through the two implementations step by step explaining the process as I go along. A demo of the application will be available <a href="http://frp-sbs.herokuapp.com/">here</a> and I suggest taking it for a spin now to get a feel for the functionality it offers. It might be handy to keep it around for reference as you read along.</p><h4>The Application</h4><p>Before we get down to the business of code, we will need to define our application. The application used for the comparison will be a simple record (the vinyl kind, not the data kind) collection. It will list out records in the collection and allow the user to add new records. To ensure consistency in the collection, the application will only allow unique records and valid data.</p><p>To achieve this functionality, there are a few things we need to implement:</p><ul><li>Fetching records from a server</li><li>Listing records in the collection</li><li>A way to filter the viewed records</li><li>Adding a new record to the collection</li><li>Informing the user whether the data entered is valid</li><li>Sending the new record to the server for verification</li><li>Receiving the new record or an error from the server</li><li>Adding the new record to the viewed collection</li></ul><p>This looks like a fairly simple task. First, let us implement it with event driven programming, using the familiar jQuery library. Let us also throw in some <a href="http://lodash.com/">LoDash</a> to get some nice functional handling of collections.</p><h4>The Event Driven Implementation</h4><p>The first thing we need to do is to fetch the record collection from the server when we load the page. We can do this using the excellent promise-based AJAX API in jQuery:</p><pre>var records = [];<br><br>    $.ajax(&quot;/records&quot;)<br>        .done(function(data) {<br>            records = data;<br>            renderRecords(records);<br>        })<br>        .fail(function() {<br>            $(&quot;#records .error&quot;).toggle(true);<br>        })<br>        .always(function() {<br>            $(&quot;#records .loader&quot;).toggle(false);<br>        });</pre><p>This should be familiar to anyone that has done AJAX-requests in the browser and the promises interface makes it very clean. If the request succeeds, we set the data received to be the current record collection and render it. If the request fails to get the record collection from the server, we show an error-message. Regardless of whether the request succeed or fail, we hide the spinner that indicates a pending request.</p><p>To render the record collection we reduce the records to a string of markup and insert it into the DOM:</p><pre>var renderRecords = function(records) {<br>        var items = _.reduce(records, function(acc, record) {<br>            return acc + <br>                &quot;&lt;li&gt;&quot; +<br>                    &quot;&lt;h3&gt;&quot; + record.album + &quot;&lt;/h3&gt;&quot; +<br>                    &quot;&lt;p&gt;Artist: &quot; + record.artist + &quot;&lt;/p&gt;&quot; +<br>                    &quot;&lt;p&gt;Year: &quot; + record.year + &quot;&lt;/p&gt;&quot; +<br>                    &quot;&lt;p&gt;Genre: &quot; + record.genre + &quot;&lt;/p&gt;&quot; +<br>                &quot;&lt;/li&gt;&quot;;<br>        }, &quot;&quot;);<br>        $(&quot;#records ul&quot;).html(items);<br>    };</pre><p>We can already see a trend in the way values are assigned to elements in the application, always as a reaction to an event occuring. We set the visibility of the error-message and spinner and the value of the record collection based on what we receive when the AJAX-request returns. This is event driven programming. Actions and reactions happening as a response to an event.</p><p>We continue with the input for the filter we want to apply to our record collection:</p><pre>var testRegex = function(pattern) {<br>        return function(value) {<br>            if(!value) return false;<br>            return new RegExp(pattern, &quot;i&quot;).test(value);<br>        };<br>    };<br><br>    var filterRecords = function(filter) {<br>        return _.filter(records, function(record) {<br>            return _(record).values().any(testRegex(filter));<br>        });<br>    };<br><br>    $(&quot;#filter&quot;).on(&quot;keyup&quot;, function() {<br>        var filter = $(this).val();<br>        renderRecords(filterRecords(filter));<br>    });</pre><p>With two helper functions, to filter out which records match the query, and an event-listener to collect the value to filter for, we get a nice little search functionality for our record collection. If the filterRecords function look a bit unfamiliar to you I suggest checking out the <a href="http://lodash.com/docs">LoDash documentation</a>. Again we see the same pattern, the contents of the list displaying the records change as a reaction to the events triggered. Also note that we have now called the renderRecords function twice from two different places.</p><p>We now have the ability to view and filter the records in the collection received from the server. But we also want to be able to add new records to the collection. To make the example a little bit more interesting, and maybe more user-friendly, we will use icons to indicate the validity of the values entered into the form. Each value required will have three states; missing, invalid and valid. And to add a bit of enforcement to the validitiy, the application will not allow the user to push the add button before all fields are valid.</p><p>The function containing the core part of this functionality is implemented as follows:</p><pre>var mapToInputIcon = function(selector, validityChecker) {<br>        var value = $(selector).val();<br>        if(!value) {<br>            $(selector + &quot;+ i&quot;).attr(&quot;class&quot;, &quot;icon-asterisk&quot;);<br>            return false;<br>        } else if(validityChecker(value)) {<br>            $(selector + &quot;+ i&quot;).attr(&quot;class&quot;, &quot;icon-ok&quot;);<br>            return true;<br>        } else {<br>            $(selector + &quot;+ i&quot;).attr(&quot;class&quot;, &quot;icon-warning-sign&quot;);<br>            return false;<br>        }<br>    };</pre><p>This function both sets the approperiate icon-class and returns the validity of the value. Not optimal, but let’s roll with it. Next we use this function in conjuction with the form to visualize the validity of the form. The validation rules are as follows:</p><ul><li>Album: No duplicates, so no records with the entered name may exist in the collection.</li><li>Artist: Has to have a value.</li><li>Year: Has to be a valid year. Since there are no records released before the second half of the 1800s we can use four digits as a requirement for a valid year.</li><li>Genre: Has to have a value.</li></ul><p>This chunk of code is perhaps the biggest in this post. But as it is fairly repetative, I am going to let it pass.</p><pre>var validAlbum = false,<br>        validArtist = false,<br>        validYear = false,<br>        validGenre = false;<br><br>    $(&quot;#album&quot;).on(&quot;keyup&quot;, function() {<br>        validAlbum = mapToInputIcon(&quot;#album&quot;, function(value) {<br>            return !_.any(records, {&quot;album&quot;: value});<br>        });<br>    });<br><br>    $(&quot;#artist&quot;).on(&quot;keyup&quot;, function() {<br>        validArtist = mapToInputIcon(&quot;#artist&quot;, _.identity);<br>    });<br><br>    $(&quot;#year&quot;).on(&quot;keyup&quot;, function() {<br>        validYear = mapToInputIcon(&quot;#year&quot;, testRegex(&quot;^\\d{4}$&quot;));<br>    });<br><br>    $(&quot;#genre&quot;).on(&quot;keyup&quot;, function() {<br>        validGenre = mapToInputIcon(&quot;#genre&quot;, _.identity);<br>    });<br><br>    $(&quot;#add-record input&quot;).on(&quot;keyup&quot;, function() {<br>        var valid = validAlbum &amp;&amp; validArtist &amp;&amp; validYear &amp;&amp; validGenre;<br>        $(&quot;[type=submit]&quot;).attr(&quot;disabled&quot;, !valid);<br>    });</pre><p>We are now using four different variables to track the validity of the new record we wish to add to the collection, which are all changing when the user enters new values into the corresponding input field. Again we have the same pattern of reacting to events. We also find ourselves in the situation where we have to keep track of a relatively complex state; the combined validtity of four fields making up the validity of a single record.</p><p>The final piece of functionality we want is sending the new record to the server for final verification.</p><pre>var resetForm = function() {<br>        $(&quot;#add-record input&quot;).val(&quot;&quot;).trigger(&quot;keyup&quot;);<br>    };<br><br>    $(&quot;[type=submit]&quot;).on(&quot;click&quot;, function(event) {<br>        event.preventDefault();<br>        $(&quot;.loader-small&quot;).toggle(true);<br>        $(&quot;#add-record .error&quot;).toggle(false);<br>        $.ajax({<br>            url: &quot;/records/new&quot;,<br>            type: &quot;POST&quot;,<br>            contentType: &quot;application/json&quot;,<br>            data: JSON.stringify({<br>                &quot;album&quot;: $(&quot;#album&quot;).val(),<br>                &quot;artist&quot;: $(&quot;#artist&quot;).val(),<br>                &quot;year&quot;: $(&quot;#year&quot;).val(),<br>                &quot;genre&quot;: $(&quot;#genre&quot;).val(),<br>            })})<br>            .done(function(data) {<br>                records.push(data);<br>                resetForm();<br>                renderRecords(filterRecords($(&quot;#filter&quot;).val()));<br>            })<br>            .fail(function() {<br>                $(&quot;#add-record .error&quot;).toggle(true);<br>            })<br>            .always(function() {<br>                $(&quot;.loader-small&quot;).toggle(false);<br>            });<br>    });</pre><p>Again we use the promises interface from jQuery’s AJAX-API. As we are preparing the AJAX-request we collect the current values of the form. And as with the previous AJAX-request, we toggle the visibility of a spinner and a potential error-message based on the current state of the request. If the server returns the record to us, we reset the form and re-render the record collection. As a nice-to-have, we let the current active filter stay active. This also marks the third time we call the renderRecords function.</p><p>You can view the source in its entirety <a href="https://github.com/mollerse/frp-sbs/blob/master/static/event.js">here</a>. Now that we have all the functionality we outlined for the application, lets reimplement it using functional reactive programming (FRP)!</p><h4>The Functional Reactive Programming Implementation</h4><p>For the FRP part we will use bacon.js. If you did not checkout the links I presented at the beginning of this post, and especially the <a href="https://github.com/baconjs/bacon.js">bacon.js API docs</a>, I will make that suggestion again. I will not go into detail with every method I use from the API, so I suggest keeping the docs at hand while reading on.</p><p>Because FRP is different from event driven programming in its approach to implementation, the steps in this implementation will not line up with the steps in the previous implementation. Without further ado, let us begin.</p><p>The first step when implementing a user interface with FRP is to define the sources of events and data in the interface. In this application we have the following sources:</p><ul><li>Existing records from the server</li><li>Input for the filter</li><li>Four inputs in the form for adding new records</li><li>Button for sending a new record to the server</li><li>The added record received from the server</li></ul><p>The first source of data is the AJAX-request we send to the server in order to fetch the existing record collection. Because a jQuery AJAX-request is based on promises, we use bacon.js’ Bacon.fromPromise to create an EventStream of the respone.</p><pre>var records = Bacon.fromPromise($.ajax(&quot;/records&quot;));</pre><p>Next we have the filter and the inputs in the new record form. These will be represented as properties, which is the bacon.js way of representing continous values. In addition we will need a property representing a record, which is the aggregation of the individual properties from the form.</p><pre>var propertyFromInput = function(field) {<br>        var value = function(event) {<br>            return event.currentTarget.value;<br>        };<br>        return Bacon.fromEventTarget(field, &quot;keyup&quot;)<br>            .map(value)<br>            .toProperty(&quot;&quot;);<br>    };<br><br>    var recordFilter = propertyFromInput($(&quot;#filter&quot;));<br><br>    var album = propertyFromInput($(&quot;#album&quot;));<br>    var artist = propertyFromInput($(&quot;#artist&quot;));<br>    var year = propertyFromInput($(&quot;#year&quot;));<br>    var genre = propertyFromInput($(&quot;#genre&quot;));<br><br>    var record = Bacon.combineTemplate({<br>            &quot;album&quot;: album,<br>            &quot;artist&quot;: artist,<br>            &quot;year&quot;: year,<br>            &quot;genre&quot;: genre,<br>    });</pre><p>The button for triggering the addition of a new record is perhaps the most familiar piece of code, if you have read any of the introductory FRP posts.</p><pre>var add = Bacon.fromEventTarget($(&quot;[type=submit]&quot;), &quot;click&quot;)<br>            .doAction(&quot;.preventDefault&quot;);</pre><p>The last source of data in this application is the AJAX-request which posts the added record to the server and gets the same data in return. In addition we want to collect all added records in a list, so we can combine it with the existing records we received from the server. To do so, we use a scanner to create a composite property from all the events in the stream. We also want a property that represents the combination of all the records in the application.</p><pre>var addedRecord = record.sampledBy(add)<br>        .flatMapLatest(function(record) {<br>           return Bacon.fromPromise($.ajax({<br>                &quot;url&quot;: &quot;/records/new&quot;,<br>                &quot;type&quot;: &quot;POST&quot;,<br>                &quot;data&quot;: JSON.stringify(record)<br>            }));<br>        })<br>        .doAction(resetForm);<br><br>    var addedRecords = addedRecord.scan([], &quot;.concat&quot;);<br>    var allRecords = records.combine(addedRecords, &quot;.concat&quot;);</pre><p>This is perhaps the most complicated piece of code in this implementation, so I will take a moment to step through it. The first thing we do is to take a snapshot of the value of the record-property when we get an event from the add-button. Then we take that value and prepare an AJAX-request with the value as the body. Since Bacon.fromPromise also returns a new event stream and we do not want to deal with nested handlers, we use flatMapLatest to get the latest event stream created, which is the response from the server. It is worth mentioning here that error-events will pass through normal handlers so that the form will not be reset if the request should fail.</p><p>The second step in implementing a user interface using FRP is to declare the relationships between the event and data sources and the various other elements of the user interface. In this application we have the following elements:</p><ul><li>A spinner to indicate a pending request for the exisiting record collection</li><li>An error-message if fetching the existing record collection fails</li><li>Icons visualizing the validity of the input fields in the new record form</li><li>The enabling of the add-button</li><li>A spinner to indicate a pending request to add a new record to the collection</li><li>An error-message if adding the new record failed</li><li>A filtered view of the existing record collection and all the added records</li></ul><p>First up is the spinner that indicates the pending request for the existing record collection. We only want to display it while a request is pending and hide it when we receive data, either records or an error.</p><pre>records.map(Boolean).mapError(Boolean).not()<br>        .assign($(&quot;#records .loader&quot;), &quot;toggle&quot;);</pre><p>Mapping both data and errors to Boolean values, any truthy value becomes true and any falsy value becomes false, and assigning it to the function toggle on the jQuery-object representing the spinner. Passing the values through not() is done because we want to hide the spinner if any data is returned from the server.</p><p>We want to display an error-message when we get an error from the server and keep it hidden when we get other data. We do this in the same way as with the spinner. We pass records through not() before we map the errors because we want any data to keep the error-message hidden.</p><pre>records.map(Boolean).not().mapError(Boolean)<br>        .assign($(&quot;#records .error&quot;), &quot;toggle&quot;);</pre><p>For the input-field icons we need a bit more code. Similar to the event driven implementation, we need variables to represent the validity of the input field. However, in this implementation, rather than assigning the value of the validity we declare it as a relationship between the property representing the value and some validity criteria.</p><pre>var validAlbum = album<br>        .combine(allRecords, function(album, records) {<br>            if(!album) return false;<br>            return !_.any(records,{&quot;album&quot;: album});<br>        });<br>    var validArtist  = artist.map(Boolean);<br>    //The testRegex method is the same as in the event driven implementation<br>    var validYear = year.map(testRegex(&quot;^\\d{4}$&quot;));<br>    var validGenre = genre.map(Boolean);</pre><p>Next we map the value of the property to the corresponding icon-class and assign it to the correct element.</p><pre>var mapToInputIcon = function(input, valid) {<br>        return input.combine(valid, function(input, valid) {<br>            if(!input) return &quot;icon-asterisk&quot;;<br>            if(!valid) return &quot;icon-warning-sign&quot;;<br>            return &quot;icon-ok&quot;;<br>        });<br>    };<br><br>    mapToInputIcon(album, validAlbum)<br>        .assign($(&quot;#album + i&quot;), &quot;attr&quot;, &quot;class&quot;);<br><br>    mapToInputIcon(artist, Bacon.constant(true))<br>        .assign($(&quot;#artist + i&quot;), &quot;attr&quot;, &quot;class&quot;);<br><br>    mapToInputIcon(year, validYear)<br>        .assign($(&quot;#year + i&quot;), &quot;attr&quot;, &quot;class&quot;);<br><br>    mapToInputIcon(genre, Bacon.constant(true))<br>        .assign($(&quot;#genre + i&quot;), &quot;attr&quot;, &quot;class&quot;);</pre><p>Because we decleared the validity separately, we will not have to do assignment as a part of the mapping-function.</p><p>To enable the add-button when all the fields in the form are valid, we just declare a relationship between the validity of the input-fields and the disabled property of the correct element.</p><pre>validAlbum.and(validArtist).and(validYear).and(validGenre).not()<br>        .assign($(&quot;[type=submit]&quot;), &quot;attr&quot;, &quot;disabled&quot;);</pre><p>Again we pass the value through not() because we want it not to be disabled when all the fields are valid.</p><p>For the AJAX-request for posting new records to the server we want to display a spinner, like with the other AJAX-request for fetching the existing record collection. We have a twist here though, which is that we only want to display it after we have pushed the add-button and the response is still pending.</p><pre>addedRecord.map(Boolean).mapError(Boolean).not()<br>        .merge(add.map(Boolean))<br>        .assign($(&quot;.loader-small&quot;), &quot;toggle&quot;);</pre><p>The relationship between the add record request and the error-message for the request is the same as with the request for existing records.</p><pre>addedRecord.map(Boolean).not().mapError(Boolean)<br>        .assign($(&quot;#add-record .error&quot;), &quot;toggle&quot;);</pre><p>Finally we want to display the filtered combination between the existing record collection and all the added records. So we declare the relationship between the existing records, the added records and the filter and assign it to the correct element in the interface.</p><pre>allRecords<br>        .combine(recordFilter, filterRecords)<br>        .map(renderRecords)<br>        .assign($(&quot;#records ul&quot;), &quot;html&quot;);</pre><p>The filterRecords and renderRecords functions are mostly the same as the reactive implementations, minus DOM insertion in renderRecords and a small change to the signature of filterRecords.</p><p>We have now implemented the same functionality using FRP. The source is available as a whole <a href="https://github.com/mollerse/frp-sbs/blob/master/static/functional.js">here</a>.</p><h4>Comparison</h4><p>I want to discuss two key differences between the two approaches; How to handle composite behavior and how to assign new values to interface components.</p><p>In the event driven implementation, we had to add some state to the code in order to get behavior that depended on more than one source of data. The two examples in this application are the record collection, which is manipulated by the two AJAX-requests, and the validity checks of the input fields, which controls the enabling of the add-button. These pieces of state are mutated from within event handlers and read from within event handlers.</p><p>The same two examples in the functional reactive implementation also have the same functionality, but it does not rely on explicit shared state to achieve it. Where we had to manually wrangle state in the event driven implementation, we have the power of declarative relationships in FRP. Rather than assigning value to a variable and manually updating it whenever something would cause it to change, we can declare how a value change when other values change and let the underlying mechanics handle the actual updating of the value.</p><p>The other key difference is how values are assigned to the different interface components. Again we have two good examples. The first is how the value of the list that displays records change and the second is how the icons that signal the state of the input fields in the form for adding new records. In the event driven implementation we manually call the function to render the record collection list three times in three different places.</p><pre>// Some implementation details omitted for clarity<br><br>    $.ajax(&quot;/records&quot;) //GET<br>        .done(function(data) {<br>            records = data;<br>            renderRecords(records);<br>        })<br><br>    $(&quot;#filter&quot;).on(&quot;keyup&quot;, function() {<br>        renderRecords(filterRecords($(this).val()));<br>    });<br><br>    $.ajax(&quot;/records/new&quot;) //POST<br>        .done(function(data) {<br>            records.push(data);<br>            renderRecords(filterRecords($(&quot;#filter&quot;).val()));<br>        });</pre><p>This means that the list of records now has three different reasons to change, so a bug with the displaying of records could come from one of three different places. And this application is not even that complex. This is one of the reasons behind the rise of MVC-like abstractions for handling complex interfaces in frontend web development.</p><p>The same functionality is achieved in the FRP implementation like so:</p><pre>// Some implementation details omitted for clarity<br><br>    records.combine(addedRecords, &quot;.concat&quot;)<br>        .combine(recordFilter, filterRecords)<br>        .map(renderRecords)<br>        .assign($(&quot;#records ul&quot;), &quot;html&quot;);</pre><p>This reduces the number of times the value of the list displaying the records changes to one. This is very similar to the same benefits you get from using a model-view-abstraction and tracking change events.</p><p>We observe the same change in behavior with the icons visualizing the validity of the input fields, but the change is not as drastic as it was with the displaying of the record collection.</p><p>There is also the benefit of a higher level of abstraction and an approach that lies closer to how we reason about interface components. The declarative nature of FRP enables us to think in terms of what we want to achieve with our interface instead of focusing on the explicit how.</p><p>In addition we get the benefits of functional programming with FRP, but covering those would be a whole blogpost in its own right. Besides, there are plenty of excellent sources on that around.</p><h4>Closing Remarks</h4><p>I have only pointed to two differences in this blogpost, but there are many subtle differences that could be major for various usecases. So my suggestion to anyone wishing to spend some time studying FRP is to repeat the exercise of implementing the same application in both your preferred techinique and FRP. This blogpost has hopefully convinced you that it would be a worthwile effort.</p><h4>Thanks</h4><p>Big thanks to Mikael Brevik for inspiration and feedback and Magnus Fjell for proofreading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=babbd8364150" width="1" height="1" alt=""><hr><p><a href="https://blogg.bekk.no/event-driven-and-functional-reactive-programming-step-by-step-babbd8364150">Event Driven and Functional Reactive Programming, Step by Step.</a> was originally published in <a href="https://blogg.bekk.no/">Bekk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>