<?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: Dave Howson</title>
    <description>The latest articles on DEV Community by Dave Howson (@davehowson).</description>
    <link>https://dev.to/davehowson</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%2F381967%2F8c59fead-add6-4563-9afc-86285c71bc34.png</url>
      <title>DEV Community: Dave Howson</title>
      <link>https://dev.to/davehowson</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/davehowson"/>
    <language>en</language>
    <item>
      <title>An Introduction to Functional Programming</title>
      <dc:creator>Dave Howson</dc:creator>
      <pubDate>Sat, 08 May 2021 07:43:03 +0000</pubDate>
      <link>https://dev.to/davehowson/an-introduction-to-functional-programming-231n</link>
      <guid>https://dev.to/davehowson/an-introduction-to-functional-programming-231n</guid>
      <description>&lt;p&gt;Functional Programming has been around for many decades but languages like JavaScript have given it a new found popularity in the recent years due to it its simplicity and straightforwardness. Functional Programming is a &lt;em&gt;Declarative Programming Paradigm&lt;/em&gt; where we tell a program what it needs to accomplish rather than telling it how it needs to accomplish this. For example, consider the following scenario using simple JavaScript.&lt;/p&gt;

&lt;p&gt;Say we have an array of numbers &lt;code&gt;[1, 2, 3, 4]&lt;/code&gt; and we need to add &lt;code&gt;1&lt;/code&gt; to each of the numbers in this array. We can achieve this &lt;em&gt;Imperatively&lt;/em&gt; or &lt;em&gt;Declaratively.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The Imperative approach would be to first create a new array, run a loop through all the numbers in our initial array, add 1 to each of the numbers and push it to our new array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="k"&gt;for&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;x&lt;/span&gt; &lt;span class="o"&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;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="o"&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;newArr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&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;In the Imperative approach, we tell the JavaScript compiler exactly what needs to be done using low level constructs such as loops and assignments. &lt;/p&gt;

&lt;p&gt;However, the Declarative approach would be to think about what our end result would be and achieve this without the use of conditionals and loops.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt; &lt;span class="o"&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newArr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&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="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Declarative approach utilizes a method built into the JavaScript language to easily achieve what we want to without having to manually loop through the array.&lt;/p&gt;

&lt;p&gt;Declarative Programming is much more cleaner than its Imperative counterpart in most cases and it leads to clean and minimal code.&lt;/p&gt;

&lt;p&gt;Built on the concepts of Declarative Programming, Functional Programming is a paradigm where we create programs by applying and combining multiple functions together. In Functional Programming, a value can be converted into another value by running it through a set of functions.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;calculateValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&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;valByTen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;multiplyByTen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&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;valPlusTwenty&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;addTwenty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;valByTen&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;valPlusTwenty&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;Above is a simple example of how a value can change as it is passed through multiple functions. Two important things to note here is that regardless of how many times you run this function, as long as the input value remains the same, the output value will always be the same as well. Secondly, the input value never changes throughout the function. Instead of changing it, we create a new value based on the input and return that as the result of the function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concepts of Functional Programming
&lt;/h2&gt;

&lt;p&gt;In order to better understand Functional Programming, we must first understand the concepts and ideas behind Functional Programming.&lt;/p&gt;

&lt;h3&gt;
  
  
  First Class Functions
&lt;/h3&gt;

&lt;p&gt;Languages such as JavaScript treat functions as First Class Citizens. This means that functions can be used anywhere that a regular entity (strings, numbers, etc..) are used. Functions can be stored in variables. They can be passed as parameters into other functions. Functions can be returned as a result of another function and they can also be included in data structures such as arrays.  In order to write functional programming code, the language should support functions as first class citizens.&lt;/p&gt;

&lt;p&gt;Another concept here is &lt;strong&gt;Higher Order Functions.&lt;/strong&gt; When functions are treated as first class citizens, they can be passed as parameters into other functions. This helps us create complex programs by composing a set of simple functions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Immutability
&lt;/h3&gt;

