<?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: Hamza Tamenaoul</title>
    <description>The latest articles on DEV Community by Hamza Tamenaoul (@hamza).</description>
    <link>https://dev.to/hamza</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%2F50687%2F03827052-2382-44b8-adbb-2315f8d649ee.png</url>
      <title>DEV Community: Hamza Tamenaoul</title>
      <link>https://dev.to/hamza</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hamza"/>
    <language>en</language>
    <item>
      <title>Have you heard of the bus factor ?</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Wed, 15 Nov 2023 23:20:08 +0000</pubDate>
      <link>https://dev.to/hamza/have-you-heard-of-the-bus-factor--1a2a</link>
      <guid>https://dev.to/hamza/have-you-heard-of-the-bus-factor--1a2a</guid>
      <description>&lt;p&gt;In software development, many risks can jeopardize the success of a project, or even threaten its survival. One of the main responsibilities of a good project manager is to take those risks into account, and measure them. As one of my teachers always stressed, &lt;strong&gt;"a metric that can't be measured, can't be controlled"&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;One of the most important metrics in a software project is the &lt;em&gt;Bus Factor&lt;/em&gt;, even though it is not much spoken about. &lt;/p&gt;

&lt;h2&gt;
  
  
  What's the concept ?
&lt;/h2&gt;

&lt;p&gt;When defining the metrics of software reliability, one of the first questions we should ask ourselves is: &lt;strong&gt;what are the points of failure of the system ?&lt;/strong&gt; And it is a very important one, since it easily creates bottlenecks. &lt;/p&gt;

&lt;p&gt;Therefore, the &lt;em&gt;Bus Factor&lt;/em&gt; tries to ask the same question, but this time about the development team: &lt;em&gt;What is the minimal number of team members that we can not afford to loose to a bus accident ?&lt;/em&gt; (Indeed, it is a dark question to think about !). &lt;/p&gt;

&lt;p&gt;Although having multiple members of your team getting hit by a bus is statistically very unlikely, on the other hand having some of them leave unexpectedly, either because of a resignation, a lifestyle change, a family situation evolution, etc..., is highly probable. We are all familiar with the turnover figures in the software industry. And it is precisely for these reasons that this factor is very important. &lt;/p&gt;

&lt;h2&gt;
  
  
  Diving in maths ?
&lt;/h2&gt;

&lt;p&gt;Let's take a simple example to understand the metric's calculation.&lt;/p&gt;

&lt;p&gt;Let's assume a project has a DevOps team made up of 3 members. Let's assume that every team member perfectly knows everything there is to know about the team's perimeter (a transversal DevOps team for example). &lt;/p&gt;

&lt;p&gt;In that case we can see that if the 3 members of the DevOps team get suddenly hit by a bus, we loose the ability to work on the project while we can get by with one DevOps (although he will have to dramatically increase his energy drinks consumption). And therefore you can guess that the &lt;code&gt;bus_factor = 3&lt;/code&gt;. Meaning we can afford to loose 2 DevOps engineers before the DevOps team stalls.&lt;/p&gt;

&lt;p&gt;For a more realistic example: Let's assume now the project having a Front End team of 5 people. While 4 of them share the same knowledge about the application, the 5th person masters one critical side of the code. Therefore, it might seem that the &lt;code&gt;bus_factor = 5&lt;/code&gt;, but in reality the global factor of the Front End team is limited to &lt;code&gt;1&lt;/code&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  How do we deal with it ?
&lt;/h2&gt;

&lt;p&gt;The reason we decide to measure the &lt;em&gt;Bus Factor&lt;/em&gt; is to try to maximize it. The higher the &lt;em&gt;Bus Factor&lt;/em&gt; is, the lower we are exposed to an unexpected loss of knowledge, eventually leading to a sharp increase in development and maintenance costs. Ideally we should aim for the ideal number which equals the number of our team members. On the contrary, a lower &lt;em&gt;Bus Factor&lt;/em&gt; means a higher exposure. And the closer we are to 0, more red bells will ring. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Knowledge should always be shared among team members to increase the &lt;em&gt;Bus Factor&lt;/em&gt; as much as possible !&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the midst of excitement when working on new software projects, or just complex features, we often forget some basic project management concepts. And best practices are here to make sure we stick to them. &lt;em&gt;The bus factor&lt;/em&gt; is among them, emphasizing the importance of practices like Code Review and pair programming, that take it into account implicitly. &lt;/p&gt;

</description>
      <category>management</category>
      <category>projectmanagement</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>If a team member gets hit by a bus, would that destroy your software project ?</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Fri, 30 Oct 2020 10:50:05 +0000</pubDate>
      <link>https://dev.to/hamza/if-a-team-member-gets-hit-by-a-bus-would-that-destroy-your-software-project-497d</link>
      <guid>https://dev.to/hamza/if-a-team-member-gets-hit-by-a-bus-would-that-destroy-your-software-project-497d</guid>
      <description>&lt;p&gt;In the software development business, there exists many risks that endanger not the only the success of a project, but even its survival. One of the roles of a good project manager is to take those risks into account, and be able to measure them. As one of my teachers in engineering school always stressed, a metric that can't be measured can't be controlled nor dealt with. &lt;/p&gt;

