<?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: Alberto Pérez de Rada Fiol</title>
    <description>The latest articles on DEV Community by Alberto Pérez de Rada Fiol (@albertopdrf).</description>
    <link>https://dev.to/albertopdrf</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%2F404329%2F90b5fc6c-056f-46d7-ad21-061ec296882c.jpeg</url>
      <title>DEV Community: Alberto Pérez de Rada Fiol</title>
      <link>https://dev.to/albertopdrf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/albertopdrf"/>
    <language>en</language>
    <item>
      <title>Range-based `for` loops</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Mon, 22 Mar 2021 08:51:38 +0000</pubDate>
      <link>https://dev.to/albertopdrf/range-based-for-loops-1kdp</link>
      <guid>https://dev.to/albertopdrf/range-based-for-loops-1kdp</guid>
      <description>&lt;p&gt;Today we are going to learn about another very useful feature of Modern C++: Range-based &lt;code&gt;for&lt;/code&gt; loops. As their name indicates, these kind of loops are useful when we want to iterate over the elements of a container, from beginning to end.&lt;/p&gt;

&lt;p&gt;Here are some of the advantages of using range-based &lt;code&gt;for&lt;/code&gt; loops:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improve the readability of the code&lt;/li&gt;
&lt;li&gt;Will be as optimized as possible&lt;/li&gt;
&lt;li&gt;The &lt;a href="https://dev.to/albertopdrf/the-awesome-auto-keyword-2f28"&gt;awesome &lt;code&gt;auto&lt;/code&gt; keyword&lt;/a&gt; can be used in the range declaration&lt;/li&gt;
&lt;li&gt;There's no need to know the size of the container we want to iterate over&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And, of course, all statements that work within a regular &lt;code&gt;for&lt;/code&gt; loop (&lt;code&gt;continue&lt;/code&gt;, &lt;code&gt;break&lt;/code&gt;, etc.) also work within range-based &lt;code&gt;for&lt;/code&gt; loops.&lt;/p&gt;

&lt;p&gt;But enough talking, let's see some examples! Imagine we have a &lt;code&gt;vector&lt;/code&gt; of &lt;code&gt;int&lt;/code&gt;s, and we want to print all of its elements to &lt;code&gt;stdout&lt;/code&gt;, how can we do it?&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="c1"&gt;// Older standards&lt;/span&gt;
  &lt;span class="c1"&gt;// Option 1&lt;/span&gt;