&lt;p&gt;Immutability is the inability of an entity to be changed. In Functional Programming, we use Immutability to ensure that entities such as variables and functions always remain the same throughout the lifecycle of the programs execution. This concept helps us create predictable and maintainable code as we know that once a value is initialized, it will never be changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;john&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;upper&lt;/span&gt; &lt;span class="o"&gt;=&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toUpperCase&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;newName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;upper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, we assign the string &lt;code&gt;john&lt;/code&gt; to a variable called &lt;code&gt;name&lt;/code&gt;. When these lines of code are executed, the variable will be initialized with the given string and once done so, it can never be altered again. If we need to change the casing of this string to an upper case, we have to create a new variable called &lt;code&gt;newName&lt;/code&gt; and pass the name as the parameter to the &lt;code&gt;upper&lt;/code&gt; function which will create a new variable, convert it to upper case and return the result so that it can be assigned to &lt;code&gt;newName&lt;/code&gt;. It is important to note here that &lt;code&gt;name&lt;/code&gt; was never altered and thus, immutability was maintained. In the lack of immutability, code becomes harder to manage as we do not know which function changed the original value and that  leads to unpredictable results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Pure Functions
&lt;/h3&gt;

&lt;p&gt;Functional Programming utilizes the concept of Pure Functions where given the same input to a function, it will always return the same output.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;multiplyByTen&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;val&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function will always multiply a given input by 10 and respond with the new value. If we run this function with the same input, it will always return the same output. This concept is important because as our program and the functions in it grow in size and complexity, we must always maintain pure functions that return predictable outputs. In order to implement Pure Functions, we must always make sure that our functions have &lt;strong&gt;No Side Effects&lt;/strong&gt;. A Side Effect is when a function alters a value outside of its local scope. We can make the above example an impure function by introducing a value outside of its scope.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&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;multiplyByTen&lt;/span&gt; &lt;span class="o"&gt;=&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;val&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;val&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since an outside value is altered by this function, we cannot ensure that its output will always be the same, thus making it an impure function. &lt;/p&gt;

&lt;p&gt;Another important concept here is that of &lt;strong&gt;Referential Transparency&lt;/strong&gt;. This means that the value of a variable never changes once defined. When we define a value and pass it as a parameter to a function, in a pure function, this initial value will never be changed. But in impure functions, like the one above, the initially declared value will change based on the execution of the function. &lt;/p&gt;

&lt;p&gt;A pure function is predictable and its data will always flow through the same steps upon execution. &lt;/p&gt;

&lt;p&gt;Functional Programming prevents the use of a shared state in programs because using such a state among functions would make them impure and unpredictable. However, there are workarounds for this where we can use a shared state which is the result of a set of data passed through a set of functions. Redux is a great implementation of this where we use a shared state in a functional way. You can read more about that &lt;a href="https://blog.usejournal.com/how-does-redux-work-b1cce46d4fa6"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using the above mentioned core concepts, Functional Programming helps developers create modular and predictable programs that are the result of composing multiple pure functions together. In Functional Programming, the output of the program is purely determined by its inputs and the functions that these inputs flow through. &lt;/p&gt;

&lt;p&gt;Since this is an Declarative Programming paradigm, declarative concepts are applied in Functional Programming as well. For example, say that we are building an e-commerce platform and that we wrote a function to calculate discount based on the price and the type of item provided. Once written, we can use this function in the store section where we display products and their discounted prices. But we can also use this confidently in the cart section as well, where similarly, we need to show a product and its discounted price. In such a scenario, once we create the discount calculation function, we do not have to worry about its implementation any more. We can reuse this function in both the store and the cart because at that point, we know that since this is a pure function, given the same input, it will always return the desired and predictable output thereby allowing us to disregard its implementation logic (how the discount is calculated) and focus on where we can use it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of Functional Programming
&lt;/h3&gt;

&lt;p&gt;Functional Programming has been around for decades and its concepts have been used in Mathematics for much longer than that with good reason. Following are some of the advantages that programmers can gain from using Functional Programming.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Simple&lt;/p&gt;

