<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pedro Neto</title>
    <description>The latest articles on Forem by Pedro Neto (@pedroduarten9).</description>
    <link>https://forem.com/pedroduarten9</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F306394%2F4f48b3c6-14c9-42bc-b78e-51eeabb9efe4.jpeg</url>
      <title>Forem: Pedro Neto</title>
      <link>https://forem.com/pedroduarten9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pedroduarten9"/>
    <language>en</language>
    <item>
      <title>The last functional programming post</title>
      <dc:creator>Pedro Neto</dc:creator>
      <pubDate>Thu, 30 Jan 2020 13:32:52 +0000</pubDate>
      <link>https://forem.com/pedroduarten9/the-last-functional-programming-post-3cig</link>
      <guid>https://forem.com/pedroduarten9/the-last-functional-programming-post-3cig</guid>
      <description>&lt;p&gt;In the last few years, we have seen lots of buzz around functional programming.&lt;br&gt;
There is a new post every day, each reminding us of the same old stuff, functions, purity, no side effects, referential transparency...&lt;br&gt;
By now I hope that everyone with at least a little experience in the business knows the basics of functional programming.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;So where is the magic?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Functional programming is more than a few snippets of code, like every other paradigm it is based on concepts, and usually, mastering the concepts gives us transferable skills, and that's what we should be aiming for.&lt;br&gt;
So, instead of showing you how you can use map, filter or reduce to achieve something, I'll explain to you why.&lt;br&gt;
Functional programming has a few unique concepts that we all know, like the ones stated above (functions, purity, no side effects, referential transparency).&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Why use functional programming?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Short answer, multi-threading.&lt;br&gt;
Our computers have become very fast in the last few years and we cannot increase their speed a lot. This gives us one answer, increase the cores so we can have more working force.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;How does functional programming solve this?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It doesn't, it helps the programmer deal with this, because if we had a functional project running on 1 thread it would be the same as running on 10, remember no side effects, referential transparency, so it's safe.&lt;br&gt;
On the other hand, the majority of the codebases have a lot of side effects which causes programmers a lot of trouble to use multi-threading.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;How do we work with a world of pure programming?&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;We don't.&lt;br&gt;
We need I/O and we need to have different states.&lt;br&gt;
If we have none of that, then we get a heating machine instead of a computer.&lt;br&gt;
The question instead should be how do we approach I/O and state?&lt;br&gt;
Regarding I/O we must encapsulate it in functions with good names that explicitly shows us that we are dealing with impurity.&lt;br&gt;
Regarding state, all of us should be using event sourcing so we never lose data and always can retrieve a state at any point in time.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Bonus&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Our brain processes everything sequentially making functional programming and declarative syntax anti-natural.&lt;br&gt;
We must approach declarative syntax by shifting our mindset to one where we try to understand how do we accomplish our goals.&lt;/p&gt;

&lt;p&gt;Example: map transforms a sequence. &lt;br&gt;
In imperative syntax, we should see a for loop iterating and transforming the sequence. &lt;br&gt;
In declarative syntax, we have a map, a function we know will transform a sequence, so we give it a sequence and a function that tells it how to transform each element.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Functional programming is a lot more than most of the posts about it, I am still and will always be learning it.&lt;br&gt;
But remember that the best learning approach is by investing in transferrable skills instead of a language or framework.&lt;/p&gt;

</description>
      <category>functional</category>
      <category>career</category>
    </item>
  </channel>
</rss>