&lt;span class="k"&gt;for&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;i&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&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="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;i&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;vector&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;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="c1"&gt;// Option 2&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&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;iterator&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;begin&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;end&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;it&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Modern C++&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;vector&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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;That's very clean and concise! 🧐 And it gets even better when we use features from standards older than C++11. For instance, let's now imagine we have a &lt;code&gt;map&lt;/code&gt;, with &lt;code&gt;int&lt;/code&gt;s for both its &lt;code&gt;key&lt;/code&gt;s and &lt;code&gt;value&lt;/code&gt;s. How can we loop through it, displaying its contents?:&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="c1"&gt;// Older standards&lt;/span&gt;
&lt;span class="k"&gt;for&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;i&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="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&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="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; &lt;span class="n"&gt;i&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;pair&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="p"&gt;,&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;pair&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;map&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;first&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;": "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;pair&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;second&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Modern C++&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;map&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;": "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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;What was that? 😮 From C++17, we can use Structured Bindings to unpack the contents of a &lt;code&gt;pair&lt;/code&gt; (or a &lt;code&gt;tuple&lt;/code&gt;, in general) in such a compact way! But what if, for instance, we only cared about the &lt;code&gt;value&lt;/code&gt;s of the map? From C++20 we can use the Ranges Library to 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="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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;Simple and clean -- and there's more! Also from C++20, we can use the Init Statement if we need to. Let's add a very simple init statment to the last example so we can track the index of the current &lt;code&gt;value&lt;/code&gt;, as I know you are already wondering what to do when the index is needed:&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="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;i&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="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;map&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;views&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"Value "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;": "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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;Do you need more examples, or are you already convinced that range-based &lt;code&gt;for&lt;/code&gt; loops are such a great addition to C++? Tell me in the comments! 👇&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>learning</category>
      <category>todayilearned</category>
      <category>programming</category>
    </item>
    <item>
      <title>The awesome `auto` keyword</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Mon, 25 Jan 2021 17:17:48 +0000</pubDate>
      <link>https://dev.to/albertopdrf/the-awesome-auto-keyword-2f28</link>
      <guid>https://dev.to/albertopdrf/the-awesome-auto-keyword-2f28</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In modern C++, you write &lt;code&gt;auto auto(auto auto) { auto; }&lt;/code&gt; and the compiler infers the rest&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Ok, it's not that easy, but I promise that using &lt;code&gt;auto&lt;/code&gt; does indeed feel like magic. Let's go with the first article with actual content of the &lt;code&gt;Learning modern C++&lt;/code&gt; series!&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;auto&lt;/code&gt; keyword is used to let the compiler infer the type of a variable automatically from its initial value instead of having to explicitly declare it. (Bonus: forget about uninitialized variables!) For instance:&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="c1"&gt;// Older standards&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&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="c1"&gt;// Modern C++&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;i&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first, this may not seem like a huge deal, but let's see another example. If we have a &lt;code&gt;getMatrix&lt;/code&gt; function that returns a &lt;code&gt;std::vector&amp;lt;std::vector&amp;lt;int&amp;gt;&amp;gt;&lt;/code&gt; type, we can easily print all its elements with a range-based &lt;code&gt;for&lt;/code&gt; loop (if you don't know what a range-based &lt;code&gt;for&lt;/code&gt; loop is, you'll love the next article of this series!). In this example, you'll see how &lt;code&gt;auto&lt;/code&gt; starts to shine a bit more:&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="c1"&gt;// Older standards&lt;/span&gt;
&lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&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;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getMatrix&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="n"&gt;std&lt;/span&gt;&lt;span class="o"&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;row&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="p"&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="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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="c1"&gt;// Modern C++&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;getMatrix&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="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;matrix&lt;/span&gt;&lt;span class="p"&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="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;element&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;endl&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hey, isn't that cool? 😎 And it gets even better! What would happen if the &lt;code&gt;getMatrix&lt;/code&gt; function was changed to return a &lt;code&gt;std::vector&amp;lt;std::vector&amp;lt;double&amp;gt;&amp;gt;&lt;/code&gt; type instead? With older C++ standards, we would have to adapt our code in order for it to work again, but using the modern C++ &lt;code&gt;auto&lt;/code&gt; keyword we wouldn't need to touch anything!&lt;/p&gt;

&lt;p&gt;Of course, this gets even more meaningful in real-world examples, but I think the ones presented should be enough to at least spark some interest.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;auto&lt;/code&gt; can also be used in function declarations, although I must admit that I haven't committed to it (yet?). The syntax is:&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="c1"&gt;// Older standards&lt;/span&gt;
&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;getIntParameter&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;parameter&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;parameter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Modern C++&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;getIntParameter&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;parameter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="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;parameter&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;However, it can be very useful when used in conjunction with the &lt;code&gt;decltype&lt;/code&gt; specifier (which inspects the declared type of a varibale):&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="k"&gt;template&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;typename&lt;/span&gt; &lt;span class="nc"&gt;U&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="nf"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;U&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;decltype&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&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;t&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;u&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;Note that in the example above we don't know the types &lt;code&gt;t&lt;/code&gt; and &lt;code&gt;u&lt;/code&gt;, but we don't even need it! We could call the function like:&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="k"&gt;auto&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;sum&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;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// (int) 2&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sum&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="mf"&gt;0.14&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// (double) 1.14&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sum&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="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// (double) 3.14&lt;/span&gt;
&lt;span class="k"&gt;auto&lt;/span&gt; &lt;span class="n"&gt;tau&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pi&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// (double) 6.28&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And everything will work wonderfully 🎉&lt;/p&gt;