&lt;p&gt;Functional Programming helps developers solve complex problems in a modular and simple approach. Instead of writing large and complicated solutions to solve a problem, we can break down a problem to more manageable parts and write functions to solve each of these problems individually. The final solution would be the result of all these functions working together to solve this complex problem using a modular approach.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Easy to understand&lt;/p&gt;

&lt;p&gt;Functional code is easier to understand because we only have to comprehend what is going on in a single function at a time. Even a program that solves a complicated problem can easily be understood by a programmer because this problem will be broken down to separate functions and to understand a single function, all you have to do is to identify the input parameters and figure out what this specific function is doing to alter the values that were passed into it. It also helps that these functions are not affected by anything other than the parameters passed into them.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Maintainable&lt;/p&gt;

&lt;p&gt;A large codebase can easily be maintained when all it consists of are individual functions. We can easily refactor any of these individual functions as long as we maintain its integrity and respect the inputs and outputs of it. &lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Easy to debug&lt;/p&gt;

&lt;p&gt;Simple, understandable and maintainable code is simply easier to debug. We do not have to think about the entire application and how it handles a complex flow of data in order to debug an issue in a single function. A function is given a responsibility to provide a predictable output and if it does not do this, then this is a problematic function which should be fixed. Doing so would not break other functions as the logic inside of a function does not affect these other functions. Only the inputs and outputs do.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Testable&lt;/p&gt;

&lt;p&gt;Functional code is very easy to test as these functions are inherently self contained. Once given some input, it should always return the expected output. It is very easy to write test cases for such functions and because of this, a functional codebase can be a highly tested and confident codebase.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Disadvantages of Functional Programming
&lt;/h3&gt;

&lt;p&gt;As all things in life, Functional Programming too has its weaknesses that can be better solved using other paradigms such as Object Oriented Programming.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Complicated in some scenarios&lt;/p&gt;

&lt;p&gt;Simplicity is an advantage of Functional Programming, but in some scenarios, following the strict guidelines of Functional Programming can make simple solutions overly complicated.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Composing functions can be troublesome&lt;/p&gt;

&lt;p&gt;Functional composition, where we use the result of one function as the input of another function, thereby composing a large number of functions together can sometimes be harder to maintain. This depends on the problem domain and the way of approaching a solution. But just because Functional Programming can lead to cleaner code does not mean that it always leads to cleaner code.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Harder to comprehend&lt;/p&gt;

&lt;p&gt;Good Functional Programming is a result of good functional thinking. In order to breakdown a complex function to a set of simple functions, one must have to do a lot of thinking and planning. Programmers should also train themselves to think functionally which is not always an easy thing to do as our brains do not comprehend solutions that way.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Refactors are unavoidable&lt;/p&gt;

&lt;p&gt;Functional Programming depends heavily on the concept of reusable functions. However, in most cases, we simply cannot predict all of the potentially reusable functions that we will create, and in the long run, as we begin to better understand the solution we are building and as some of the requirements of our solution change, it will become inevitable that we will have to run across functions which will require refactoring.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the advancements of the development ecosphere, everyday we tend to move more and more closer to simple and declarative solutions. Developers are moving away from the mentality of needing to custom-build everything from scratch and instead are starting to see the amazing benefits of reusing code and libraries across solutions. Programming languages such as JavaScript keep evolving and adding new features to it so that developers can focus more on the problems they need to solve rather than having to worry about the implementation details of the methods and tools they use. This landscape is breathing new life into the wonderful paradigm that is Functional Programming. For me personally, clean and reusable code is everything. I thank the day I decided to learn Functional Programming and I have loved it ever since. I hope you will too. &lt;/p&gt;

&lt;p&gt;#happycoding&lt;/p&gt;