&lt;p&gt;And one of the most important metrics in a software project is the &lt;em&gt;Bus Factor&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's the concept ?
&lt;/h2&gt;

&lt;p&gt;When designing scalable and reliable software, one of the first questions we should ask ourselves is &lt;strong&gt;what is the single point of failure of the system ?&lt;/strong&gt; And it is a very important one, since as you already know, it can easily cause a bottleneck and therefore stop the whole application. &lt;/p&gt;

&lt;p&gt;Well the &lt;em&gt;Bus Factor&lt;/em&gt; tries to ask the same question, but this time about the development team. The question of &lt;em&gt;What is the minimum number of team members that should get hit by a bus before we loose a necessary knowledge about the project&lt;/em&gt;. (It's a very dark question to ask !)&lt;/p&gt;

&lt;p&gt;Although having many members of your team getting hit by a bus is statistically very unlikely, however having some of them leave the team unexpectedly, either because of a new job, new lifestyle, new family situation, etc..., is highly probable. And it is precisely for this reason that this factor is very important. &lt;/p&gt;

&lt;h2&gt;
  
  
  How do we measure it ?
&lt;/h2&gt;

&lt;p&gt;Let's take for example that a project is composed of three distinct entities: the Front End team composed of 5 people, the Back End team of 10 people, and the DevOps team of 3. Let's assume that every team member perfectly knows about what its team is working on only. &lt;/p&gt;

&lt;p&gt;In that case we can see that if the three members of the DevOps team get suddenly hit by a bus, we loose the ability to work on the project. And therefore you can guess that the &lt;em&gt;Bus Factor&lt;/em&gt; of this team is 3.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do we deal with it ?
&lt;/h2&gt;

&lt;p&gt;The reason we decide to measure the &lt;em&gt;Bus Factor&lt;/em&gt; is to try to maximize it. The higher the &lt;em&gt;Bus Factor&lt;/em&gt; is, the lower we are exposed to an unexpected loss of knowledge. Ideally we should aim for ideal number which is the number of our team members. On the contrary, a lower &lt;em&gt;Bus Factor&lt;/em&gt; means a higher exposure, and the closer we are to 0, the worse we are. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You should always share knowledge between your team members to have the highest &lt;em&gt;Bus Factor&lt;/em&gt; possible !&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In the midst of excitement when working on a new Software project, we often forget some basic project management concepts. And best practices are here to make sure we don't forget some of them like the &lt;em&gt;Bus Factor&lt;/em&gt;. This shows the importance of practices like Code Review or pair programming that take into account this kind of factor, and help prevent a low metric.   &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why you don't need to remap the escape key in Vim !</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Mon, 21 Sep 2020 12:45:48 +0000</pubDate>
      <link>https://dev.to/hamza/why-you-don-t-need-to-remap-the-escape-key-in-vim-opa</link>
      <guid>https://dev.to/hamza/why-you-don-t-need-to-remap-the-escape-key-in-vim-opa</guid>
      <description>&lt;p&gt;Vim by its nature is very heavy on the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; key usage. It's very important in the modal editing philosophy of the editor. But when we are talking about Vim, we are talking about minimal hand movement in the first place, since it is the reason behind all of its design choices. For this reason many have found the usage of the &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; very unintuitive to use, and prefer to map it to a more easier to access key combination. Many tutorials over the internet suggest changing it to a combination close to the home row like &lt;code&gt;jk&lt;/code&gt;, a combo I did not personally find useful. &lt;/p&gt;

&lt;p&gt;However the designer of Vim did not forget about the user that might find &lt;strong&gt;exhausting&lt;/strong&gt; to use &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt;. When diving in the documentation of Vim, we can notice in the intro page by typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:help escape
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can read on this page a more clever key combination that is already built in the default Vim configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Esc&amp;gt;   escape  CTRL-[  27  escape  &amp;lt;Esc&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can see that &lt;code&gt;&amp;lt;Esc&amp;gt;&lt;/code&gt; is also mapped to &lt;code&gt;&amp;lt;C-[&amp;gt;&lt;/code&gt;. And this is very interesting since Vim by default gives us a more &lt;strong&gt;easier&lt;/strong&gt; to use key combination for the escape key out of the box. &lt;/p&gt;

&lt;p&gt;It can take some time to get used to using this key combination, but it will quickly become your favorite since, you can start from it to make other more interesting key combinations; like an escape key of the built-in terminal.&lt;/p&gt;

&lt;p&gt;What do you think about this key combination, or do you already use a more interesting one in your configuration. &lt;/p&gt;

</description>
      <category>vim</category>
      <category>config</category>
    </item>
    <item>
      <title>Interface implementation difference cross languages</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Mon, 25 May 2020 10:31:40 +0000</pubDate>
      <link>https://dev.to/hamza/interface-implementation-difference-cross-languages-274p</link>
      <guid>https://dev.to/hamza/interface-implementation-difference-cross-languages-274p</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="https://hamza-tam.gitlab.io"&gt;my blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Interfaces are one of the most important features of a lot of programming languages. A lot of their features won't be available without that small keyword.&lt;/p&gt;

&lt;p&gt;But working with different languages we can spot two different paradigms in how interfaces are implemented in them. I have decided to name them the &lt;em&gt;"Implicit implementation"&lt;/em&gt; and the &lt;em&gt;"Explicit implementation"&lt;/em&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Explicit implementation
&lt;/h1&gt;

&lt;p&gt;Explicit implementation is the most straight forward one from the two to spot. The most prominent example is this approach used by the &lt;code&gt;java&lt;/code&gt; language.&lt;/p&gt;

&lt;p&gt;The idea is fairly simple, after you define an interface, you need to explicitly specify that you are implementing it by the current class. As an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Geometry&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="nf"&gt;area&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Coordinates&lt;/span&gt; &lt;span class="o"&gt;{...}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Although this approach make the code easier to read, since by just glancing at the code we can guess that this class have the methods and attributes defined in the interface.&lt;/p&gt;

&lt;h1&gt;
  
  
  The limitations of explicit implementation
&lt;/h1&gt;

&lt;p&gt;Let's imagine you have this code in &lt;code&gt;Typescript&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Point&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Coordinates&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;y&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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;getX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_object&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Coordinates&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;number&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;_object&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To test it we can execute:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;point&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Point&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Point&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;getX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;point&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Any &lt;code&gt;Typescript&lt;/code&gt; developer know that this type of code works. However in the &lt;code&gt;java&lt;/code&gt; world it does not. For the languages that rely on the explicit implementation scheme, an error will be thrown at you. for them, even if the &lt;code&gt;Point&lt;/code&gt; class have apparently the requirements to be considered as a &lt;code&gt;Coordinates&lt;/code&gt; implementation, it is not. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You may not see the problem, but it become crucial when the class you wanna use is from a library but the interface is yours.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Implicit implementation
&lt;/h1&gt;

&lt;p&gt;To solve this sticky situation, more and more languages rely on implicit implementation. In those type of languages, like &lt;code&gt;Typescript&lt;/code&gt; or &lt;code&gt;go&lt;/code&gt;, the compiler see if the class fulfill the requirements specified by the interface, and not if it implements it.&lt;/p&gt;

&lt;p&gt;This languages have decided to sacrifice readability, unless you know all the interfaces of your code, you can not know if a class follow an interface specification or not.&lt;/p&gt;

&lt;p&gt;A quick demonstration from the go language.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;Geometry&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;area&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;rectangle&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="n"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;area&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;y&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;getArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_object&lt;/span&gt; &lt;span class="n"&gt;Geometry&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="n"&gt;_object&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;area&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;For testing purposes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;getArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&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;And as expected it works without much effort, and without the hassle of having to explicitly declare the implementation of the interface.&lt;/p&gt;

&lt;p&gt;__&lt;/p&gt;

&lt;p&gt;I hope that this article was a quick peek to discover one of the many questions a languages designer have to ask himself before starting to make it's own language. (Although I agree that interfaces may not be the first thing he will start with ;) !). However it shows the two most common approaches, one more focused on readability, the other on functionality and extensibility. For you, which one of those implementations do you prefer ?&lt;/p&gt;

</description>
      <category>programming</category>
      <category>theory</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Framework vs library vs package vs module: The debate</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Thu, 16 Apr 2020 16:44:04 +0000</pubDate>
      <link>https://dev.to/hamza/framework-vs-library-vs-package-vs-module-the-debate-3jpp</link>
      <guid>https://dev.to/hamza/framework-vs-library-vs-package-vs-module-the-debate-3jpp</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://hamza-tam.gitlab.io"&gt;This article was first published in  my blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;As a software developer, this is one of the questions that is often asked, and one of a big source of confusion. In the debate about the difference between frameworks, libraries, packages and modules, what does each one of them represent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Module
&lt;/h3&gt;

&lt;p&gt;Is the smallest piece of software. A module is a set of methods or functions ready to be used somewhere else.&lt;/p&gt;

&lt;h3&gt;
  
  
  Package
&lt;/h3&gt;

&lt;p&gt;Is a collection of modules. This may sound funny, but usually what a package does, is gather a number of modules holding in general the same functional purpose. Making it easier to include all the related modules at once.&lt;/p&gt;

&lt;h3&gt;
  
  
  Library
&lt;/h3&gt;

&lt;p&gt;Well library at it's core, is a collections of packages. It's purpose is to offer  a set of functionalities ready to use without worrying about the subsequent packages. So a library is what you include when you want to add some functionality to your code. It does not force any coding style on you either.&lt;/p&gt;

&lt;h3&gt;
  
  
  Framework
&lt;/h3&gt;

&lt;p&gt;It's a set of libraries. But this time, the framework does not just offer functionalities, but it also provides an architecture for the development work. In other words you don't include a framework. You integrate you code into it. He is the wire frame of the project. That's why a framework forces its coding style on you.&lt;/p&gt;

&lt;p&gt;I hope that this quick summary was enjoyable !&lt;/p&gt;

</description>
      <category>library</category>
      <category>framework</category>
    </item>
    <item>
      <title>The different types of method specifications</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Fri, 10 Apr 2020 12:26:17 +0000</pubDate>
      <link>https://dev.to/hamza/the-different-types-of-method-specifications-42ji</link>
      <guid>https://dev.to/hamza/the-different-types-of-method-specifications-42ji</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://hamza-tam.gitlab.io/"&gt;This post was originally published in my blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Specs, specs and specs. The often forgotten aspect of software design. Defining the specification of the project is the first step in any successful software project. And yet it is often overlooked. It gives us not only the opportunity to understand the need of the client, but also to synchronize the work inside a team of developers more easily and avoid any negative side effects.&lt;/p&gt;

&lt;p&gt;My goal here today is not to talk about what is their importance or why are they so useful. But it is about showing some key aspect to have in one's mind during the specification design phase.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;N.B: To make things simpler, I am going to focus here on method specification, but a generalization can be applied to more advanced structures like classes or modules.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What are specifications
&lt;/h1&gt;

&lt;p&gt;the specification of a method is the definition of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The prototype of the method&lt;/strong&gt; to define the parameters of the method and their type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The preconditions&lt;/strong&gt; are what conditions should be fulfilled before the method procedure could start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The postconditions&lt;/strong&gt; are what conditions are guaranteed on the outputs of the method. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By convention the preconditions follow the keyword &lt;em&gt;requires&lt;/em&gt;, while the postconditions follow the &lt;strong&gt;effects&lt;/strong&gt;'s keyword.&lt;/p&gt;

&lt;p&gt;The importance of the specification can be felt at the implementation phase. it forces us to agree on the method and its side effects, and by then have no disappointment after the development phase from the its client &lt;em&gt;(The client here refers to the user of the method)&lt;/em&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deterministic vs Non-deterministic specifications
&lt;/h1&gt;

&lt;p&gt;You can find two types of specs: &lt;strong&gt;deterministic&lt;/strong&gt; and &lt;strong&gt;non-deterministic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A deterministic specification is a specification that is precise enough so that any implementation of that specification from the implementation space will yield the same results. That means that regardless of how the method was developed, or the person that have developed it, we can trust that the client will get from all of the implementations the same result.&lt;/p&gt;

&lt;p&gt;A non-deterministic specification, on the contrary, gives more freedom to the implementer, since in the implementation space of the method, we can have implementations that won't give the same results. So the client can't trust these different implementations since he is not sure that they will converge on the same results.&lt;/p&gt;

&lt;p&gt;A small example to understand. Let's consider the following spec.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;em&gt;non-deterministic&lt;/em&gt; specification. In this case we cannot be sure if the index that will be returned is the smallest or the biggest one found for example. An implementation may start from the lower bound, another one from the higher bound.&lt;/p&gt;

&lt;p&gt;To make a deterministic specification we can say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;lowest&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of any determinization is to remove the ambiguity. And it is the same goal here: Removing the ambiguity from the statement, so that the implementers can agree.&lt;/p&gt;

&lt;h1&gt;
  
  
  Stronger vs weaker specifications
&lt;/h1&gt;

&lt;p&gt;Now that we have our specification in place, what if we want to make a stronger or weaker one. Well the answer to that question is very tricky, since we need to understand first what do we mean by a stronger specification or weaker one.&lt;/p&gt;

&lt;p&gt;A weaker specification is a specification that demands more from on the client and put less responsibility on the method, while a stronger one puts more strains on itself, and relieves the client from some of the task's responsibilities. Mathematically speaking, in a given implementation space for a method, the more stronger the specification is, the more smaller the space is, while on the contrary, the weaker the specification, the bigger that space. In other words, a weaker specification asks more of the inputs (A.K.A the client), and less from outputs, whereas a stronger reverse this statement. &lt;/p&gt;

&lt;p&gt;For a given specification, to make it weaker &lt;em&gt;(or stronger)&lt;/em&gt;, you need either to put more &lt;em&gt;(less)&lt;/em&gt; preconditions, or less &lt;em&gt;(more)&lt;/em&gt; postconditions.&lt;/p&gt;

&lt;p&gt;This may sound counter intuitive, but if we take into account the definition above, the weaker the preconditions, the more responsibility we put on the method since it has to handle the test cases it did not before. While the more postconditions we put, the less headaches the client will have with the effects of the method.&lt;/p&gt;

&lt;p&gt;For illustration let's take the example we used earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make this specification weaker, we can ask from the client more efforts. To do so, we can write it as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While to make it stronger, we can impose more conditions from the outputs. For example, we can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;not&lt;/span&gt; &lt;span class="n"&gt;found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Writing good specifications
&lt;/h1&gt;

&lt;p&gt;Good specification is crucial, specially in the context a team work. It provides the developers with the necessary tools for them to be on the same page and not diverge in their implementations. It is mandatory for a specification designer to take into account these two key concept, to pay attention to what specification is he writing, and to ask the good questions. Is it all right if this specifications is non-deterministic, or it may put the integration of the modules at risk ? Do we need a stronger specification on this class, or this weak one shall do it ? These are some of the most important questions that he shall bare in mind during the whole process.&lt;/p&gt;

&lt;p&gt;There are other key aspects in designing a specification that were not mentioned in this post, like defining exceptions, but still it is already enough for now I guess. Maybe I will write about them in another piece.&lt;/p&gt;

&lt;p&gt;Happy coding, and stay safe !&lt;/p&gt;

</description>
      <category>specification</category>
      <category>development</category>
      <category>software</category>
    </item>
    <item>
      <title>Hey you ! Have you thought about specifications ?</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Wed, 08 Apr 2020 19:19:34 +0000</pubDate>
      <link>https://dev.to/hamza/hey-you-have-you-thought-about-specifications-2po4</link>
      <guid>https://dev.to/hamza/hey-you-have-you-thought-about-specifications-2po4</guid>
      <description>&lt;p&gt;&lt;em&gt;This post was originally published in &lt;a href="https://hamza-tam.gitlab.io/"&gt;my blog&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Specs, specs and specs. The often forgotten aspect of software design. Defining the specification of the project is the first step in any successful software project. And yet it is often overlooked. It gives us not only the opportunity to understand the need of the client, but also to synchronize the work inside a team of developers more easily and avoid any negative side effects.&lt;/p&gt;

&lt;p&gt;My goal here today is not to talk about what is their importance or why are they so useful. But it is about showing some key aspect to have in one's mind during the specification design phase.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;N.B: To make things simpler, I am going to focus here on method specification, but a generalization can be applied to more advanced structures like classes or modules.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What are specifications
&lt;/h1&gt;

&lt;p&gt;the specification of a method is the definition of the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The prototype of the method&lt;/strong&gt; to define the parameters of the method and their type.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The preconditions&lt;/strong&gt; are what conditions should be fulfilled before the method procedure could start.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The postconditions&lt;/strong&gt; are what conditions are guaranteed on the outputs of the method. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By convention the preconditions follow the keyword &lt;em&gt;requires&lt;/em&gt;, while the postconditions follow the &lt;strong&gt;effects&lt;/strong&gt;'s keyword.&lt;/p&gt;

&lt;p&gt;The importance of the specification can be felt at the implementation phase. it forces us to agree on the method and its side effects, and by then have no disappointment after the development phase from the its client &lt;em&gt;(The client here refers to the user of the method)&lt;/em&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Deterministic vs Non-deterministic specifications
&lt;/h1&gt;

&lt;p&gt;You can find two types of specs: &lt;strong&gt;deterministic&lt;/strong&gt; and &lt;strong&gt;non-deterministic&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A deterministic specification is a specification that is precise enough so that any implementation of that specification from the implementation space will yield the same results. That means that regardless of how the method was developed, or the person that have developed it, we can trust that the client will get from all of the implementations the same result.&lt;/p&gt;

&lt;p&gt;A non-deterministic specification, on the contrary, gives more freedom to the implementer, since in the implementation space of the method, we can have implementations that won't give the same results. So the client can't trust these different implementations since he is not sure that they will converge on the same results.&lt;/p&gt;

&lt;p&gt;A small example to understand. Let's consider the following spec.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a &lt;em&gt;non-deterministic&lt;/em&gt; specification. In this case we cannot be sure if the index that will be returned is the smallest or the biggest one found for example. An implementation may start from the lower bound, another one from the higher bound.&lt;/p&gt;

&lt;p&gt;To make a deterministic specification we can say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;lowest&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The goal of any determinization is to remove the ambiguity. And it is the same goal here: Removing the ambiguity from the statement, so that the implementers can agree.&lt;/p&gt;

&lt;h1&gt;
  
  
  Stronger vs weaker specifications
&lt;/h1&gt;

&lt;p&gt;Now that we have our specification in place, what if we want to make a stronger or weaker one. Well the answer to that question is very tricky, since we need to understand first what do we mean by a stronger specification or weaker one.&lt;/p&gt;

&lt;p&gt;A weaker specification is a specification that demands more from on the client and put less responsibility on the method, while a stronger one puts more strains on itself, and relieves the client from some of the task's responsibilities. Mathematically speaking, in a given implementation space for a method, the more stronger the specification is, the more smaller the space is, while on the contrary, the weaker the specification, the bigger that space. In other words, a weaker specification asks more of the inputs (A.K.A the client), and less from outputs, whereas a stronger reverse this statement. &lt;/p&gt;

&lt;p&gt;For a given specification, to make it weaker &lt;em&gt;(or stronger)&lt;/em&gt;, you need either to put more &lt;em&gt;(less)&lt;/em&gt; preconditions, or less &lt;em&gt;(more)&lt;/em&gt; postconditions.&lt;/p&gt;

&lt;p&gt;This may sound counter intuitive, but if we take into account the definition above, the weaker the preconditions, the more responsibility we put on the method since it has to handle the test cases it did not before. While the more postconditions we put, the less headaches the client will have with the effects of the method.&lt;/p&gt;

&lt;p&gt;For illustration let's take the example we used earlier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;least&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To make this specification weaker, we can ask from the client more efforts. To do so, we can write it as such:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;requires&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;exists&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="n"&gt;only&lt;/span&gt; &lt;span class="n"&gt;once&lt;/span&gt; &lt;span class="n"&gt;in&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While to make it stronger, we can impose more conditions from the outputs. For example, we can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cpp"&gt;&lt;code&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;effects&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returns&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="n"&gt;such&lt;/span&gt; &lt;span class="n"&gt;as&lt;/span&gt; &lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;or&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;the&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="n"&gt;not&lt;/span&gt; &lt;span class="n"&gt;found&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Writing good specifications
&lt;/h1&gt;

&lt;p&gt;Good specification is crucial, specially in the context a team work. It provides the developers with the necessary tools for them to be on the same page and not diverge in their implementations. It is mandatory for a specification designer to take into account these two key concept, to pay attention to what specification is he writing, and to ask the good questions. Is it all right if this specifications is non-deterministic, or it may put the integration of the modules at risk ? Do we need a stronger specification on this class, or this weak one shall do it ? These are some of the most important questions that he shall bare in mind during the whole process.&lt;/p&gt;

&lt;p&gt;There are other key aspects in designing a specification that were not mentioned in this post, like defining exceptions, but still it is already enough for now I guess. Maybe I will write about them in another piece.&lt;/p&gt;

&lt;p&gt;Happy coding, and stay safe !&lt;/p&gt;

</description>
      <category>specification</category>
      <category>development</category>
      <category>software</category>
    </item>
    <item>
      <title>Why some think ++i is faster than i++ ?</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Mon, 25 Nov 2019 11:43:01 +0000</pubDate>
      <link>https://dev.to/hamza/why-some-think-i-is-faster-than-i-2b94</link>
      <guid>https://dev.to/hamza/why-some-think-i-is-faster-than-i-2b94</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted in &lt;a href="https://hamza-tam.gitlab.io"&gt;my portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A while ago, I have noticed reading some competitive programmers' code that a lot of them in their for and while loops tended to prefer using &lt;code&gt;++i&lt;/code&gt; instead of &lt;code&gt;i++&lt;/code&gt;. For example you could see in their code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(;;&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="n"&gt;i&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;So a question scratched my head to figure out &lt;strong&gt;why and if there is any real performance boost by using such expressions&lt;/strong&gt; (since they were top competitive programmers).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The answer lies in the dark caves of compilers and assembler generation&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So let's try to figure out what happens !&lt;/p&gt;

&lt;h1&gt;
  
  
  Analysis
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Accessing an array index with an expression
&lt;/h2&gt;

&lt;p&gt;Let's I have the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// I have two variables 'a' and 'b'&lt;/span&gt;
&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When reading this instruction what does the compiler do ?&lt;br&gt;
If we write what the compiler does in pseudo code it would give us something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get the value of a
Get the value of b
Calculate the expression a + b
Access the array position with the calculated index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessing the array index with a pre-increment
&lt;/h2&gt;

&lt;p&gt;Now this time let's see what happens with &lt;code&gt;++i&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// I have a variable 'a' &lt;/span&gt;
&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the compiler translate this with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get the value of a
Increment that value
Store the new value
Access the array position with the calculated index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  The breakthrough
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Have you noticed a trend here ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The compiler evaluate the expression inside the brackets before accessing the element. Which is &lt;strong&gt;different from what the usual &lt;code&gt;i++&lt;/code&gt; do !&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;if we have now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="c1"&gt;// I have a variable 'a' &lt;/span&gt;
&lt;span class="n"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;++&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 guess now how the compiler would translate that given the knowledge of what this instruction does:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Get the value of a
Store the value of a temporarily
Increment that value
Store the new value
Access the array position with the calculated index
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Given the added storage - that might be interesting in the context of an array access but usually unnecessary in the context of a loop - we get an added instruction that could result, depending on the machine the code is executed on, a slight performance drop.&lt;/p&gt;

&lt;h1&gt;
  
  
  Closing words
&lt;/h1&gt;

&lt;p&gt;You can guess by now that this syntax, in the context of modern machines the performance hit is generally not something to worry about. In addition to this I have found that usually compilers now optimize this kind of instruction to see if the value is really needed to be stored or can be dismissed. But this kind of questions is really helpful in understanding more how compilers work.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>speed</category>
      <category>programming</category>
    </item>
    <item>
      <title>WSL 2.0: More of the good juice</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Tue, 02 Jul 2019 15:06:48 +0000</pubDate>
      <link>https://dev.to/hamza/wsl-2-0-more-of-the-good-juice-3eko</link>
      <guid>https://dev.to/hamza/wsl-2-0-more-of-the-good-juice-3eko</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally published in &lt;a href="https://hamza-tam.gitlab.io"&gt;my blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Microsoft made big announcements during its last Microsoft Build. A lot of new and exciting products for developers have been announced. While the main focus of the people was centered on the new windows terminal, a terminal with a lot of long awaited enhancements and the new VS Code features, what held my attention was the improvements on the &lt;strong&gt;Windows Subsystem for Linux&lt;/strong&gt; or what was called the &lt;strong&gt;WSL 2.0&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why should you get excited about WSL 2.0
&lt;/h1&gt;

&lt;h2&gt;
  
  
  WSL 1.0 was amazing
&lt;/h2&gt;

&lt;p&gt;While I was doing my whole development work on Linux, mainly Xubuntu and Arch, I had to always install it along side of windows, since Linux didn't support a lot of the tools I was using on nearly a daily basis (Specially games). But upon discovering WSL, everything changed, I suddenly found myself able to migrate my development work completely to windows, except for some system development with C, and living inside &lt;em&gt;CMD&lt;/em&gt; (I have tried a lot windows terminal emulator, but I always found &lt;em&gt;CMD&lt;/em&gt; to be the best one, any suggestions ?).&lt;/p&gt;

&lt;p&gt;WSL 1.0, besides some of it's limitations, like not being able to install a lot of Linux applications or it's very slow speed, was quite successful at delivering the promise it gave us; A Linux development environment on Windows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where WSL 2.0 will make it better
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Big problem of WSL 1.0
&lt;/h3&gt;

&lt;p&gt;The biggest complain about WSL 1.0 was its slow speed, some commands took ages to complete, when they should have needed few seconds. This was due to the compatibility layer that WSL 1.0 was introducing, a layer whose role was to primarily translate Linux syscalls into Windows syscalls, so it didn't find a use to having a Linux kernel. &lt;/p&gt;

&lt;h3&gt;
  
  
  WSL 2.0 solution
&lt;/h3&gt;

&lt;p&gt;The solution is quite simple and obvious, shipping a linux kernel directly into Windows and let it do the work. That's the engineering feat that the WSL team was formidably successful at accomplishing. So now the programs run as if they were running on the Linux kernel, because they finally do. This will enable a lot of the tools that wouldn't be able to run using the compatibility layer to run, and most notably &lt;strong&gt;Docker&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does it work
&lt;/h2&gt;

&lt;p&gt;The Linux kernel runs in a very lightweight virtual machine, and all of your WSL instances will run on top of it. This has an incredible impact on the performance of WSL. Since only a single instance of the virtual machine with the kernel is running, having a lot of instances of WSL won't result in a huge performance drop, a feature accentuated by the really lightweight nature of the VM containing the kernel.&lt;/p&gt;

&lt;p&gt;Adding to this, the WSL team dropped the usage of the weird compatibility layer they were using for files, and instead use native Linux filesystems directly in WSL, that way the filesystem performance are significantly enhanced.&lt;/p&gt;

&lt;p&gt;This doesn't mean that you would not be able to access your files on windows directly or vice versa, they are using a network protocol to share files across Linux and Windows. It's the method that uses Vagrant to have access to some part of your host filesystem in the guest by using Samba for example, but this time with WSL 2.0, you have access in both ways.&lt;/p&gt;

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

&lt;p&gt;With WSL 2.0, Windows give us more of the great experience that it gave the developer community with WSL 1.0. It is an impressive achievement not only because of what it enables Windows users to do, but also because of the incredible engineering feat it represents. &lt;br&gt;
for more information you can check the WSL.&lt;/p&gt;

&lt;p&gt;If you are interested in knowing more I invite to you to see the &lt;a href="https://www.youtube.com/watch?v=lwhMThePdIo"&gt;WSL Team keynote&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>windows</category>
      <category>environment</category>
      <category>wsl</category>
    </item>
    <item>
      <title>I created a JavaScript free portfolio</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Sun, 31 Mar 2019 13:14:24 +0000</pubDate>
      <link>https://dev.to/hamza/i-created-a-javascript-free-portfolio-3o91</link>
      <guid>https://dev.to/hamza/i-created-a-javascript-free-portfolio-3o91</guid>
      <description>&lt;p&gt;&lt;a href="https://hamza-tam.gitlab.io"&gt;Visit my portfolio&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I always wanted to make a portfolio, I always saw as the medium by which I could showcase my work and my skills. So I wanted it to be a true representation of how I work.&lt;/p&gt;

&lt;p&gt;I tried a lot of concepts, build five portfolios before throwing them to the trash can, and emptying it. Finally, I thought what would define how I love making software. Three worlds came out: simple, minimal, beautiful. This is how my portfolio needed to be.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simple
&lt;/h2&gt;

&lt;p&gt;The simplicity came from making from it's structure, it's layout, the choice of the technologies used in it. Why would I use JavaScript if everything that I wanted to do could be done using plain CSS. Why would I use frameworks like Bootstrap or foundation, if I could handle everything myself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Minimal
&lt;/h2&gt;

&lt;p&gt;In the choice of the information that it provides, the choice of colors and design. Basically, it's overall spirit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Beautiful
&lt;/h2&gt;

&lt;p&gt;In this case, this is a subjective matter, but looking at the current design trends, and some award winning portfolios. I think describing it as beautiful fits it.&lt;/p&gt;

&lt;p&gt;I am not done making it, there is still a lot of work to be done, I have a lot of projects to add and things to tweak. But I judged that it has reached the point where it could be published. So I thought I would submit it to the people of this wonderful community to seek their opinion and critic. &lt;/p&gt;

</description>
      <category>portfolioweb</category>
    </item>
    <item>
      <title>*nix Bash shell vs Windows PowerShell: Two paradigms</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Fri, 15 Feb 2019 20:43:12 +0000</pubDate>
      <link>https://dev.to/hamza/nix-bash-shell-vs-windows-powershell-two-paradigms-42di</link>
      <guid>https://dev.to/hamza/nix-bash-shell-vs-windows-powershell-two-paradigms-42di</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted in &lt;a href="https://hamza-tam.gitlab.io"&gt;my portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;PowerShell and Bash Shell, have quite a lot of differences. The first one is a complete scripting environment, the second is only a command line interpreter. One is suited for the management of windows servers, the second is more suited for development environment. These differences might look obvious when discovering them for the first time. But what really held my attention, was the fact that PowerShell use Objects, when Bash Shell uses plain text.&lt;/p&gt;

&lt;p&gt;Let's take a simple linux command.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The output of this command will be returned in a plain text format, that input will can be for example piped to another command like &lt;em&gt;grep&lt;/em&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l | grep Desktop
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;In this example the bash would take the output of the &lt;em&gt;ls -l&lt;/em&gt; command a string parse it looking for the pattern set in the parameter.&lt;/p&gt;

&lt;p&gt;Windows PowerShell behaves differently. Let's try to repeat the same example in it.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS &amp;gt; dir
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Now, if we want to look for a specific pattern on the text, we will pipe the result to the &lt;em&gt;Select-String&lt;/em&gt; command.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS &amp;gt; dir | Select-String -pattern "Desktop"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;At first glance you will notice a difference in how the output is displayed. Unlike grep which displayes the line where it found the pattern with the pattern highlighted. But it's not simply a display style or choice. The output is the object that matches the pattern.&lt;/p&gt;

&lt;p&gt;To see this behaviour in action let's assume that for the linux command the output is:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;drwxrwxrwx 1 hamza hamza    4096 Nov  4 18:29 Desktop
drwxrwxrwx 1 hamza hamza    4096 Nov  4 17:15 Documents
drwxrwxrwx 1 hamza hamza    4096 Nov  4 17:15 Downloads    
drwxrwxrwx 1 hamza hamza    4096 Nov  4 17:15 Favorites
drwxrwxrwx 1 hamza hamza    4096 Nov  7 10:56 IntelGraphicsProfiles
drwxrwxrwx 1 hamza hamza    4096 Nov  4 17:15 Links
drwxrwxrwx 1 hamza hamza    4096 Sep 22 01:26 MicrosoftEdgeBackups
drwxrwxrwx 1 hamza hamza    4096 Nov  4 17:15 Music
drwxrwxrwx 1 hamza hamza    4096 Oct 20 12:26 OneDrive
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Then if we use:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ls -l | grep drw
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We will get the same output but this time with &lt;em&gt;drw&lt;/em&gt; highlighted. But for the first PowerShell command if we get:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---       04/11/2018     17:15                Contacts
d-r---       04/11/2018     18:29                Desktop
d-r---       04/11/2018     17:15                Documents
d-r---       04/11/2018     17:15                Downloads
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and do a search on this output using:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PS &amp;gt; dir | Select-String -pattern "d-r"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We will get nothing in return. Because the column Mode column is a non searchable parameter by Select-String of the output Object of &lt;em&gt;dir&lt;/em&gt; (the alias of &lt;em&gt;Get-ChildItem&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;If you call Select-String with wrong arguments, it will send an error message for each file object it iterates throw.&lt;/p&gt;

&lt;p&gt;Learning about the differences in different technologies is very interesting, a way to discover how different people give different solutions to the &lt;em&gt;same problems&lt;/em&gt;. By understanding the power of each technology and it's short falls, you will start to see technology in a whole new way.&lt;/p&gt;

</description>
      <category>bashpowershell</category>
    </item>
    <item>
      <title>The history behind "grep"'s name</title>
      <dc:creator>Hamza Tamenaoul</dc:creator>
      <pubDate>Mon, 07 Jan 2019 23:54:38 +0000</pubDate>
      <link>https://dev.to/hamza/the-history-behind-greps-name--193p</link>
      <guid>https://dev.to/hamza/the-history-behind-greps-name--193p</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted in &lt;a href="https://hamza-tam.gitlab.io"&gt;my portfolio&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;grep&lt;/strong&gt;, a tool that is widely used in the Unix world, a tool that no one could live without. It's one of the first command to which every linux beginner is introduced from its start, so its function is no secret to no one. However, what's the history behind its weird name ?&lt;/p&gt;

&lt;p&gt;The answer to this question requires us to go back to the early days of Unix, days of resource scarcity, may they be processing power or memory resources. Software developper of the time had to play by the rules and develop very light programs that get the job done. And one of those tools was the &lt;strong&gt;ed&lt;/strong&gt; text editor. But this editor is nothing like the modern editor we have today (VIM looks like JetBrains IDEs next to it). To see a line of text from the text buffer you needed to type &lt;strong&gt;p&lt;/strong&gt; preceeded by the line number. And for searching the buffer for an occurence of a regular expression we could use like in VIM &lt;strong&gt;/regularexpression&lt;/strong&gt;. But for us to search for all the occurences and print them we'll use &lt;strong&gt;g/regularexpression/p&lt;/strong&gt;, written simply &lt;strong&gt;g/re/p&lt;/strong&gt;. And that's how the world &lt;strong&gt;grep&lt;/strong&gt; was born.&lt;/p&gt;

&lt;p&gt;The history of Unix is full of these stories. Amazing stories about those early days of computing.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>bash</category>
      <category>grep</category>
    </item>
  </channel>
</rss>