&lt;p&gt;That's probably enough for the post, let me know what you think of it on the comments section below! Reacting to and sharing the post is also appreciated 😊 And, as always, thanks for reading!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>learning</category>
      <category>todayilearned</category>
      <category>programming</category>
    </item>
    <item>
      <title>I turned What's Going On (Whagon) into a Rails app!</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Thu, 21 Jan 2021 11:50:50 +0000</pubDate>
      <link>https://dev.to/albertopdrf/i-turned-what-s-going-on-whagon-into-a-rails-app-3lho</link>
      <guid>https://dev.to/albertopdrf/i-turned-what-s-going-on-whagon-into-a-rails-app-3lho</guid>
      <description>&lt;p&gt;A few days ago, I presented a very simple React app that shows what's going on in any GitHub repository. You can read about it here:&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/albertopdrf" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1tK95KUb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--BNsezpQQ--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/404329/90b5fc6c-056f-46d7-ad21-061ec296882c.jpeg" alt="albertopdrf image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/albertopdrf/get-to-know-what-s-going-on-in-any-github-repository-5709" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Get to know what's going on in any GitHub repository!&lt;/h2&gt;
      &lt;h3&gt;Alberto Pérez de Rada Fiol ・ Jan 18 ・ 1 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#react&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#showdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;After thinking a bit more about it, I decided to go ahead and turn the app into a Rails app with a React frontend powered by the &lt;code&gt;react-rails&lt;/code&gt; gem, &lt;a href="https://whagon.herokuapp.com"&gt;you can check it out here&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;I decided to go the Rails way for a few reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A backend was needed to be able to implement a GitHub login (already done! 😎), which will allow for many other features to come, stay tunned for them!&lt;/li&gt;
&lt;li&gt;I wanted to build something with Rails again for too long 😜&lt;/li&gt;
&lt;li&gt;Do you really need more? 😁&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'll keep you posted on the progress, thanks for reading!&lt;/p&gt;

</description>
      <category>rails</category>
      <category>react</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
    <item>
      <title>Get to know what's going on in any GitHub repository!</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Mon, 18 Jan 2021 18:01:18 +0000</pubDate>
      <link>https://dev.to/albertopdrf/get-to-know-what-s-going-on-in-any-github-repository-5709</link>
      <guid>https://dev.to/albertopdrf/get-to-know-what-s-going-on-in-any-github-repository-5709</guid>
      <description>&lt;p&gt;Ever since I started using GitHub, I felt like its repositories could use a "What's going on" section, so checking what a huge project is up to is easier. So, I just built that!&lt;/p&gt;

&lt;p&gt;Today I present &lt;a href="https://whats-going-on.netlify.app/"&gt;What's Going On&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What the website does now is not even near to what it could end up doing, but I thought it was better to put a hopefully useful preliminary version out in the open as soon as possible than to keep procrastinating on building anything at all. By the way, I seized the opportunity to try out &lt;a href="https://primer.style/"&gt;GitHub's Primer Style&lt;/a&gt;, which is quite nice to work with!&lt;/p&gt;