</description>
      <category>functional</category>
      <category>paradigms</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>An Introduction to WSL</title>
      <dc:creator>Dave Howson</dc:creator>
      <pubDate>Sat, 22 Aug 2020 06:28:07 +0000</pubDate>
      <link>https://dev.to/davehowson/an-introduction-to-wsl-2igf</link>
      <guid>https://dev.to/davehowson/an-introduction-to-wsl-2igf</guid>
      <description>&lt;h2&gt;
  
  
  What is WSL?
&lt;/h2&gt;

&lt;p&gt;Introduced with the Anniversary Update in August 2016, the Windows Subsystem for Linux is a feature that lets you work seamlessly on a Linux environment inside of Microsoft Windows.&lt;br&gt;
WSL is a compatibility layer that runs on top of a Windows environment letting you experience the best of both worlds.&lt;br&gt;
Unix based Systems like Linux and macOS have always been the go-to Operating Systems for Web Developers and Open Source project contributors due to their unparalleled support for development tools and their similarity to production environments. Microsoft Windows has improved its developer experience tremendously over the years, especially with the introduction of tools like PowerShell and Hypervisor technologies, but many developers still &lt;a href="https://insights.stackoverflow.com/survey/2019#technology-_-platforms" rel="noopener noreferrer"&gt;prefer Linux over Microsoft Windows&lt;/a&gt; when it comes to their development platform.&lt;br&gt;
However, WSL is here to change that. When combined with the convenience of Windows and the functionality of Linux, WSL becomes the obvious platform of choice for many developers especially in the field of Web Application Development.&lt;/p&gt;

&lt;h2&gt;
  
  
  WSL1 vs WSL2
&lt;/h2&gt;

&lt;p&gt;WSL comes in two versions and they have significantly different architectures under the hood. In order to understand the architecture of WSL, we must first understand the architecture of the Linux Operating System. A machine that runs on Linux can basically be divided into four sections.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hardware - This is the physical machine&lt;/li&gt;
&lt;li&gt;Kernel - This is the core of the Linux operating system. It facilitates the communication between software and hardware.&lt;/li&gt;
&lt;li&gt;Shell - This is the interface that takes input from the user and communicates this with the kernel&lt;/li&gt;
&lt;li&gt;Applications and Utilities&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FKD6jOtO.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FKD6jOtO.png" alt="Architecure of Linux"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;WSL1 runs Linux compatible applications and utilities on top of a Linux Shell (e.g. Bash). In a Linux Operating System, the Linux Shell communicates with the Linux Kernel in order to process and relay system calls sent from applications and user commands. However, in WSL1, a Linux Kernel does not exist. Instead, system calls from the Shell are translated to calls that are compatible with the Windows NT Kernel that ships with Microsoft Windows.&lt;/p&gt;

&lt;p&gt;Processes in an operating system execute in one of two modes. Lower level processes that need direct access to the Kernel and hardware devices are executed in the &lt;em&gt;Kernel Mode&lt;/em&gt; while higher level processes are executed in the &lt;em&gt;User Mode&lt;/em&gt;. When a higher level process makes a lower level system call, this is relayed to a process running in the Kernel Mode which handles this call and replies accordingly. In WSL1, Unmodified Linux Binaries run inside processes known as &lt;em&gt;Pico Processes&lt;/em&gt; in the User Mode. These Pico Processes run in isolated environments and they do not have any direct contact with the outside environment. System calls sent out by Pico Processes are handled by &lt;em&gt;Pico Drivers&lt;/em&gt;. Due to the isolated architecture of these processes, they are able to run pure Linux binaries without having to worry about the environment in which they are executed in. &lt;br&gt;
WSL1 consists of two Pico drivers - LXCore &amp;amp; LXSS. All system calls sent out by Pico Processes are handled by these two drivers. These drivers, running in the Kernel Mode, translate Linux system calls to Windows system calls that can be understood by the Windows NT Kernel. This allows pure Linux binaries running on top of a WSL environment to function as if they are functioning in a pure Linux environment without having to bother about the underlying Windows Operating System.&lt;/p&gt;

&lt;p&gt;This translation based architecture was a good solution to implement interoperability between Windows and Linux. But translation takes time and some Linux calls cannot be translated perfectly to Windows calls. Instead, the WSL team came up with a better solution in WSL2. &lt;/p&gt;

