<?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>DEV Community: Jiří Rejman</title>
    <description>The latest articles on DEV Community by Jiří Rejman (@rejmank1).</description>
    <link>https://dev.to/rejmank1</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%2F531850%2Fa8db2217-f59a-4cfe-828c-fd607debb08e.jpg</url>
      <title>DEV Community: Jiří Rejman</title>
      <link>https://dev.to/rejmank1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rejmank1"/>
    <language>en</language>
    <item>
      <title>The DevOps handbook - summary</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Tue, 15 Feb 2022 10:04:38 +0000</pubDate>
      <link>https://dev.to/rejmank1/the-devops-handbook-summary-1hge</link>
      <guid>https://dev.to/rejmank1/the-devops-handbook-summary-1hge</guid>
      <description>&lt;p&gt;DevOps handbook is one of the most important DevOps books on the market. It combines the most important DevOps ideas, examples from known companies, and best practices. It does not have any code so it is an ideal book for non-technical readers that would like to know what their teams are talking about. Bellow, you find a summary with the ideas that stick with me the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  Flow and Feedback
&lt;/h2&gt;

&lt;p&gt;The first thing we want to accomplish in DevOps is to have fast feedback on our work. The first frontier, before the ultimate testing on production, is a set of well-written fast tests. Those tests should be able to run in parallel and they should be run on each commit automatically. Tests that are not run are useless, and the only way to enforce running those tests is using automation. This allows us to have basic confidence in our code and the fast feedback provided by fast pipeline should not break the flow. The testing should be not limited to unit tests but it can (and should) test also security, integration, and other aspects of our application. Important is to run different tests on different occasions (run slow tests less often) to not break the developer`s flow.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...a small number of reliable, automated tests are almost always preferable over a large number of manual or unreliable automated tests.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Get it out!
&lt;/h2&gt;

&lt;p&gt;You will never test everything. In production, someone will always do something you do not expect, try to hack you, or will not use your shiny feature at all. And the only way to test this is to go to production as fast as possible. This is the only way to test (almost) every possible scenario and see the outcomes. Of course, going fast to production have its dangers but we can mitigate them using tools such as shadow releases, canary testing, or blue-green release pattern. With frequent releases, we generally get smaller release sizes which is associated with a higher deployment success rate.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...when we increase our deployment batch size, our change success rates go down and our incident counts and MTTR go up—the opposite of the outcomes we want.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Observer and learn
&lt;/h2&gt;

&lt;p&gt;If we put our code into production we need to have a way to observe the code running. Other than standard metrics such as CPU and Memory usage, percentage of a cache hit, and other technical measures we should also have business metrics available. Does our new feature that is promoted everywhere have poor usage? It might be caused by a technical issue such as poor performance or distorted render on some browsers. The second case can be that we simply build the wrong thing. Both outcomes are valuable for us developers so we should have access to those metrics to be able to learn from them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...business metrics create context for our infrastructure metrics, enabling Development and Operations to better work together toward common goals.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Involve everyone
&lt;/h2&gt;

&lt;p&gt;One of the most important lessons for me was how important is to make everyone more exposed to other team's problems. In the end, we all work toward a common goal. By being more exposed to problems of developers, testers, or ops we can often find better solutions to problems, fix the problems earlier, cheaper and build empathy for other teams.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...how to make Dev work more visible to Operations. To accomplish this, we explored three broad strategies, including creating self-service capabilities to enable developers in service teams to be productive, embedding Ops engineers into the service teams, and assigning Ops liaisons to the service teams when embedding Ops engineers is not possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The DevOps handbook is one of the technical books that will fill your head with ideas. It will not teach you how to create an ideal pipeline, nor it will give you the answers to all problems but it will tickle those parts of your brain that know that our job can be done better. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Our call to action is this: no matter what role you play in your organization, start finding people around you who want to change how work is performed. Show this book to others and create a coalition of like-minded thinkers to break out of the downward spiral.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you like the post, consider subscribing to my &lt;a href="https://rejmank.substack.com/?r=438li"&gt;substack&lt;/a&gt; &lt;/p&gt;

</description>
      <category>devops</category>
      <category>books</category>
    </item>
    <item>
      <title>how to start with devOps?</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Tue, 25 Jan 2022 15:56:04 +0000</pubDate>
      <link>https://dev.to/rejmank1/how-to-start-with-devops-1g6p</link>
      <guid>https://dev.to/rejmank1/how-to-start-with-devops-1g6p</guid>
      <description>&lt;p&gt;The internet is filled with tutorials for technologies and road maps with the premise of learning DevOps but in my opinion, the DevOps is less about technology and more about processes and mindset.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is DevOps?
&lt;/h2&gt;

&lt;p&gt;To start with DevOps we first need to know what DevOps is. Amazon defines DevOps as a &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a pretty good summary but see that it does not mention any particular technology. It is because it does not matter what technologies you use (but it can help), DevOps is about delivering &lt;strong&gt;high quality&lt;/strong&gt; at &lt;strong&gt;high velocity&lt;/strong&gt;. You don't need to use AWS, Kubernetes, and state of the art pipeline to do DevOps. The only requirement for DevOps is to be focused on the ability to deliver great products with high velocity. The tools and practices we use are just things that proved themselves to be the most efficient way to accomplish this. &lt;/p&gt;

&lt;h2&gt;
  
  
  So how to start with DevOps?
&lt;/h2&gt;

&lt;p&gt;To start with DevOps start to think not about which technology to use but rather how to enable faster delivery and more quality. Take your project and look where most of the issues are. Is it non-existing tests? Start there. Do you have old branches that are a pain to merge? Introduce short-lived branches. Do you have a problem with ops being slow to respond? Try to embed them into your daily work. The most important thing is to know why. Will it save any money? Will It make any money? With answers to these questions, you will have more support from the managers to grant you the time and resources needed to start with DevOps, the technologies will follow.&lt;/p&gt;

&lt;p&gt;If you like this article, subscribe to me on &lt;a href="//rejmank.substack.com"&gt;substack&lt;/a&gt; to get notified when next article arrive.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Habits to build
</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Sun, 16 Jan 2022 18:32:41 +0000</pubDate>
      <link>https://dev.to/rejmank1/habits-to-build-jcb</link>
      <guid>https://dev.to/rejmank1/habits-to-build-jcb</guid>
      <description>&lt;p&gt;The topic of habits is mentioned in almost every self-help book. And it is no wonder why. If I look back at what helped me last year it was just a few habits that had a tremendous impact on me. And the same seems to be true for my work as a developer. &lt;/p&gt;

&lt;h2&gt;
  
  
  Note-taking
&lt;/h2&gt;

&lt;p&gt;For me, note-taking was an ad hoc thing that was painful, but over time I managed to get better at it and even be able to have a system. The more projects, places to do things, and how to you will have the more you appreciate good note-taking systems. You will stop to ask your colleagues for that link to documentation and googling how to connect to that strange DB your backend is using, you just open your notes and there it will be.&lt;br&gt;
I use zettelkatsen combined with a second brain system but there are endless options. &lt;/p&gt;

&lt;h2&gt;
  
  
  Commit clean up
&lt;/h2&gt;

&lt;p&gt;Before each commit, I go through the diff, file after file, and fix all the small issues I found. Forgotten console.logs, commented code you name it I take care of this mess before it will go public. Doing this allows your coworkers to focus on important things during the code review, instead of focusing on where you left commented code. &lt;/p&gt;

&lt;h2&gt;
  
  
  Reading
&lt;/h2&gt;

&lt;p&gt;We work in an ever-changing environment, with new frameworks, libraries, languages... Regular reading will allow you to have an overview of the emerging technologies. Pick a few quality sources (Twitter accounts, newsletters...) and regularly check them. But have in mind that you do not need to learn everything you will read about.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overcoming Resistance
&lt;/h2&gt;

&lt;p&gt;Resistance is a concept from Steven Pressfield and his book war of art. For me regularly reminding myself that the reason why I want to "just check Twitter before I start to code that functionality" is just because I do not want to fight the resistance. &lt;/p&gt;

&lt;h2&gt;
  
  
  Automate
&lt;/h2&gt;

&lt;p&gt;You will break all your habits. Even the most bake in. So why not automate them? Running test before commit? Automate it, linting your code? The same. We have tools for all of this so take advantage of them and make your life easier. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Those are the most important habits that help me with my work. There is nothing magical about them and building them hurts, but working without them would hurt me much more.&lt;/p&gt;

&lt;p&gt;If you like this article follow me here or on twitter &lt;a href="https://twitter.com/rejmank1"&gt;https://twitter.com/rejmank1&lt;/a&gt;. Thanks!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Learning tech stuff</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Mon, 10 Jan 2022 18:06:11 +0000</pubDate>
      <link>https://dev.to/rejmank1/learning-tech-stuff-23l8</link>
      <guid>https://dev.to/rejmank1/learning-tech-stuff-23l8</guid>
      <description>&lt;p&gt;I was facing a problem. I need to learn Kubernetes... and I need to do it fast. Fortunately, I managed to learn a few other technologies so far but this time I wanted to make the learning as efficient as possible. To achieve this I connected several Ideas I get from reading about effective learning, together with my experience, and created a system that allowed me to get all my tasks done and be able to speak about Kubernetes in our internal conference in three months.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mnemonic medium
&lt;/h2&gt;

&lt;p&gt;The biggest influence on me so far had Andy Matuschak and Michael Nielsen with their &lt;a href="https://numinous.productions/ttft/"&gt;article about mnemonic medium &lt;/a&gt;. It is an idea of creating books combined with spaced repetition, which kind of forces the reader to engage with content repeatedly and think about it. This is a great way to remember facts and think about the material in a long run. The biggest problem is to create good prompts, fortunately, there is a &lt;a href="https://andymatuschak.org/prompts/"&gt;great long read&lt;/a&gt; about this topic which helped me a lot. &lt;/p&gt;

&lt;h2&gt;
  
  
  Zettelkatsen
&lt;/h2&gt;

&lt;p&gt;I discovered the zettelkatsen from Eliska Sestakova and her awesome &lt;a href="https://eliskasestakova.cz/"&gt;blog&lt;/a&gt; (CZ only) and the biggest treasure of this system for me is the connection. I write notes about the topic that I am learning using short paragraphs and linking the paragraphs together to create a graph connecting the ideas across the document. Reading this feels more like a gliding between topics and exploring rather than a sequential flow of information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Accelerated learning
&lt;/h2&gt;

&lt;p&gt;I stumbled across accelerated learning through this &lt;a href="https://commoncog.com/blog/accelerated-expertise/"&gt;article&lt;/a&gt; by Cedric Chin. The article gave me a pretty good sense of how knowledge learning differs from skills learning. We often hear that the best way to learn is using spaced repetition, this is great for knowledge but we have no clue if this works the same way for skills.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...spaced repetition has mostly been shown to work for knowledge retention, not skill retention; second, in general, studies tell us that skills tend to be retained for a longer period than knowledge. The authors note that we currently lack a good empirical base for skill retention.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The article (book) offers a way to better teach skills. It is not that revolutionary but I think it is often underused. The article advises to create a set of &lt;strong&gt;hard&lt;/strong&gt; simulations based on input from domain experts and letting the learners practice. The task for me should be an exciting quest that sends me on the learning journey. The only problem with quests is that they are often not that easy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Together
&lt;/h2&gt;

&lt;p&gt;Putting those three concepts together I created an article about Kubernetes which started with a difficult task. The article contained paragraphs with a description of a single concept, as a pod, accompanied with a few flashcards with the most important concepts, names, etc. Those paragraphs were interconnected. Learning using this format felt explorative. I usually started with the task and used the article as a guide through the exercise. During the tasks I did a ton of notes and since I am the one creating the article for myself, correcting mistakes I found out. I use the spaced repetition "cards" in the evening as a habit. The evening practice takes a few minutes but it often showed me where my blind spots were. The process of learning was more difficult than just reading a book but the amount of information I really understand was beyond comparable. &lt;/p&gt;

&lt;h2&gt;
  
  
  Where to continue?
&lt;/h2&gt;

&lt;p&gt;The last thing that remains to explore is if using the format itself is useful or the learning is in the creation of the whole workbook. I will definitely explore the area and will be back, either with publishing one of my learning workbooks or with some results on a quinea pig. To get notified when this happens subscribe to my substack.e results on a quinea pig. To get notified when this happens subscribe to my articles or to my &lt;a href="https://twitter.com/rejmank1"&gt;twitter&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title> Why I started to fall in love with go</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Tue, 23 Mar 2021 16:47:31 +0000</pubDate>
      <link>https://dev.to/rejmank1/why-i-started-to-fall-in-love-with-go-2e5g</link>
      <guid>https://dev.to/rejmank1/why-i-started-to-fall-in-love-with-go-2e5g</guid>
      <description>&lt;p&gt;I am a JavaScript developer by soul. In school, I have had java classes and before the first job I played with some python but since I switched to JavaScript I newer looked back. I could build a frontend in it and after I learned node even server-side things. The language has its shortcomings and quirks but overall it is a nice, simple language that gives you a lot of power at your fingertips with a huge ecosystem of libraries. But I felt that I need to have a second tool under my belt so recently I started to search for my second language. &lt;/p&gt;

&lt;h2&gt;
  
  
  What do I want from a second language?
&lt;/h2&gt;

&lt;p&gt;The reason I wanted to learn a second language, other than a pure curiosity, was that I want to have something that can be used for some heavy lifting. I also wanted to learn a language that is using static typing to see the benefits and drawbacks myself. A nice benefit would be if there are some jobs using the language.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I tried so far?
&lt;/h2&gt;

&lt;p&gt;I tried F# and Rust so far but non of them hook me for a long time.&lt;/p&gt;

&lt;p&gt;F# is a great functional language. In my opinion, there is no better place to learn typed functional programming. After some tutorials and exercises, I hit the ecosystem wall. I just was not willing to learn about the ecosystem. &lt;a href="https://dusted.codes/dotnet-for-beginners"&gt;This article&lt;/a&gt; summarizes my experience pretty well. If you add that the F# community seems to prefer frameworks over libraries, it was something that I simply did not have enough grit for.&lt;/p&gt;

&lt;p&gt;Rust was a little bit different. I finished the rustlings but I was not able to write anything. It was just too many new concepts for me to learn. The power of language is huge, immutability first, and support for functional programming is also great but for someone who never worked with typed language much, it was just too hard.&lt;/p&gt;

&lt;p&gt;Just to be clear, those objections against languages say more about me than about languages. I would be more than happy to use them in my job. But for my side projects and as a second language I just did not have the grit. &lt;/p&gt;

&lt;h2&gt;
  
  
  Go
&lt;/h2&gt;

&lt;p&gt;Then I read an &lt;a href="https://sw-samuraj.cz/2018/09/golang-micro-services-prvni-ohlednuti"&gt;older article by sw-samuraj&lt;/a&gt; about his experience using GO in his job. He mentioned many positive aspects and one of them was that he felt using go was similar to writing code in clojure. This got my attention. I explored the language a little bit and after a week I spend learning to Go I am hooked. &lt;/p&gt;

&lt;p&gt;The main reason I am excited is simplicity. I was able to start coding fast. The language itself is small and has a really good standard library. Standard library have you covered for most of the day-to-day tasks from writing basic server to CSV parsing. The only thing I am missing is map, filter, and reduce. But there are libraries that can help with this and with the generics coming I expect a lot of FP libraries to pop up. &lt;/p&gt;

&lt;p&gt;The type system was easy to learn. It kind of surprised me after my experience with rust where most of my learning was how to do the types correctly. This might change with the generics but I would not expect a huge rise in complexity.&lt;/p&gt;

&lt;p&gt;Goroutines is another nice thing. I did not use them much so far but they influenced clojure core.async library and also is one of the selling points of language so I expect them to be great.&lt;/p&gt;

&lt;p&gt;With Go, you have enough speed that you can tackle almost anything from image processing to machine learning. This makes go universal language and a big plus for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So far I have had a pretty good experience with go. I was amazed at how fast I created some simple scripts. The learning curve is smooth and the community and resources are great. It is hard not to fall in love with go.&lt;/p&gt;

</description>
      <category>go</category>
    </item>
    <item>
      <title>The usefulness of currying</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Sat, 20 Feb 2021 17:06:24 +0000</pubDate>
      <link>https://dev.to/rejmank1/the-usefulness-of-currying-38hb</link>
      <guid>https://dev.to/rejmank1/the-usefulness-of-currying-38hb</guid>
      <description>&lt;p&gt;In the &lt;a href="https://rejmank.com/post/functional-pipe"&gt;last article about pipe&lt;/a&gt; I wrote that while using a pipe to compose functions, those functions start to look like lego pieces. But what would you do if the pieces don't fit together? In a functional toolbox, there is a tool for that, it is called pipe and it is something that every functional programmer should have under their belt.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is curry?
&lt;/h2&gt;

&lt;p&gt;Currying allows us to create a new function by providing some parameters for that function ahead of time. Let me show you this on some code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// we have one general function that counts the discount&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;countDiscound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;discountInPercent&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;originalPrice&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;discountInPercent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="c1"&gt;// Here we have single purpose function that we want to use somwhere in program&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;countSeventyPercentDiscount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;originalPrice&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// There is easier way to create the specific functions, because we curried general&lt;/span&gt;
&lt;span class="c1"&gt;// function we can use it to create the same functions as above, while using the&lt;/span&gt;
&lt;span class="c1"&gt;// original multipurpose function&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;countSeventyPercentDiscount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;countDiscound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;countSeventyPercentDiscount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;countDiscound&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the difference yourself, the functions we created with curry use less code, do not repeat the same logic and thus it obey the DRY (don't repeat yourself) principle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Specific functions
&lt;/h2&gt;

&lt;p&gt;Curry allows us to create single-purpose functions from generic functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// parse imported from date-fns/fp is already curied&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;parse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;date-fns/fp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// we create new function that help us parse some internal date string&lt;/span&gt;
&lt;span class="c1"&gt;// we can now use it in the rest of our program&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parseInternalTimeString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h:mmaa&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsedInternal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parseInternalTimeString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;06:30AM&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 2021-02-19T05:30:00.000Z&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other than saving some lines of code, this approach also has another, not so obvious benefit, it increases readability. If you encounter the parse function used like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parsedDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h:mmaa&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;06:30AM&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does not exactly tell you that the parsed string is some company internal format and it also reveals the detail you don't necessarily need to know, the format for parsing. Every time you want to parse the internal time string you need to remember or search for parse string. On the other hand, using the curried function the name itself reveal that you can use it on internal time strings, and to use it you do not need to know anything. This technique is beneficial if you do domain-driven design.&lt;br&gt;
Currying has also a huge benefit for composition. Recently I needed to parse the date that was included in the filename I used composition as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;parse&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;date-fns/fp&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDateFromFileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.csv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;h:mmaa&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;getDateFromFileName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;06:30AM.csv&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 2021-02-19T05:30:00.000Z&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Curry, in this case, allowed me to create a simple function that parses the filename. All three functions benefit from curry, without curry we could not use Pipe and without pipe our code would be much less readable. It would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date-fns/fp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getDateFromFileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;h:mmaa&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.csv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;getDateFromFileName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;06:30AM.csv&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// 2021-02-19T05:30:00.000Z&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have at least a little bit of experience with pipe, you red the first function without any problems. The second version on the other hand takes at least a little bit of effort and switches reading order from left to right to right to left.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does curry work?
&lt;/h2&gt;

&lt;p&gt;When I was learning about closures, understanding how curry works internally was really helpful for me. So let's take a look at one, naive implementation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// this implementation requires the first argument in the time we curry it&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;curryOne&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;parameter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// the function returns new function, it remembers the first parameter using closure&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;secondParam&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// after we call the returned function, it calls the original function with all&lt;/span&gt;
    &lt;span class="c1"&gt;// parameterers and return the result&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parameter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;secondParam&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addFive&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curryOne&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;addFive&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 11&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This implementation of curryOne (it can help to curry only one parameter) works by using closure to remember the first parameter. And this is all the magic that closures have. Although this code is a nice example of using closure do not use it in production or as your curing solution, rather use ramda.&lt;/p&gt;

&lt;h2&gt;
  
  
  What if the parameters are in the wrong order?
&lt;/h2&gt;

&lt;p&gt;There is often the situation that you want to curry some function but the parameters are in the wrong order. Luckily we have a solution for this in our functional toolbox. The first one is &lt;strong&gt;a flip&lt;/strong&gt; function. What flip does is that it takes a function, &lt;strong&gt;switches parameters order&lt;/strong&gt;, and returns the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;flip&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subtract&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;getSomeNumber&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="c1"&gt;// now we want to substract 10 from number we got&lt;/span&gt;
  &lt;span class="c1"&gt;// we first flip the parameters order and then curry the function&lt;/span&gt;
  &lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;flip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subtract&lt;/span&gt;&lt;span class="p"&gt;))(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we have already curried function we can use &lt;strong&gt;__&lt;/strong&gt; function t*&lt;em&gt;o skip some of the parameters&lt;/em&gt;*. For example, we can use ramda map function and create a function that accepts a function and apply it to predefined data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;applyFunctionOnArrayOfNumbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Partial
&lt;/h2&gt;

&lt;p&gt;Another function that allows us to do a similar thing as curry in ramda is partial. The difference between currying and partial application is subtle and rather academic. In ramda the difference is that using partial you can provide an array of parameters to a function, instead of supplying the parameters as one after another. If you are interested in the differences between curry and apply I recommend this article from &lt;a href="https://2ality.com/2011/09/currying-vs-part-eval.html"&gt;2ality.com&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;partial&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addThree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addToThree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;partial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;addThree&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="nx"&gt;addToTrhee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Currying is one of the most practical things that functional programming can offer you. It gives you the flexibility to create small single-purpose functions, allows you to create better compositions, and profit from the functional paradigm even more. Combined with pipe you will be amazed at the beauty your fingers will produce.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
      <category>programming</category>
    </item>
    <item>
      <title>Why use pipe?</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Mon, 15 Feb 2021 20:01:47 +0000</pubDate>
      <link>https://dev.to/rejmank1/the-inconspicuousness-of-the-pipe-4n54</link>
      <guid>https://dev.to/rejmank1/the-inconspicuousness-of-the-pipe-4n54</guid>
      <description>&lt;p&gt;I would describe pipe as a magic door into functional programming. At the first sight, I didn't get the pipe. It seemed so obsolete, but since I started to write them all other functional concepts suddenly started to clicking together. So how to start opening the doors into the &lt;del&gt;Narnia&lt;/del&gt; functional programming world?&lt;/p&gt;

&lt;h2&gt;
  
  
  What does pipe do?
&lt;/h2&gt;

&lt;p&gt;The pipe is just a function that creates other functions by composing them. Okay, this didn't help. Let me try it again. Imagine that you have three &lt;a href="https://rejmank.com/post/pure-functions"&gt;pure functions&lt;/a&gt;. And you want to call them all, in sequence on one piece of data. Something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fromatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./myModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;format1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is called composition and it is a cornerstone of functional programming. But functional toolkit has a way to write this nicer the mighty pipe.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fromatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./myModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatWithPipe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;formatWithPipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pipe just takes all the functions and spits out a new function. When you call the new function with data those data go through all functions in pipe.&lt;/p&gt;

&lt;h2&gt;
  
  
  The readability benefit
&lt;/h2&gt;

&lt;p&gt;Let's look at the code we have above once again, try to read all three functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fromatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./myModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;format1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;format2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;splited&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fomatedItems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;splited&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fomatedItems&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;format3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you examine the first function it seems ok, this is an example of nice composition, but it has one problem, you need to read it from right to left. We are not used to reading out programs right to left so it breaks the reading flow.&lt;br&gt;
The second version does not force you to switch the reading order but it is lengthy and the reading order is zig-zag so not ideal either.&lt;br&gt;
At first sight, the pipe does not help that much but with time you will simply read the function from the top to bottom and immediately get an idea about what the function does. Reading flow, in this case, is the same as with other code and the function is nicely compact.&lt;br&gt;
TIP: There is often a question about how to do logging inside pipe. Although we should strive to have our pipes pure during the development the console.log is one of the most helpful things. So how to do it? Just use R.tap, it allows you to log anywhere in your pipe. The other option is to create a log function, where you can specify other parameters like what to print before data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fromatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;filterItems&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./myModule&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;_log&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;curry&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;format3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;splitData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;_log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;some string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="nx"&gt;formatItems&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// logs the data after formatItems&lt;/span&gt;
    &lt;span class="nx"&gt;filterItems&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;format3&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  A better understanding of functional tools
&lt;/h2&gt;

&lt;p&gt;Other than looking good and increasing readability, the pipe has other benefits that are not apparent at the first sight. The pipe helps you understand the purpose of other functional concepts like curry, flip, map, etc. When I started to use pipe all the other functions started to make sense. With pipe functions become lego pieces that from time to time do not fit together. Functional tools often help you transform your legos that it fits together nicely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pipe pushes you to write better functions
&lt;/h2&gt;

&lt;p&gt;Another benefit of piping is that it pushes you to write better functions. You will find out that your functions suddenly have fewer inputs, they are pure and when you start to write a bigger function, you start to think about how to split it so it would compose nicely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the beginning, pipe seems like just syntactic sugar with no value-added. But the readability benefit and the way it pushes you to write your code start to be apparent as soon as you write a few of them. Try it out, once you get used to it you will never look back.&lt;/p&gt;

&lt;p&gt;If you like this post check out other posts &lt;a href="//www.rejmank.com"&gt;on my website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
      <category>ramda</category>
    </item>
    <item>
      <title>Why I use date-fns
</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Fri, 05 Feb 2021 14:25:25 +0000</pubDate>
      <link>https://dev.to/rejmank1/why-i-use-date-fns-1l4f</link>
      <guid>https://dev.to/rejmank1/why-i-use-date-fns-1l4f</guid>
      <description>&lt;p&gt;For a long time, momentjs was almost a standard for working with dates in JavaScript. It had several drawbacks such as size, no support for tree shaking, mutations... and it was also abandoned recently. So the natural question arose, what to use instead? For me, the answer is clear date-fns. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why not use native functions?
&lt;/h2&gt;

&lt;p&gt;You can be almost sure that modern JavaScript date object have all you need in order to work with dates. There were always several drawbacks for me. For example, subtract the specified number of days from date looks like this in native JS and date-fns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Native JavaScript&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// date-fns&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;subDays&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date-fns/subDays&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;subDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I encounter a native version in the code I need to stop and think about what it actually does. Looking at date-fns version I just know what the code does. &lt;br&gt;
Another factor is that in order to work with dates I often need to use regex to parse the date from string or recount the number of days to milliseconds which is both things that I can easily make mistake in, or forget to test some edge cases.&lt;/p&gt;
&lt;h2&gt;
  
  
  Functional
&lt;/h2&gt;

&lt;p&gt;Date-fns have great support for functional programming. In module 'date-fns/fp' you can find all functions already curried and with switched order of parameters. If you don't know what currying is no worries, I am preparing a series about ramda and FP, or check out functional light javaScript. This makes usage with Ramda or Lodash breeze. &lt;br&gt;
Another big benefit is that all functions in date-fns are pure. In this case, the main benefit of purity is that if I supply the function date, the date itself remains unchanged and a new date is returned instead.&lt;br&gt;
Just look at the beauty:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;R&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ramda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;addYears&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;format&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;date-fns/fp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="c1"&gt;// we create new function that add five years and format the output&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;addFiveYearsAndFormat&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;R&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pipe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;addYears&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="nx"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;y-M-dd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;// we can call the function anywhere with any date object&lt;/span&gt;
&lt;span class="nx"&gt;addFiveYearsAndFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// '2026-2-04'&lt;/span&gt;
&lt;span class="c1"&gt;// addYears is pure function so it did not change the input&lt;/span&gt;
&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;getFullYear&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// 2021&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Great documentation and completeness
&lt;/h2&gt;

&lt;p&gt;The documentation for date-fns is great. For each function, you will find a bunch of examples, what the function returns and what exceptions it can throw. The only thing that I miss is some kind of playground similar to Ramda documentation. &lt;br&gt;
That level of documentation is even more impressive if you take into account how many functions does the library provides. So far I did not encounter anything that the library does not have. From parsing to working with ranges, comparing to formatting the date-fns have it all. &lt;br&gt;
Great is also support for tree shaking that can save you a bunch of kilobytes from your bundle. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Date-fns is a great library. If you need to work with dates this library provides everything you need and a bunch of extra things on top. If you are still not convinced check out the &lt;a href="https://date-fns.org/"&gt;documentation&lt;/a&gt; or &lt;a href="https://github.com/you-dont-need/You-Dont-Need-Momentjs#quick-links"&gt;this awesome repository&lt;/a&gt; that compares other options for working with dates.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>functional</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The value of feedback</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Wed, 03 Feb 2021 18:20:38 +0000</pubDate>
      <link>https://dev.to/rejmank1/the-value-of-feedback-1j08</link>
      <guid>https://dev.to/rejmank1/the-value-of-feedback-1j08</guid>
      <description>&lt;p&gt;Writing software is a complex job full of learning. We learn not only new technologies but also domains and avoiding disasters in production. From my experience, the best learning tool is fast feedback. Embracing it in all aspects of your development process will make your progress skyrocket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback as a tool
&lt;/h2&gt;

&lt;p&gt;Feedback is a tool to make your output and you better. If you submit your code to a colleague, to do a code review he will point out the mistakes you did and, in the best scenario, he will help you understand the issues and fix your code. Both of you are gaining from this situation. Bad code was not pushed to production, you learned how to write better programs and next time there will be a third of the issues. If you would not get the feedback you might to found out the issues later either as a bug or as technical debt and the cost of learning will be much higher.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback and current development practices
&lt;/h2&gt;

&lt;p&gt;If you look at the current trends in software development, you can see that a lot of what is an everyday practice for us is some form of getting fast feedback. For example, writing tests. Without them, it is like playing a musical instrument without hearing it. You are almost sure that you are playing the right notes, but you cannot be sure. There is no better way to get fast feedback than by running a suite of good tests (okay, maybe Clojure and its repl driven development). Continues integration and continuous delivery allow us to ship software faster to get feedback from users and real-life situations as fast as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem with receiving feedback
&lt;/h2&gt;

&lt;p&gt;Receive and accept feedback is tough. Ego, fear, and expectations get in the way of receiving it. But I have some good news for you, as with everything you get better at it. You learn how to separate yourself from the feedback and take what is going to move you forward. For me, there were a few books that helped me with this namely &lt;a href="https://www.amazon.com/Mindset-Updated-Changing-Fulfil-Potential/dp/147213995X"&gt;mindset&lt;/a&gt; by Dr. Carol Dweck and &lt;a href="https://www.amazon.com/Creativity-Inc-Overcoming-Unseen-Inspiration-ebook/dp/B00GUOEMA4/"&gt;Creativity inc.&lt;/a&gt; by Ed Catmull. Giving someone feedback is maybe an even bigger problem but I do not feel like having enough experience to write about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Getting feedback is an often big step out of your comfort zone. You may show someone something terrible but if you don't put your skin in the game it stays terrible. If you get feedback, you have the opportunity to make it better.&lt;/p&gt;

&lt;p&gt;If you like this article follow me on Twitter &lt;a href="https://twitter.com/rejmank1"&gt;https://twitter.com/rejmank1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>productivity</category>
      <category>learning</category>
      <category>feedback</category>
    </item>
    <item>
      <title>Fundamentals of software architecture - review </title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Wed, 27 Jan 2021 18:16:43 +0000</pubDate>
      <link>https://dev.to/rejmank1/fundamentals-of-software-architecture-review-1jam</link>
      <guid>https://dev.to/rejmank1/fundamentals-of-software-architecture-review-1jam</guid>
      <description>&lt;p&gt;One of my resolutions for 2021 is to get more into software architecture. As an entry point for this topic, I chose fundamentals of software architecture by Mark Richards and Neal Ford. It was a great starting point and in this review, I will tell you why. &lt;/p&gt;

&lt;h2&gt;
  
  
  The great
&lt;/h2&gt;

&lt;p&gt;The bread and butter of this book is a middle part that describes eight architecture styles. Each one is described in enough detail but without any unnecessary clutter. Great are practical examples that point out the weaknesses and strengths of each described architecture. The architecture styles also come with a handy table that can serve as a quick overview of the strengths and weaknesses of each architecture style. We will see how quickly will this part get old but until that, it will be a go-to resource for me when doing initial research on how to approach a problem from an architectural point of view. &lt;/p&gt;

&lt;h2&gt;
  
  
  The mind-bending
&lt;/h2&gt;

&lt;p&gt;The book, in the first part, goes over basic architectural knowledge such as modularity, coupling, components... What was completely new for me was the introduction of formal methods of evaluating architecture characteristics. This part of the book is on my bucket list to read again in the hope to understand it better than during the first read. This part was also the hardest to read but for me, that is always a good sign of learning, so be prepared and take your time, it is worth it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The not so good
&lt;/h2&gt;

&lt;p&gt;The last part of the book focuses mainly on softer parts of the architect job. There are good parts (I enjoyed the risk analysis part and Architecture decision records) but overall I had a feeling that this is something "extra". If this is what you would like to get from architecture book, look somewhere else.  &lt;/p&gt;

&lt;h2&gt;
  
  
  The Conclusion
&lt;/h2&gt;

&lt;p&gt;The fundamentals of software architecture was a great introduction to the topic of software architecture. The technical parts are excellent with great examples. The book is worthy of your time, you get a great overview of the discipline and a great handbook for everything architecture related.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>books</category>
    </item>
    <item>
      <title>JavaScript learning resources</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Thu, 21 Jan 2021 16:11:35 +0000</pubDate>
      <link>https://dev.to/rejmank1/javascript-learning-resources-2dfd</link>
      <guid>https://dev.to/rejmank1/javascript-learning-resources-2dfd</guid>
      <description>&lt;h1&gt;
  
  
  Javascript learning resources
&lt;/h1&gt;

&lt;p&gt;This article is a compilation of resources I would use again while learning a node.js or react. It contains everything from free articles, paid courses to books. There are not sorted in any particular order.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/leonardomso/33-js-concepts"&gt;33 JS concepts&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;What is great about this collection is that it sums up all the things that you should be at least familiar with while using JavaScript. I would focus mostly on the understanding &lt;strong&gt;call stack&lt;/strong&gt;, &lt;strong&gt;function scope, block scope, lexical scope&lt;/strong&gt;, &lt;strong&gt;Message Queue, and Event loop&lt;/strong&gt;, &lt;strong&gt;closures&lt;/strong&gt;, &lt;strong&gt;map, reduce filter&lt;/strong&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/goldbergyoni/nodebestpractices"&gt;Node best practices&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Another git collection. This time of best NodeJS practices. I cannot say that I agree with everything on 100% but it is a great starting point when you try to do your next project the right way.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="//www.frontendmasters.com"&gt;Frontend masters&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;This is an awesome company producing awesome content. The price is a little higher than usual but it is worth every penny. The courses are recorded lections from practitioners and the quality of content is high. I would recommend courses from Kyle Simpson, Scott Moss, and Brian Londsdorf, but in the end, I did not encountered a bad course so pick what you are interested in.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/getify/You-Dont-Know-JS"&gt;You don't know JavaScript&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;If you want to go deep in JavaScript this is a go-to source for me. What I like about this series is that id does not leave out the quirky parts of JavaScript (looking at you JavaScript the good parts!) but forces you to understand them. Kyle Simpson has the unusual talent to describe difficult topics approachable. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://github.com/getify/Functional-Light-JS"&gt;Functional light JS&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Another book by Kyle Simpson. This time introduction to functional programming focusing on the important topics that you can apply immediately. I recommend pairing this book with his course on the same topic from frontend masters. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://www.roadtoreact.com/"&gt;The road to React&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;I learned to react to this eBook. I remember it was a really good introduction. I build some basic react app alongside this book as a reference source.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other
&lt;/h2&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://epicreact.dev/"&gt;Epic react dev&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;If I would like to go deeper in React or need to refresh it I would grab the epic react dev from Kent C. Dodds. I received a pretty good impression from everyone who bought the course, even senior react devs so this would be the choice for me. &lt;/p&gt;

&lt;p&gt;If you liked this article follow me on twitter &lt;a href="https://twitter.com/rejmank1"&gt;https://twitter.com/rejmank1&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The beauty of pure functions</title>
      <dc:creator>Jiří Rejman</dc:creator>
      <pubDate>Sat, 16 Jan 2021 17:15:37 +0000</pubDate>
      <link>https://dev.to/rejmank1/the-beauty-of-pure-functions-9m9</link>
      <guid>https://dev.to/rejmank1/the-beauty-of-pure-functions-9m9</guid>
      <description>&lt;p&gt;Starting with functional programming is hard. There is a ton of new concepts to learn, new terms, and sometimes even a new language. But there is one simple concept that can make your programs better immediately. Pure functions. These functions are easy to understand, easy to write but they will have a tremendous impact on your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are pure functions?
&lt;/h2&gt;

&lt;p&gt;In short pure functions are functions that have no side effect and for each combination of parameters they return the same output. In reality, that means that you cannot request a database, make HTTP requests, use random inside them, or call functions that do so. No side effect means that they cannot change anything, not event their inputs. If you want to know more about pure function this is a good start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pure functions are guide to better architecture
&lt;/h2&gt;

&lt;p&gt;Using pure function means that you restrict yourself. That restriction forces you to think of better solutions for your problems. Recently I wrote an app that needed to work with a date. The first solution I think of was something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;doingDirtyThings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// do something&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;workWithDate&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;// do something else&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;workWithDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="c1"&gt;// work with date...&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;someData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you look at the functions, none of them is pure. the creation of date is a side effect and it makes the workWithDate function hard to test. I would let the code like this if part of my brain would not scream IT IS INPURE! The solution, in this case, is to move the creation of the date to doingDirtyThings function. This way we can easily test the workWithDate function just by supplying the created date as input. In the end, I needed to reuse the date later in the program so this change made everything easier.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;doingDirtyThings&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// do something&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;date&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;workWithDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// do something else&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;workWithDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;date&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// work with date...&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;someData&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Pure functions improve testability
&lt;/h2&gt;

&lt;p&gt;I started to like writing tests since I started to write pure functions. The reason is that with pure functions the tests take almost no effort. You just import the function, throw some values at it, and look at the results. There is no mocking, no setup just values. Of course, you have to test the dirty parts of your app too, but the dirty parts are usually significantly smaller.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pure functions help keep functions small and focused
&lt;/h2&gt;

&lt;p&gt;Writing big bloated functions that are also pure is hard. I often find myself wondering how to avoid mutation and often the answer is: split the function! This gives you the benefit of better composability and it is much easier to reason about a small function that has single responsibility rather than a big bloated function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using pure functions helps to reason about code
&lt;/h2&gt;

&lt;p&gt;There are simply fewer moving parts. That means that fewer things can be broken. In pure functions, the only thing that can be broken is function logic.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If there is one concept from functional programming you should know it is pure functions. As soon as you write a few of them you will encounter other benefits as easier composability etc. I hope that this article encouraged you to write more pure functions, the world needs it&lt;/p&gt;

&lt;p&gt;You can this and more articles from me at &lt;a href="https://rejmank.com/post/pure-functions"&gt;https://rejmank.com/post/pure-functions&lt;/a&gt;&lt;/p&gt;

</description>
      <category>functional</category>
      <category>javascript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