&lt;p&gt;The source code is can be found at&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/AlbertoPdRF"&gt;
        AlbertoPdRF
      &lt;/a&gt; / &lt;a href="https://github.com/AlbertoPdRF/whats-going-on"&gt;
        whats-going-on
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Check what's going on any GitHub repository!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;This project was bootstrapped with &lt;a href="https://github.com/facebook/create-react-app"&gt;Create React App&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
Available Scripts&lt;/h2&gt;
&lt;p&gt;In the project directory, you can run:&lt;/p&gt;
&lt;h3&gt;
&lt;code&gt;yarn start&lt;/code&gt;
&lt;/h3&gt;
&lt;p&gt;Runs the app in the development mode.&lt;br&gt;
Open &lt;a href="http://localhost:3000" rel="nofollow"&gt;http://localhost:3000&lt;/a&gt; to view it in the browser.&lt;/p&gt;
&lt;p&gt;The page will reload if you make edits.&lt;br&gt;
You will also see any lint errors in the console.&lt;/p&gt;
&lt;h3&gt;
&lt;code&gt;yarn test&lt;/code&gt;
&lt;/h3&gt;
&lt;p&gt;Launches the test runner in the interactive watch mode.&lt;br&gt;
See the section about &lt;a href="https://facebook.github.io/create-react-app/docs/running-tests" rel="nofollow"&gt;running tests&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h3&gt;
&lt;code&gt;yarn build&lt;/code&gt;
&lt;/h3&gt;
&lt;p&gt;Builds the app for production to the &lt;code&gt;build&lt;/code&gt; folder.&lt;br&gt;
It correctly bundles React in production mode and optimizes the build for the best performance.&lt;/p&gt;
&lt;p&gt;The build is minified and the filenames include the hashes.&lt;br&gt;
Your app is ready to be deployed!&lt;/p&gt;
&lt;p&gt;See the section about &lt;a href="https://facebook.github.io/create-react-app/docs/deployment" rel="nofollow"&gt;deployment&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h3&gt;
&lt;code&gt;yarn eject&lt;/code&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Note: this is a one-way operation. Once you &lt;code&gt;eject&lt;/code&gt;, you can’t go back!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you aren’t satisfied with the build tool and configuration…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/AlbertoPdRF/whats-going-on"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;although the repository is not quite ready for visits 😜&lt;/p&gt;

&lt;p&gt;Let me know what you think of the website in the comments section!&lt;/p&gt;

&lt;p&gt;And thanks for dropping by 😊&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>showdev</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Let's learn some modern C++!</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Thu, 17 Dec 2020 18:49:23 +0000</pubDate>
      <link>https://dev.to/albertopdrf/let-s-learn-some-modern-c-2b0f</link>
      <guid>https://dev.to/albertopdrf/let-s-learn-some-modern-c-2b0f</guid>
      <description>&lt;p&gt;As I'm sure it's many other people's case, I started learning C++ as part of one of my university courses (8 years ago already 🤯), and to be honest, it did get quite overwhelming at times! However, it was also astonishing and encouraging to see how many things one could do with it, so I ended up enjoying the class.&lt;/p&gt;

&lt;p&gt;I used the language throughout my degree to solve various tasks, but it wasn't until my graduate life that I started making a heavy usage of it, mostly to write data analysis programs (which most of the time make use of &lt;a href="https://root.cern/"&gt;ROOT&lt;/a&gt;) and &lt;a href="https://geant4.web.cern.ch/"&gt;Geant4&lt;/a&gt; applications for the simulation of experimental setups.&lt;/p&gt;

&lt;p&gt;However, I started noticing how I relied too much on stuff I had learnt long ago - and maybe not as rigorously as I should have - as a result of which my code always ended up full of patches, workarounds, bad style, ... in short, I was producing unmaintenable and very difficult to reuse or extend code.&lt;/p&gt;

&lt;p&gt;So, I made up my mind and since a few months ago I'm focusing on reinforcing the concepts I already knew, learning new ones, applying new syntax and good practices, etc. and I figured out it would be a good idea to document part of that process here! I'll be posting some short articles as part of this series explaining what I learn along the way, and hopefully inspire some people and/or spark some nice discussions!&lt;/p&gt;