&lt;p&gt;WSL2 boots up a Linux Kernel inside a highly optimized Virtual Machine which uses the Hyper-V architecture of Windows. WSL2 provides all the features of WSL1 along with some major improvements such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full System Call Compatibility&lt;/li&gt;
&lt;li&gt;Faster IO Performance&lt;/li&gt;
&lt;li&gt;Smaller Memory Footprint&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Since WSL2 is based on virtualization via the Hyper-V architecture, it is able to provide users with a complete Linux Kernel. This Kernel runs separately alongside the NT Kernel and all hardware calls are handled by the underlying Hypervisor.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FDC7jd6o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FDC7jd6o.png" alt="WSL2 Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Highly Optimized Utility VM that WSL2 runs on top of gives it the ability to boot up extremely faster than a traditional VM. Similar to WSL1, WSL2 can easily access the Windows File system and other IO components such as external devices and network connectivity. In fact, the modern architecture of WSL2 ensures that it is much faster than WSL1 when it comes to accessing files and networks.&lt;br&gt;
Since WSL2 has access to a fully fledged Linux Kernel, it provides users with 100% system call compatibility. This means that WSL users can do anything that native Linux users can do with their Kernel.&lt;br&gt;
The inclusion of a Linux Kernel also means that WSL2 can receive updates much more efficiently than WSL1. Previously, in WSL1, when a new feature or an update is deployed to the Linux Kernel, the WSL team had a lot of work to do in the translation layer before this feature was deployed to WSL users. However, in WSL2, new Linux Kernel features and updates can simply be deployed via Windows updates since there is no translation layer, giving WSL users access to the latest and greatest Linux features in an instant.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use WSL?
&lt;/h2&gt;

&lt;p&gt;WSL is the perfect combination for Developers of Web and Open Source Projects who can benefit from the combined power of Windows and Linux. Since most web servers run on Linux environments, developers can develop their applications on production-like environments while enjoying the accessibility, stability and modernness of Windows. WSL allows developers to run Linux specific tools in a Windows environment without having to go through the hassle of running a Virtual Machine. Unlike traditional VM's, WSL is fast, efficient and needs no initial configuration to get it up and running. WSL provides developers with an advanced, state-of-the-art Linux experience on Windows without any of the complexity. Developers do not have to resort to dual boot or VM's anymore in order to experience the best of both worlds, making WSL the perfect choice for them.&lt;/p&gt;

&lt;p&gt;Linux has always stood out over the rest of the Operating Systems out their because of its impressive list of distributions. WSL supports almost all of the popular Linux distros and they can be easily downloaded via the Microsoft Store. WSL users can install multiple Linux distros and seamlessly switch between them when needed.&lt;/p&gt;

&lt;p&gt;The WSL team has gone above and beyond to make WSL a worthwhile option for developers. Unlike in VM's where the virtualized OS is isolated from the environment around it, WSL has full access to the underlying systems network and files, making it very easy for developers to work on the same projects in both Windows and Linux environments. Microsoft has also released plugins for tools such as VSCode that help developers access projects inside WSL via the VSCode UI, which simplifies cross platform development workflows. Developers can simply open VSCode inside Windows, open up their projects inside WSL and start coding right away. No hassle, no configuration and no stress!&lt;/p&gt;

&lt;p&gt;WSL props up Microsoft Windows as a serious candidate in the developer Operating System market. With an ambitious and dedicated team behind the development of WSL, Microsoft has opened up new possibilities in the world of remote development and we couldn't be more happier about this.&lt;/p&gt;

&lt;p&gt;For more information about WSL and how to get started on it, visit the &lt;a href="https://docs.microsoft.com/en-us/windows/wsl/" rel="noopener noreferrer"&gt;Official WSL Docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>wsl</category>
      <category>virtualization</category>
      <category>linux</category>
      <category>windows</category>
    </item>
  </channel>
</rss>
