<?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 Fachrin Aulia Nasution on Medium]]></title>
        <description><![CDATA[Stories by Fachrin Aulia Nasution on Medium]]></description>
        <link>https://medium.com/@fachrinfan?source=rss-a1944fe6091c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aQXP9uYcgqgjok_GaMDnOg.jpeg</url>
            <title>Stories by Fachrin Aulia Nasution on Medium</title>
            <link>https://medium.com/@fachrinfan?source=rss-a1944fe6091c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 02:20:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fachrinfan/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[PostgreSQL as a Message Broker to Apply a Reactive Caching Strategy]]></title>
            <link>https://medium.com/geekculture/postgresql-as-a-message-broker-to-apply-a-reactive-caching-strategy-57e7f8f7dd0e?source=rss-a1944fe6091c------2</link>
            <guid isPermaLink="false">https://medium.com/p/57e7f8f7dd0e</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[message-queue]]></category>
            <category><![CDATA[cache]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Fachrin Aulia Nasution]]></dc:creator>
            <pubDate>Thu, 08 Jul 2021 04:13:18 GMT</pubDate>
            <atom:updated>2022-03-09T05:28:58.315Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>We’ve been using database engines like PostgreSQL or the other as a building block to develop software that solves our daily friction problems. It could be a simple to-do list app or a spending-tracker app using those database engines to remember and store things.</p><p>I’d like to share the other use cases we can have using PostgreSQL to not only doing basic things we do but something beyond it which some of us may never explore through this article.</p><h3>PostgreSQL as a Message Broker</h3><p>Message broker is a software that enables us to do asynchronous communication between two or more parties. Parties here could be some microservice-based applications that listen to some topics to share and fetch some information they need and process it under their business logic.</p><p>There are a bunch of technologies that can act as a message broker we can find out there, such as</p><ul><li>Redis Pub/Sub</li><li>RabbitMQ, and</li><li>Apache Kafka</li></ul><p>I guess those three technologies on the list are the most common ones that pop up in everybody’s mind whenever they think of a message broker software. On the other way around, nobody would think PostgreSQL will suit the needs in the very first place.</p><h4>Listen and Notify</h4><p>PostgreSQL owns an API that resembles the message broker’s pub-sub pattern through <strong>LISTEN</strong> and <strong>NOTIFY </strong>commands.</p><p>We can use the <strong>NOTIFY</strong> command to publish a notification telling subscribers that an event has occurred in a channel. Meanwhile, for the <strong>LISTEN </strong>command we can use it to subscribe to a channel’s event and use the information in it to do something.</p><p>It’s just like any other pub-sub pattern that is common in the message broker softwares. To get clearer visualization about it, we can see how it looks like in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYiznsTlRkEEbI5IX76vkg.gif" /></figure><p>It’s pretty straightforward to use the commands, right? 👀</p><pre># to subscribe to a channel (topic)</pre><pre><strong>LISTEN</strong> <em>channel</em>;</pre><pre># to publish an event to a channel (topic), payload is optional</pre><pre><strong>NOTIFY </strong><em>channel</em><strong><em>, </em></strong><em>payload</em><strong><em>;</em></strong></pre><p>You can learn more about this here: <a href="https://www.postgresql.org/docs/current/sql-listen.html">LISTEN</a> and <a href="https://www.postgresql.org/docs/current/sql-notify.html">NOTIFY</a>.</p><h3>Reactive Caching Strategy using PostgreSQL</h3><p>This is the interesting part, we now know that PostgreSQL can do things like any other message broker softwares. The question is: what makes it has something to do with the caching strategy?</p><p>So before going into the chief topic, it’s better to have some idea and aligned definition about what does it actually mean here in a <em>nutshell</em>.</p><h4><strong>Caching Strategy</strong></h4><p>A caching strategy is a technique to maintain the data integration between the major data source and the caching system, and in what manner we can interact with the data later on.</p><p>There are several common caching strategy variants out there but here we’re only going to discuss some of the write variants. Let’s get to them.</p><h4>Write Through Variant</h4><p>Write through variant allows us to sync the data between the caching system and data source in an one go manner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*-eVKWhpZx-yXybMylk5Fgw.png" /></figure><ol><li>Application writes data to the cache, then</li><li>Application writes data to the database after done writing data to the cache</li></ol><p>It is a pretty simple approach yet the drawback is very obvious, tho. This operation is costly because we have to maintain two network calls to the cache and database.</p><p>The write to the database could be potentially sluggish and considered as a heavy operation so that it will increase the network latency even more.</p><h4>Write Behind Variant</h4><p>Write Behind variant is actually similar to the <em>Write Through</em> one. The only difference between them is that this variant requires a message broker or a middleware to sync the data between the cache and the database asynchronously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*JB61qwVCH92w_aRamzdvcQ.png" /></figure><ol><li>Application writes data to the cache</li><li>Application publishes a message that notifies the data has changed</li><li>The consumer application consumes the message, then</li><li>It writes data back to the database</li></ol><p>This variant requires more steps to get done but we can benefit a thing from it, we can reduce the network latency through a message broker or a middleware in between to sync the data.</p><p>Writing a message to a message broker produces less latency rather than addressing data to the database directly.</p><h4>👻 Reactive Cache Variant 👻</h4><p>This variant is actually my own term. The reactive word in its name reflects the way how the cache will get updated. The idea is the update on the cache will only happen whenever the respective data in the database gets changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*prZkAbS_PWibhwDd6Q0onQ.png" /></figure><p>Here what’s happening in this variant:</p><ol><li><strong>Application only writes data to the database once</strong></li><li>The database publishes a message to tell consumers that a data has changed</li><li>The consumer application consumes a message, then</li><li>It writes the data back to the cache</li></ol><p>By using this approach, we can reduce the network latency in a very significant way.</p><p>Notice that we only do a single network call to the database, and then let it do its job to produce a message orchestrating the consumers to write the data back to the cache asynchronously. <strong><em>Fire and forget.</em></strong></p><p>Not only that, we also don’t need any additional message broker software anymore to get it done. Let the PostgreSQL come into play through its <strong>Listen/Notify</strong> API.</p><p><em>Pretty cool, huh?</em> 😎</p><h3>Twitter Profile App as an Use Case</h3><p>Let’s get dirty. All the things above sound promising, right? So, I’ve built a “semi” working application that implements that reactive caching strategy under the hood.</p><p>I’ve designed a Twitter-like application architecture to show a user profile page that contains information about the number of followings, followers, and likes counter.</p><p>Here’s how the architecture does look like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*7o5KWAsAQ8PqQNvtYiIWGA.png" /></figure><ol><li>Updating counters will take the benefit of the reactive cache strategy. Client can access <strong><em>/v1/profile/&lt;username&gt;</em></strong> endpoint to do that, and</li><li>To fetching counters, client can stream the <strong>/stream</strong> endpoint. It will connect with the endpoint through a <strong><em>Server-Sent Events Protocol</em></strong> to get realtime data from the server side. The server will push data to the client whenever changes happen in the cache.</li></ol><p>So, there you go, you can see the demonstration below or <a href="https://rc.fachr.in/">go to this link</a> for a hands-on interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zdqnsj9eiFWhHUjJbe6wDw.gif" /></figure><p>We can see there are two Chrome windows opened here. Each window renders our Twitter Profile app. Whenever the counter changes in a window, another window will get immediately updated and react to the changes right away. <strong>Pretty fast</strong>.</p><p>Notice that <strong><em>it’s not just the typical Javascript’s DOM manipulation</em></strong>. It’s calling an API to update the counter and to stream the counter. So, there should be a network latency, but it’s done before a blink of an eye 😜</p><p>Still be skeptical about it? We can speed up the update counter operation using a browser hack by executing this function on the browser’s console.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86b4f2a6ed9c445ae95c2eaeaa2dca6d/href">https://medium.com/media/86b4f2a6ed9c445ae95c2eaeaa2dca6d/href</a></iframe><p>This is the result. <em>Expect a frame rate drop, because it’s a GIF anyway</em>. The original file showed much faster counter change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9cS6_pmbuR6P-r9dnBBTQ.gif" /></figure><p>The application can serve the request without any effort, it worked seamlessly 🐛</p><h3>Conclusion</h3><p>Hey, we have come to the conclusion section already. I hope by completing this read we can be more cognizant of the Postgres’ <strong>Listen/Notify</strong> API existence, and start thinking of what kind of other use cases we can apply using this technology.</p><p>In terms of the scalability and performance, I unfortunately didn’t explore it that far. If you perhaps want to build a simple application, and don’t want to over-engineer it, you can start consider using a familiar tech like PostgreSQL instead of using more advanced message broker software like Apache Kafka.</p><p><strong><em>It’s super possible to use PostgreSQL as a message broker software as an alternative to the others.</em></strong></p><h4>Source Code</h4><p>You can access all the source code demonstrated in this article through my Github repository here: <a href="https://github.com/parinpan/reactive-cache">https://github.com/parinpan/reactive-cache</a></p><p><strong>Tech stack used:</strong> Python3, Flask Framework, PostgreSQL, and Redis.</p><h4>Further Discussion</h4><p>If you have any query or would like to discuss anything. I’m very open to it. Please reach me out through my social media accounts:</p><ul><li><a href="https://twitter.com/fachrinFAN">Twitter</a></li><li><a href="https://www.linkedin.com/in/fachrinfan/">Linkedin</a>, and</li><li><a href="https://fachr.in/">Website</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57e7f8f7dd0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/postgresql-as-a-message-broker-to-apply-a-reactive-caching-strategy-57e7f8f7dd0e">PostgreSQL as a Message Broker to Apply a Reactive Caching Strategy</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gracefully Mimicking Clojure’s Threading Macros in Golang]]></title>
            <link>https://fachrinfan.medium.com/gracefully-mimicking-clojures-threading-macros-in-golang-656827a12421?source=rss-a1944fe6091c------2</link>
            <guid isPermaLink="false">https://medium.com/p/656827a12421</guid>
            <category><![CDATA[functional-programming]]></category>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[code-style]]></category>
            <dc:creator><![CDATA[Fachrin Aulia Nasution]]></dc:creator>
            <pubDate>Sat, 13 Feb 2021 04:26:02 GMT</pubDate>
            <atom:updated>2021-07-10T01:11:35.083Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Wise men said if you can’t find happiness in your life, it’s not solely the other’s fault because you are the only one who is responsible for that. They said in order to achieve happiness you have to figure out a way and create it by your own instead of finding it nowhere.</p><p>One of wonderful things is by looking at how Clojure executes a set of functions sequentially in a lovely manner and it feels so oddly satisfying which Golang has none to offer the same thing.</p><p>I actually love both programming languages but lately I code in Clojure more often than Golang since I joined Gojek. There’s a feature in Clojure that I love the most. It’s called <strong>Threading Macros</strong>. What the hell is it, actually?</p><h4>Clojure’s Threading Macros</h4><p>In an oversimplified explanation, it’s a pattern that can help you to set up a set of functions and let each of them doing data transformation when executed, which the transformed data then will be passed as an argument to the next function in the set to generate new information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dmjgvO7AlZ_pLbiotFbugg.png" /><figcaption>Image 1: Threading Macros in Clojure</figcaption></figure><p>As shown in the Image 1, the <em>Clojure’s Threading Macro</em> has a set of functions which comprises:</p><ul><li><strong>(get-restaurants)</strong> that return a list of restaurant</li><li><strong>(get-menus)</strong> that return a list of menu from a list of restaurant returned by <em>(get-restaurants)</em></li><li><strong>(get-food-with-highest-price)</strong> that return food with highest price from a list of menu returned by <em>(get-menus)</em></li></ul><p>We can see the data streamed from one to another function with a new form so neatly!</p><p>By the way, if you’d like to find out more about <em>Clojure’s Threading Macros</em>, go find it on <a href="https://clojure.org/guides/threading_macros">Clojure’s Documentation Official Page</a>.</p><h4>Mimicking Clojure’s Threading Macros in Golang</h4><p>Yeah, I know. We all are going to love this feature. Who doesn’t? It introduces a syntactic sugar touch to our code base, which makes things easier to read or to express. Oops… beware of diabetes! 🤗</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*L0hLuuxPGbi4NLuVWEP1jw.png" /></figure><p>All must agree that statically typed programming languages are usually better in terms of performance rather than the dynamically typed ones, but that’s not the case because we sometimes are longing for the simplicity of writing code too!</p><p>I tried to carry that kind of simplicity from Clojure to Golang by introducing a small library called <a href="https://github.com/parinpan/pipe"><strong>Pipe</strong></a><strong>, </strong>which I developed recently. It basically does the same thing as <em>Clojure’s Threading Macros</em> and copies its concept.</p><p>Let’s get dirty, show me the code!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3faae7034fa4b387b2a693ed290174d4/href">https://medium.com/media/3faae7034fa4b387b2a693ed290174d4/href</a></iframe><p>Here we go. We just imported the github.com/parinpan/pipe library at the very top of the file. This library has two core functions to make the same functionality of <em>Clojure’s Threading Macros</em> running in Golang, they are: <strong><em>pipe.Do()</em></strong> and <strong><em>pipe.Apply()</em></strong></p><ul><li>the <strong><em>pipe.Do()</em></strong> function accepts a set of <strong><em>pipe.Apply()</em></strong> functions to register all the functions for sequential execution.</li><li>the <strong>pipe.Apply() </strong>function<strong> </strong>accepts any function with its arguments or else we could leave them blank, since by default the passed function’s argument will be the latest return value of previous executed function in the set.</li></ul><p>Okay, it’s still fine <strong>if all the functions only have one argument</strong> so that this library can pass the latest return value of previous executed function to it. Now, the question is: <strong>how about the functions that have more than one argument? 👀🧐</strong></p><p>Relax. Let me show you the code again. We have the answer! 🙈</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7db38b200804d19178d84d83fd55c803/href">https://medium.com/media/7db38b200804d19178d84d83fd55c803/href</a></iframe><p>Let’s see what’s changed here. Now some functions accept more than one argument.</p><ul><li><strong>getMenusWithFilter(…)</strong> function accepts restaurant location at the 1st argument, a list of restaurant at the 2nd argument, and restaurant established year at the 3rd argument</li><li><strong>getFoodByName(…)</strong> function accepts a list of menu at the 1st argument and food name at the 2nd argument</li></ul><p>So, now, <strong>how the library can know at what index it should pass the argument with the return value of previous executed function?</strong> Should it be at the function argument’s <em>1st index</em>, <em>2nd index</em>, or <em>nth index</em>?</p><p>If you noticed, from the code above there are some <strong>pipe.Pass() </strong>function passed in the <strong>pipe.Apply()</strong> which we know already that it accepts a function and its arguments. So, the library will replace the argument value with the carrier return value at an argument’s index where the <strong>pipe.Pass()</strong> was being passed.</p><p>The special thing is <strong>pipe.Pass()</strong> can also accept a function to alter the carrier return value to a new form before being executed, which shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5774215653748d373a812cdeb5841354/href">https://medium.com/media/5774215653748d373a812cdeb5841354/href</a></iframe><p>You can think <strong>pipe.Pass()</strong> is an equivalent to the Clojure’s anonymous function “<em>%”</em> symbol.</p><pre><strong># this is clojure!</strong></pre><pre><em>(-&gt; (get-restaurant)<br>    (#(get-menus-with-filter &quot;Bay Area&quot; </em><strong><em>%</em></strong><em> 1940))<br>    (#(get-food-name </em><strong><em>%</em></strong><em> &quot;BigMac&quot;))<br>    (#(say (format &quot;I love %s so much!&quot; </em><strong><em>%</em></strong><em>)))</em></pre><p>Isn’t it cool, huh? 😎</p><h4>Under the Hood</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/0*t93Y3LrMvw4v-kGy.gif" /></figure><p>After going thru the cool stuff, we must thank to Golang’s reflection feature, which makes it all possible to happen! Yeah, the library is actually only an abstraction on top of it to hide all the complexities behind.</p><p>Let’s look at a sneak peek where it happened by looking at this code snippet:</p><pre><strong>returnValue</strong> := reflect.ValueOf(<strong>function</strong>).Call([]reflect.Value{<strong><em>arg1, arg2, arg3</em></strong>})[0]</pre><p>Basically, the library uses the Golang’s reflect.ValueOf() function to call all functions that we’ve registered one by one using the combination of <strong>pipe.Do()</strong> and <strong>pipe.Apply()</strong> function together with their arguments.</p><p>After we got the returnValue from the reflect.ValueOf() execution, we’re going to use that value again as the next executed function’s argument. 👻</p><h4>Benchmarking</h4><p>Tested on MacBook Pro 16 inch 2019. Processor: 2,3 GHz 8-Core Intel Core i9. Memory: 16 GB 2667 MHz DDR4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8G6ZlrnJK8JWCthHG5ExKw.png" /></figure><p>From the image above, the result is:</p><ul><li>ExecutedWithoutPipe was computed 60.675.291 times in 166ms with a duration of 18.3ns on each operation.</li><li>ExecutedWithPipe was computed 603.291 times in 166ms with a duration of 1825ns on each operation.</li></ul><p>No contest. No wonder. We already know who’s the winner at the first place. Executing the operation without using <strong>Pipe</strong> performs <strong>100x better</strong> than using it. Golang’s reflection is definitely expensive.</p><p>It’s back to you again. We can still consider 1825ns on each operation as quite fast depends on the context and situation.</p><h4>Conclusion</h4><p><em>Clojure’s Threading Macros</em> offers a neat way to construct a series of function’s execution, which is so syntactic sugar and encourages us to love coding again. 😍</p><p>Mimicking that feature in Golang is not really difficult, it’s just a matter of how we can build an abstraction on top of Golang’s reflection feature, which indeed the cost is very expensive in terms of performance.</p><p>But as long as this can make you happy and code more. Why not? <em>Okay, this is an opinion✌️</em></p><h4>Further Discussion</h4><p>If you have any inquiry, please reach me on <a href="https://twitter.com/fachrinFAN">Twitter</a> or <a href="https://www.linkedin.com/in/fachrinfan/">LinkedIn</a>. Oh yeah, if you are interested in this library. You can find it on: <a href="https://github.com/parinpan/pipe">https://github.com/parinpan/pipe</a></p><p>Thanks!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=656827a12421" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Golang is agnostic to particular programming paradigms. Here’s why.]]></title>
            <link>https://medium.com/geekculture/golang-is-agnostic-to-particular-programming-paradigms-heres-why-a57bfc27ec90?source=rss-a1944fe6091c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a57bfc27ec90</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Fachrin Aulia Nasution]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 14:08:53 GMT</pubDate>
            <atom:updated>2021-07-09T06:45:55.859Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>A Long Story Short</strong></h3><p>the <strong>Novel Coronavirus</strong> is now travelling the world. Some countries decided to lockdown cities that are infected by this most infectious virus of the year. It’s also a month where I spend the spare time as a temporary jobless man after resigning from <strong>Tokopedia, </strong>the largest e-commerce platform in Indonesia.</p><p>It is taking me to a tranquil state where no surrounding crowds, voices, or whatever they are that bring you to focus less on something you’re working on. So, I hear the void is whispering to me: <em>How about writing a functional programming stuff?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*dbBP4UiLU0xCaqESzyEqkw.png" /></figure><p><strong>Golang</strong> has been my favourite language, at least until now. Previous working experience had me to deal with it, we get to know each other better day by day. I like its simplicity and straightforwardness; it’s like you are the master who can tinker and mix-match whatever you want to build anything on this language.</p><p>I’ve created a tiny library in Golang to emphasize its agnosticism of particular programming paradigms to you. In the instance that it doesn’t only belong to Object-Oriented Programming paradigm which everyone usually glorifies <em>(hey, me too!).</em></p><p>I called the library as <a href="https://github.com/parinpan/fun-go"><strong>Fun-go</strong></a><strong> (still far away from perfect) </strong>that will provide some <strong>functional programming</strong> ability in Go<strong>.</strong> Basically, it consists of <strong><em>map</em></strong>, <strong><em>filter</em></strong>, and <strong><em>reduce</em></strong> function that I adopted from Javascript. Well, it’s quite influential enough while I was working on it besides my confession that:</p><blockquote>I do really hate repetitive looping syntax!</blockquote><p>I will start with <em>a pain point </em>and describe how<em> </em>the library will help me a lot getting rid of my hatred on that thing and make Golang still loveable.</p><h3><strong>Searching Items is Painful</strong></h3><p>Searching is a <em>basic instinct</em> in computer science. Oftentimes, a simple thing becomes more complex because we alone that add more complexities to it; like too many searching conditions. Example:</p><ul><li>Search products with price higher than <strong>$50</strong></li><li>Search new products with price higher than <strong>$50</strong></li><li>Search used products that each has <strong>ID</strong> greater than <strong>1234</strong> and price lower than <strong>$100</strong></li><li>Another search condition…</li><li>Etc…</li></ul><p>In a conventional way, your code will usually look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/888dbd3dbc3f7912274c4ea280a37668/href">https://medium.com/media/888dbd3dbc3f7912274c4ea280a37668/href</a></iframe><p>You must see a pattern. You keep writing many repetitive looping blocks over and over again and starting losing the straightforwardness of what you are actually going to do with the data. The intention becomes blurry. IMHO.</p><pre>// the pattern</pre><pre>// you will always provide a variable that will hold your data<br>var myVariables</pre><pre>// keep making repetition of the looping block<br>for _, <em>blabla</em> := range blablas {<br>  ..state a search condition that might be used multiple times..<br>  ..append <em>blabla</em> to <strong>myVariables..</strong><br>}</pre><p>Imagine new engineers are coming to your repo and they have to search items in an array using that approach. The potential is high <strong>they will write redundant logics</strong> that actually do exist already because of their lack of knowledge about the repo besides the search conditions themselves are quite unorganized and decentralized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*wMGeNiqIECKE4Ctjtw2umw.jpeg" /></figure><p>By looking at that pain point. I started to think how can I solve this problem? That’s why this immature tiny library is out. This is how Fun-go’s <strong><em>filter</em></strong> function will come to rescue to save you from the pain:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/403254b528300258ddaf09c4c919642c/href">https://medium.com/media/403254b528300258ddaf09c4c919642c/href</a></iframe><p>Now, there will be no repetitive looping blocks that will blur your intention about what you are going to do with the data.</p><p>Everything looks clearer and more organized, various <strong><em>filter functions</em></strong> can be reused in another part of your code by simply calling them as you need using <a href="https://en.wikipedia.org/wiki/Higher-order_function">Higher-Order Function</a> technique. Reusable means reducing redundancy.</p><p>You are now also able to build filtering pipeline like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16d2485b1fa828dd9cfa9163d9b197b9/href">https://medium.com/media/16d2485b1fa828dd9cfa9163d9b197b9/href</a></iframe><p>If you want to find other examples related to <em>map</em> and <em>reduce</em> function. You can go to my Github repo: <a href="https://github.com/parinpan/fun-go">https://github.com/parinpan/fun-go</a></p><h3><strong>Benchmark</strong></h3><p>Tested on MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports) 2 GHz Intel Core i5 8 GB 1867 MHz LPDDR3 with 1,000,000 data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*tDGTuBEzr8eAmidAONVWdg.png" /></figure><h3><strong>Conclusion</strong></h3><p>Golang is fun. It’s agnostic to particular programming paradigms. Well, I can’t say it’s good enough to implement some of functional programming principles on it but still possible and brings us to a better approach of how we program.</p><h3><strong>Disclaimer</strong></h3><p>I’m not an expert in functional programming. Only a great fan of it! :)</p><p><em>Anyway, If you have any inquiry; you can contact me on: </em><a href="https://www.linkedin.com/in/fachrinfan/"><em>Linkedin</em></a><em> or </em><a href="https://twitter.com/fachrinFAN"><em>Twitter</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a57bfc27ec90" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/golang-is-agnostic-to-particular-programming-paradigms-heres-why-a57bfc27ec90">Golang is agnostic to particular programming paradigms. Here’s why.</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>