&lt;p&gt;How does that sound? If you don't want to miss any of the articles, make sure to follow me!&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>learning</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Gathering interest for an interests package</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Fri, 11 Sep 2020 11:36:05 +0000</pubDate>
      <link>https://dev.to/albertopdrf/gathering-interest-for-an-interests-package-3h0j</link>
      <guid>https://dev.to/albertopdrf/gathering-interest-for-an-interests-package-3h0j</guid>
      <description>&lt;p&gt;One of the biggest concerns I had when I first started developing &lt;a href="https://tisn.app"&gt;Tisn&lt;/a&gt; was how to craft a good enough list of interests, as it's a critical part of the application. Questions like: "What to include?", "How to organize it?", or "Where to get icons for it from?" were revolving around my head for way too much time, until I finally settled on &lt;a href="https://github.com/Tisn/tisn.app/commit/a774597b8119047dd93ffa631d0ca3299c06b58f"&gt;a list of interests and a set of icons&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, since then I've had in mind that creating and maintaining such a list in a more distributable way has the potential to be a very useful project. So here I am, writing this post to see if people would be interested (pun intended 😛) in such a project and even in working on it with me!&lt;/p&gt;

&lt;p&gt;Now, a short list of the requirements I thought for the project follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contain a (somewhat) complete list of interests&lt;/li&gt;
&lt;li&gt;Be organized in categories&lt;/li&gt;
&lt;li&gt;Provide custom icons&lt;/li&gt;
&lt;li&gt;Have an open source license&lt;/li&gt;
&lt;li&gt;Be distributed as an npm package&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As can be seen from the list of requirements above, this project touches many different kinds of work, so it could be a great opportunity to work with people from many different backgrounds!&lt;/p&gt;

&lt;p&gt;Without any more hesitation, here go the questions: are you interested in such a project? Would you like to get involved in it? Drop a comment below and let's get the discussion started!&lt;/p&gt;

&lt;p&gt;And one last thing: if you react to and share this post for further reach I'll appreaciate it very much!&lt;/p&gt;

&lt;p&gt;Thanks for reading, I'm looking forward to hearing from you!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>npm</category>
      <category>design</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Share content natively with the Web Share API</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Sat, 25 Jul 2020 09:42:25 +0000</pubDate>
      <link>https://dev.to/albertopdrf/share-content-natively-with-the-web-share-api-2l20</link>
      <guid>https://dev.to/albertopdrf/share-content-natively-with-the-web-share-api-2l20</guid>
      <description>&lt;p&gt;Today I'm going to explain how to share content natively using the &lt;a href="https://www.w3.org/TR/web-share/" rel="noopener noreferrer"&gt;Web Share API&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I first found out about this API when trying to figure out how to allow users of &lt;a href="https://tisn.app/" rel="noopener noreferrer"&gt;an application I was developing&lt;/a&gt; to share content with other applications. I didn't want to use external libraries or have to manually implement methods for every application I wanted to support (among other things because I wanted to support them all 😛) and was so glad when I finally found this API and saw that it was exactly what I was looking for! As I think not so many people know about the API yet, I'll try to explain how it works hoping that it will help anyone in the same situation I found myself in.&lt;/p&gt;

&lt;p&gt;Before starting, it's worth noting that &lt;a href="https://caniuse.com/#feat=web-share" rel="noopener noreferrer"&gt;the API isn't supported by many of the major browsers yet&lt;/a&gt;. However, it will work for pretty much any user browsing your web application from their phones, which is where it is more necessary in my opinion. As such, a fallback mechanism will have to be implemented for when the user is using a browser that doesn't support the API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;In this tutorial I'll walk you through my own implementation of the API, which was on a &lt;a href="https://reactjs.org/" rel="noopener noreferrer"&gt;React&lt;/a&gt; application that uses &lt;a href="https://material-ui.com/" rel="noopener noreferrer"&gt;Material-UI&lt;/a&gt;. If you are curious, you can take a look at &lt;a href="https://github.com/Tisn/tisn.app" rel="noopener noreferrer"&gt;the whole repository&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Let's start with the actual tutorial! As I wanted to be able to share different kinds of resources, what made the most sense was to build a reusable component which implemented all the logic and user interface. The JSX of that component looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Fragment&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IconButton&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;primary&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;handleClick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ShareIcon&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/IconButton&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Menu&lt;/span&gt;
    &lt;span class="nx"&gt;anchorEl&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;anchorEl&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;keepMounted&lt;/span&gt;
    &lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;anchorEl&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;onClose&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="nf"&gt;handleClose&lt;/span&gt;&lt;span class="p"&gt;()}&lt;/span&gt;
  &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MenuItem&lt;/span&gt; &lt;span class="nx"&gt;onClick&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="nf"&gt;handleChatsClick&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="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shareMenu.chats&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MenuItem&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;MenuItem&lt;/span&gt; &lt;span class="nx"&gt;onClick&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="nf"&gt;handleMoreClick&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="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;shareMenu.more&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/MenuItem&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Menu&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/Fragment&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But let's see how all of this works, as just sharing the JSX is not that useful! 😄 First, we have the share button that we'll be presenting to the user (the &lt;code&gt;IconButton&lt;/code&gt; component) that calls the &lt;code&gt;handleClick&lt;/code&gt; function on click. This &lt;code&gt;handleClick&lt;/code&gt; function is the function where we'll check if the Web Share API is supported in the current browser in order to decide what to show to the user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleClick&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&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;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;share&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setAnchorEl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentTarget&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;handleChatsClick&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To do that, we simply check for the &lt;code&gt;navigator.share&lt;/code&gt; method of the API. If it exists, we present the user with a two option menu by setting the anchor element of it. If not, we just call the &lt;code&gt;handleChatsClick&lt;/code&gt; function. This function is responsible for direct in app sharing through the chat system of the application, and won't be covered in this article to try and stay on topic. Here's where you would implement any fallback mechanism for browsers that don't support the API, but for me direct in app sharing was enough of a fallback.&lt;/p&gt;

&lt;p&gt;Let's now see what the &lt;code&gt;handleMoreClick&lt;/code&gt; function does, which is where the actual Web Share API logic is implemented:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;handleMoreClick&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="nf"&gt;handleClose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nb"&gt;navigator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;share&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&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;Wow! Easy, right? 😎 We just close the menu with the &lt;code&gt;handleClose&lt;/code&gt; function (setting the anchor element of it to &lt;code&gt;null&lt;/code&gt;) and call the &lt;code&gt;navigator.share&lt;/code&gt; method of the Web Share API with the &lt;code&gt;params&lt;/code&gt; object. At this point, the user will be presented with the native share menu:&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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0165wfz6u1t4ij65dhxx.jpg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F0165wfz6u1t4ij65dhxx.jpg" alt="Native share menu"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;params&lt;/code&gt; object passed to the &lt;code&gt;navigator.share&lt;/code&gt; method comes directly from the properties passed to the component, and it looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Text&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;URL&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Given how the data that we pass through the Web Share API is handled by Android (I haven't been able to test this on iOS), I've found out that the best strategy is to have the &lt;code&gt;title&lt;/code&gt; and &lt;code&gt;text&lt;/code&gt; be the same string. Also, it's worth noting that the &lt;code&gt;url&lt;/code&gt; will be appended to the end of &lt;code&gt;text&lt;/code&gt; -- but this is something that we only have to care about if we want to handle receiving data. Wait, is there an API that allows our application to receive data from other apps? Oh yes, there is! If you want me to write an article about it, let me know it in the comments section and I'll gladly do it! 😊&lt;/p&gt;

&lt;p&gt;Besides, the Web Share API allows sharing files with other apps too, although I haven't played with that as it didn't apply to my use case.&lt;/p&gt;

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

&lt;p&gt;In this article we've gone through a simple implementation of the Web Share API, which allows us to share content of our application with other apps through the native share menu. This API solves the problem of having to rely on external libraries or having to implement custom methods in order to share content of our application with other apps, and although it's not supported by many major browsers, it should work on almost any phone.&lt;/p&gt;

&lt;p&gt;I hope this tutorial has been useful for you, let me know it by reacting to it and/or posting a comment. And, of course, thanks for reading!&lt;/p&gt;

&lt;p&gt;See you around 👋&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>mobile</category>
      <category>webdev</category>
    </item>
    <item>
      <title>New GitHub UI ✨</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Thu, 18 Jun 2020 10:24:18 +0000</pubDate>
      <link>https://dev.to/albertopdrf/new-github-ui-4p4e</link>
      <guid>https://dev.to/albertopdrf/new-github-ui-4p4e</guid>
      <description>&lt;p&gt;What do you think about GitHub's new UI?&lt;/p&gt;

&lt;p&gt;If you haven't seen it yet, you can enable it by clicking on your avatar on the top right of the screen, then on &lt;code&gt;Feature preview&lt;/code&gt;, and lastly enabling one or both of the features listed there.&lt;/p&gt;

</description>
      <category>github</category>
      <category>ui</category>
      <category>ux</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Tisn is now an open source project!</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Tue, 16 Jun 2020 15:40:40 +0000</pubDate>
      <link>https://dev.to/albertopdrf/tisn-is-now-an-open-source-project-2ko0</link>
      <guid>https://dev.to/albertopdrf/tisn-is-now-an-open-source-project-2ko0</guid>
      <description>&lt;p&gt;Last week I posted about why I created a social network, and the article received quite a bit of feedback that I appreciated very much. Make sure to take a look at it if you haven't seen it yet!&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/albertopdrf" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1tK95KUb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--BNsezpQQ--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/404329/90b5fc6c-056f-46d7-ad21-061ec296882c.jpeg" alt="albertopdrf image"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="/albertopdrf/why-i-created-a-social-network-1fad" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Why I created a social network&lt;/h2&gt;
      &lt;h3&gt;Alberto Pérez de Rada Fiol ・ Jun 13 ・ 2 min read&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#webdev&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#showdev&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;On the article I presented &lt;a href="https://tisn.app"&gt;tisn.app&lt;/a&gt;, a new social network that I've been working on for the past few months. This article is a quick follow up to let everyone now that Tisn is now an open source project!&lt;/p&gt;

&lt;p&gt;There's still &lt;strong&gt;a lot&lt;/strong&gt; of stuff, in every sense, to figure out and work on, but I decided to take this step now as probably a lot of people would like to experience contributing and setting the direction of a newborn project. Make sure to drop by the repository!&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Tisn"&gt;
        Tisn
      &lt;/a&gt; / &lt;a href="https://github.com/Tisn/tisn.app"&gt;
        tisn.app
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Tisn - The introverts' social network ➡️ Meet people while doing what you enjoy!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div&gt;
  &lt;br&gt;
  &lt;a rel="noopener noreferrer" href="https://raw.githubusercontent.com/Tisn/tisn.app/master/./client/public/logo192.png"&gt;&lt;img alt="Tisn" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Kt-bopdO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://raw.githubusercontent.com/Tisn/tisn.app/master/./client/public/logo192.png"&gt;&lt;/a&gt;
  &lt;h1&gt;
Tisn - The introverts' social network&lt;/h1&gt;
  &lt;strong&gt;Meet people while doing what you enjoy!&lt;/strong&gt;
&lt;/div&gt;
&lt;h2&gt;
Table of contents&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#what-is-tisnapp"&gt;What is tisn.app?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#contributing"&gt;Contributing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#getting-started"&gt;Getting Started&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#prerequisites"&gt;Prerequisites&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#back-end-or-api-or-server"&gt;Back end (or API, or server)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#front-end-or-client"&gt;Front end (or client)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#important-note"&gt;Important note&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/Tisn/tisn.app/master/#license"&gt;License&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
What is tisn.app?&lt;/h2&gt;
&lt;p&gt;Welcome to the &lt;a href="https://tisn.app/" rel="nofollow"&gt;tisn.app&lt;/a&gt; (or just Tisn) repository! We are very glad to have you here. If you want to help us make Tisn better, this is definitely the place to be!&lt;/p&gt;
&lt;p&gt;The primary objective of Tisn is to try and address the problem of the apparent difficulty that exists to meet people and make new friends on this modern world. To do that, our social network:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Connects people according to their interests&lt;/li&gt;
&lt;li&gt;Encourages people to go outside and meet others while doing something that they all enjoy&lt;/li&gt;
&lt;li&gt;Is as simple as possible&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We try to do all of that while being completely transparent and respecting our users' privacy.&lt;/p&gt;
&lt;h2&gt;
Contributing&lt;/h2&gt;
&lt;p&gt;We…&lt;/p&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Tisn/tisn.app"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;I'm very excited about the project in general and this step in particular, and hopefully some of you are too! If that's the case, make sure to let me know by reacting and/or commenting to the post!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>showdev</category>
      <category>contributorswanted</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Why I created a social network</title>
      <dc:creator>Alberto Pérez de Rada Fiol</dc:creator>
      <pubDate>Sat, 13 Jun 2020 18:28:36 +0000</pubDate>
      <link>https://dev.to/albertopdrf/why-i-created-a-social-network-1fad</link>
      <guid>https://dev.to/albertopdrf/why-i-created-a-social-network-1fad</guid>
      <description>&lt;p&gt;A few years ago, I started getting interested in web development because of the great opportunity it provides to make an impact both on an individual and a community level. My first contributions were to the speedcubing community (see for instance the WCA &lt;a href="https://www.worldcubeassociation.org"&gt;website&lt;/a&gt; and &lt;a href="https://github.com/thewca/worldcubeassociation.org"&gt;repository&lt;/a&gt;). I enjoyed the experience so much that I just couldn't resist getting more into it.&lt;/p&gt;

&lt;p&gt;Fast forward to a few months ago, I wanted to try and solve a problem that has bothered me for years, which is the apparent difficulty that exists to meet people and make new friends on this modern world. I could go way deeper into this, but it falls out of the scope of this post. So, to address the problem, I designed a social network that basically:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connects people according to their interests.&lt;/li&gt;
&lt;li&gt;Encourages people to go outside and meet others while doing something that they all enjoy.&lt;/li&gt;
&lt;li&gt;It's as simple as possible.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In order to accomplish those 3 points, the experience goes like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a profile, which requires only the absolutely necessary personal information.

&lt;ul&gt;
&lt;li&gt;For example, the gender is not needed at all, so why request that information in the first place?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Select your interests.&lt;/li&gt;
&lt;li&gt;Be presented with event recommendations in your area.

&lt;ul&gt;
&lt;li&gt;An event can really be anything: go to the cinema, play a basketball game, visit a museum, attend a hackaton, etc.&lt;/li&gt;
&lt;li&gt;You are also able to create your own events.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's the very basic functionality, but there's a bit more of stuff in order to provide a more complete experience:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each event has its own comments' wall so attendants to it have an easy way to communicate with each other.&lt;/li&gt;
&lt;li&gt;A person can send a friendship request to any other person, which has to be accepted to become friends.&lt;/li&gt;
&lt;li&gt;Private chats between friends.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's it! To build all of that, I used React and Material UI for the front end (hosted on Netlify), Node.js and Express.js for the back end (hosted on Heroku), and MongoDB for the database (hosted on MongoDB Atlas). The code is on GitHub, although it isn't open sourced yet for various reasons, but the plan is for it to be -- I can only imagine how amazing it would be to receive contributions from people as interested on the project as I am!&lt;/p&gt;

&lt;p&gt;Please visit &lt;a href="https://tisn.app"&gt;Tisn - The introverts' social network&lt;/a&gt; and let me know what you think about it on the comments' section below! If there's intereste on the topic, I would be very glad to post more about both the technical and the personal side of it.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
