<?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: Navneet Sahota</title>
    <description>The latest articles on DEV Community by Navneet Sahota (@navi).</description>
    <link>https://dev.to/navi</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%2F83056%2F554d49d6-6018-42e4-91cd-15db73cd3655.jpg</url>
      <title>DEV Community: Navneet Sahota</title>
      <link>https://dev.to/navi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/navi"/>
    <language>en</language>
    <item>
      <title>Revisiting LCA Problem</title>
      <dc:creator>Navneet Sahota</dc:creator>
      <pubDate>Mon, 22 Jul 2019 12:16:15 +0000</pubDate>
      <link>https://dev.to/navi/revisiting-lca-problem-2npf</link>
      <guid>https://dev.to/navi/revisiting-lca-problem-2npf</guid>
      <description>&lt;p&gt;Today, I read a &lt;a href="https://github.com/papers-we-love/papers-we-love/blob/master/data_structures/lca-revisited.pdf" rel="noopener noreferrer"&gt;paper by Michael A. Bender &amp;amp; Martı́n Farach-Colton&lt;/a&gt; on one of the most fundamental algorithmic problem on trees, &lt;strong&gt;The LCA algorithm&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
Here’s what I learned from it.&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%2Fcdn-images-1.medium.com%2Fmax%2F677%2F1%2AZ3XjF0oMk7V7Q2BDqbpfrQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F677%2F1%2AZ3XjF0oMk7V7Q2BDqbpfrQ.png"&gt;&lt;/a&gt;Least Common Ancestor&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;&lt;em&gt;Least Common Ancestor&lt;/em&gt;&lt;/strong&gt; of two nodes A and B in a tree is a shared ancestor of A and B that is located farthest from the root. The LCA problem is a pretty interesting one because fast algorithms for the LCA problem can be used to solve other algorithmic problems. &lt;em&gt;Harel and Tarjan&lt;/em&gt; showed that LCA queries can be answered in constant time by doing some linear preprocessing of the tree. Unfortunately, it is also well understood that the actual algorithm is too complicated to be implemented efficiently. The hypothesis made by algorithm designers is that the LCA problem still does not have an implementable optimal solution. Thus, concluding that it’s better to have a solution of LCA problem that doesn’t rely on preprocessing. This notion is been argued in the paper.&lt;/p&gt;

&lt;p&gt;In this paper, the authors present the re-engineered PRAM algorithm, which might not be a promising solution at first. But, when PRAM complications are removed we are left with an extremely simple algorithm.&lt;/p&gt;

&lt;p&gt;We start with &lt;strong&gt;RMQ&lt;/strong&gt; , &lt;em&gt;Range Minimum Query problem,&lt;/em&gt; which might seem pretty different from LCA but is closely linked. According to Wikipedia,&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Range minimum query&lt;/strong&gt; (RMQ) solves the problem of finding the minimal value in a sub-array of an array of comparable objects.&lt;/p&gt;
&lt;/blockquote&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%2Fcdn-images-1.medium.com%2Fmax%2F501%2F1%2Ae7LnBd3ILquP_gxw8RT4fA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F501%2F1%2Ae7LnBd3ILquP_gxw8RT4fA.png"&gt;&lt;/a&gt;Range Minimum Query&lt;/p&gt;

&lt;p&gt;Now, we introduce some notations to simplify the description of algorithms. If an algorithm has preprocessing time &lt;strong&gt;f(n)&lt;/strong&gt; &amp;amp; query time &lt;strong&gt;g(n)&lt;/strong&gt;, we will say that the algorithm has complexity if &lt;strong&gt;.&lt;/strong&gt; Our solution to LCA is derived from RMQ so we reduce LCA problem to RMQ problem.&lt;/p&gt;

&lt;p&gt;We establish a lemma that if there is &lt;strong&gt;&lt;/strong&gt; time solution to RMQ, them there exist a &lt;strong&gt;&lt;/strong&gt; time solution for LCA, where &lt;strong&gt;O(n)&lt;/strong&gt; is the preprocessing cost, &lt;strong&gt;(2n - 1)&lt;/strong&gt; is the length of the resultant array and &lt;strong&gt;O(1)&lt;/strong&gt; is time needed to convert the RMQ answer to LCA answer.&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%2Fcdn-images-1.medium.com%2Fmax%2F181%2F1%2ARQhX35dAOx0CpXA8phmUXw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F181%2F1%2ARQhX35dAOx0CpXA8phmUXw.png"&gt;&lt;/a&gt;Euler Tour&lt;/p&gt;

&lt;p&gt;Now, we create an array &lt;strong&gt;E&lt;/strong&gt; , of &lt;strong&gt;(2n - 1)&lt;/strong&gt; length doing a Euler Tour of the tree. Compute the Level array where &lt;strong&gt;L[i]&lt;/strong&gt; is the depth of the node &lt;strong&gt;E[i]&lt;/strong&gt;. Let the representative of a node in a Euler tour be the index of the first occurrence of the node in the tour. And compute the Representative Array &lt;strong&gt;R&lt;/strong&gt; of length n, where &lt;strong&gt;R[i]&lt;/strong&gt; is the index of the representative of node &lt;strong&gt;&lt;em&gt;i&lt;/em&gt;&lt;/strong&gt;. All this takes &lt;strong&gt;O(n)&lt;/strong&gt; time.&lt;/p&gt;

&lt;p&gt;We observe that,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The nodes in the Euler Tour between the first visits to &lt;strong&gt;u&lt;/strong&gt; and to &lt;strong&gt;v&lt;/strong&gt; are &lt;strong&gt;E[R[u],…., R[v]].&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The shallowest node in this sub tour is at index &lt;strong&gt;RMQ(R[u], R[v]).&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;The node at this position is &lt;strong&gt;E[RMQ(R[u], R[v])]&lt;/strong&gt;, which is thus the output of &lt;strong&gt;LCA(u, v).&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thus, we can complete our reduction in said time and space complexity of preprocessing the Level array L for RMQ.&lt;/p&gt;

&lt;p&gt;From now, we will focus on RMQ and how to optimize it. RMQ’s preprocessing time can be reduced to &lt;strong&gt;O(n²)&lt;/strong&gt; from &lt;strong&gt;O(n³)&lt;/strong&gt; by dynamic programming.&lt;/p&gt;

&lt;p&gt;We further reduce this brute-force algorithm to get the Sparse Table (ST) algorithm for RMQ which has a complexity of &lt;strong&gt;O( n log n).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In Level array L from the above reduction, adjacent elements differ by +1 &amp;amp; -1. This is because in a Euler tour, one element is always the parent of the other, and so their levels differ by exactly one. We consider this as a &lt;strong&gt;special&lt;/strong&gt; &lt;strong&gt;(+1,-1) RMQ&lt;/strong&gt; problem.&lt;/p&gt;

&lt;p&gt;Now we use the &lt;strong&gt;ST algorithm&lt;/strong&gt; on our special RMQ problem. We will use the table lookup technique to remove the &lt;strong&gt;O(log n)&lt;/strong&gt; part from precomputing. We use 2 arrays along with the ST algorithm to reduce the running time to &lt;strong&gt;O(n).&lt;/strong&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F488%2F1%2AdsHi_eFo2nvXz23fGAlR9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F488%2F1%2AdsHi_eFo2nvXz23fGAlR9w.png"&gt;&lt;/a&gt;Sparse Table&lt;/p&gt;

&lt;p&gt;This works for our special RMQ problem. In order to prove it works for general RMQ problems, we first reduce RMQ to LCA and then back to our special RMQ problem. We can easily do that in &lt;strong&gt;O(n)&lt;/strong&gt; time and thus our algorithm works for all RMQ problems in &lt;strong&gt;O(n)&lt;/strong&gt; time.&lt;/p&gt;

</description>
      <category>leastcommonancesto</category>
      <category>lca</category>
      <category>rmq</category>
      <category>programming</category>
    </item>
    <item>
      <title>What are all the possible ways to style pseudo-elements and pseudo-classes other than using classes in React?</title>
      <dc:creator>Navneet Sahota</dc:creator>
      <pubDate>Mon, 18 Mar 2019 08:53:56 +0000</pubDate>
      <link>https://dev.to/navi/what-are-all-the-possible-ways-to-style-pseudo-elements-and-pseudo-classes-other-than-using-classes-in-react-48e2</link>
      <guid>https://dev.to/navi/what-are-all-the-possible-ways-to-style-pseudo-elements-and-pseudo-classes-other-than-using-classes-in-react-48e2</guid>
      <description>

</description>
      <category>react</category>
      <category>css</category>
    </item>
    <item>
      <title>User Study: TED App</title>
      <dc:creator>Navneet Sahota</dc:creator>
      <pubDate>Mon, 18 Jun 2018 03:36:20 +0000</pubDate>
      <link>https://dev.to/navi/user-study-ted-app-3lg9</link>
      <guid>https://dev.to/navi/user-study-ted-app-3lg9</guid>
      <description>&lt;p&gt;Firstly, let me give you some information about TED. As stated on their official website:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;TED is a nonprofit devoted to spreading ideas, usually in the form of short, powerful talks (18 minutes or less). TED began in 1984 as a conference where Technology, Entertainment and Design converged, and today covers almost all topics — from science to business to global issues — in more than 100 languages. Meanwhile, independently run TEDx events help share ideas in communities around the world.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bScsgKTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/940/1%2AUGnpwo-rY4ETfC9JKC37xg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bScsgKTd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/940/1%2AUGnpwo-rY4ETfC9JKC37xg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Personally, I think that this app has a pretty sweet design. This was one of the reasons why I decided to do a User Study for this app. I asked my brother to install and just freely move around exploring all the features.&lt;/p&gt;

&lt;p&gt;So, he installed the app on his phone and the first thing I noticed was that there was no First-time-Tutorial. That was a little odd.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m8xqnhcR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AwPiwn_cpwMF6FsxwzsoJ9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m8xqnhcR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AwPiwn_cpwMF6FsxwzsoJ9w.png" alt=""&gt;&lt;/a&gt;Home Screen&lt;/p&gt;

&lt;p&gt;He navigated his way to different section all by himself and then finally came to the profile section. The profile section has a ‘Log In’ option but no ‘Sign Up’ option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DfyvDvPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZYEy787fInTZVDvCWPbISQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DfyvDvPi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AZYEy787fInTZVDvCWPbISQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lyPth1Cb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4N-Sx0aV41CpGlaoWqaTaw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lyPth1Cb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A4N-Sx0aV41CpGlaoWqaTaw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you click on ‘Log In’, it redirects you to the login page which is not very pleasing.&lt;/p&gt;

&lt;p&gt;Also, there are only two options for logging in: via Facebook which redirects you to yet another page and via normal email and password method.&lt;/p&gt;

&lt;p&gt;There is no login via google option which was quite odd as most apps provide google sign up/login option.&lt;/p&gt;

&lt;p&gt;But Surprisingly, ‘Sign Up’ option is available on this page. To add more to the discomfort, it will redirect you to official TED site for signing up your account which is really annoying.&lt;/p&gt;

&lt;p&gt;After all this, he managed to create his account and as he was trying to search for some video I noticed a badly placed search button. This search button is placed at the bottom and it took him a while to realize that it’s not in the top menu.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6_JHMRCA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A2GsSvROLD_OpaimIoAQZSA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6_JHMRCA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2A2GsSvROLD_OpaimIoAQZSA.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iHxTLXNI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AS8GNwnsut7q1KanZ3i-chQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iHxTLXNI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AS8GNwnsut7q1KanZ3i-chQ.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oP12JvDE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AfdQ-MtoddphyAoc2rUw67g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oP12JvDE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AfdQ-MtoddphyAoc2rUw67g.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, he selected and played the video and everything worked well. He discovered another feature which is that the audio will keep on playing even when we have minimized the video. It’s a cool feature and was appreciated by the user.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5ivDVgd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACYihji564QD4D5AE85Zmgg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5ivDVgd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2ACYihji564QD4D5AE85Zmgg.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Observation
&lt;/h4&gt;

&lt;p&gt;TED app has a really good design but the sign up and login interface can be improved and the search option should also be moved to the top bar instead of bottom right corner.&lt;/p&gt;

</description>
      <category>userstudy</category>
      <category>ui</category>
      <category>ux</category>
      <category>uidesign</category>
    </item>
    <item>
      <title>You don’t need jQuery</title>
      <dc:creator>Navneet Sahota</dc:creator>
      <pubDate>Mon, 18 Jun 2018 01:24:11 +0000</pubDate>
      <link>https://dev.to/navi/you-don-t-need-jquery-24m7</link>
      <guid>https://dev.to/navi/you-don-t-need-jquery-24m7</guid>
      <description>&lt;p&gt;I recently read this article &lt;a href="https://hackernoon.com/i-still-love-jquery-and-you-should-too-3114f33f249e"&gt;&lt;strong&gt;&lt;em&gt;I Still Love jQuery — And You Should, Too.&lt;/em&gt;&lt;/strong&gt;&lt;/a&gt; In all honesty, I was a bit surprised that there is someone who is willing to put a case for jQuery in this modern age of development.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--loX7ccAE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AqKyXecsGDFKV5Gbti-Inzw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--loX7ccAE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/800/1%2AqKyXecsGDFKV5Gbti-Inzw.jpeg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The author made a good case for jQuery but there were statements which are not accurate and some aspects of development have been ignored. Let’s look at some of his arguments in favor of jQuery.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;jQuery doesn’t make your site slow&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Well, the above statement is false. The author uses this statement but then acknowledges that jQuery does affect the loading time of the page, which is negligible in most cases. Actually, he is right but he fails to put the light in the cases when we need our site to accessible to everyone. In such events,our site may be used by someone with a bad internet connection, and that’s when you would wish your site size was as small as possible.&lt;/p&gt;

&lt;p&gt;Even if you use the min/slim version of jQuery, the size difference isn’t much and some features like animations and Ajax are removed in jQuery slim version.&lt;/p&gt;

&lt;p&gt;The author also mentions that using jQuery improves your typing speed. That’s true for most parts but there are a lot of cases when jQuery and Vanilla JavaScript both have almost similar lines of code. That’s when you should really consider that do you really want jQuery in your site.&lt;/p&gt;

&lt;p&gt;Here are some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Append using jQuery
$(parent).append(el);

// Append using Vanilla JS
parent.appendChild(el);

// Getting Children using jQuery
$(el).children();

// Getting Children using Vanilla JS
el.children

// Get HTML using jQuery
$(el).html();

// Get HTML using Vanilla JS
el.innerHTML
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Using jQuery is so redundant that there’s a website dedicated to showing the difference between jQuery and Vanilla JS code called &lt;a href="http://youmightnotneedjquery.com/"&gt;You Might Not Need jQuery&lt;/a&gt;. You can check this website for more examples like the above mentioned.&lt;/p&gt;

&lt;p&gt;Also, jQuery Selectors performance was overlooked in that article. Here is a site where you can check and compare jQuery Selector’s performance called &lt;a href="https://jsperf.com/dm-jquery-vs-vanilla-selectors"&gt;JSPERF&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Spoiler Alert: The Vanilla JS selector is faster than the jQuery counterpart every time.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dghk5LP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AuIG2P4s1Zlp0brMy_5boZQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dghk5LP1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn-images-1.medium.com/max/1024/1%2AuIG2P4s1Zlp0brMy_5boZQ.png" alt=""&gt;&lt;/a&gt;JSPERF’s Result of jQuery and Vanilla JS Selectors&lt;/p&gt;

&lt;p&gt;Lastly, one of the main feature of jQuery which is ajax() is not available in slim version and can be easily replaced by fetch method or external libraries like Axios.&lt;/p&gt;

&lt;p&gt;In the end, I would like to say that jQuery does add some features as discussed by the author in his &lt;a href="https://hackernoon.com/i-still-love-jquery-and-you-should-too-3114f33f249e"&gt;article&lt;/a&gt;. Also, using jQuery is a choice but there are better alternatives available. You’ll have to make some trade-offs and choose the option that serves your priorities.&lt;/p&gt;

</description>
      <category>jquery</category>
      <category>javascriptlibrary</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Why Functional Programming Matters</title>
      <dc:creator>Navneet Sahota</dc:creator>
      <pubDate>Sun, 10 Jun 2018 18:33:46 +0000</pubDate>
      <link>https://dev.to/navi/why-functional-programming-matters-2o95</link>
      <guid>https://dev.to/navi/why-functional-programming-matters-2o95</guid>
      <description>&lt;p&gt;At &lt;a href="https://pesto.tech" rel="noopener noreferrer"&gt;Pesto&lt;/a&gt;, we were recently taught two things: &lt;strong&gt;Programming Deliberately&lt;/strong&gt; and &lt;strong&gt;Functional Programming&lt;/strong&gt;. Programming Deliberately means knowing every bit of code that we are going to write.&lt;/p&gt;

&lt;p&gt;We have to do some homework, to help us clearly understand the concept of Programming Deliberately. We need to read an academic research paper from &lt;a href="https://paperswelove.org/" rel="noopener noreferrer"&gt;PapersWeLove.org&lt;/a&gt; and then write a Medium post about it.&lt;/p&gt;

&lt;p&gt;The paper I read is &lt;a href="https://github.com/papers-we-love/papers-we-love/blob/master/paradigms/functional_programming/why-functional-programming-matters.pdf" rel="noopener noreferrer"&gt;Why Functional Programming Matters&lt;/a&gt; by John Hughes and here’s what I learned from it.&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%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AWednDtXFV10wEWC-AdUUGg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F800%2F1%2AWednDtXFV10wEWC-AdUUGg.png"&gt;&lt;/a&gt;Evolution of Programming Paradigms&lt;/p&gt;

&lt;p&gt;Functional Programming is so called because the program consists entirely of functions. Even the main program is a function, which receives input as an argument and generates output as its result.&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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A709ugF12LLkYxvb839YNlg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A709ugF12LLkYxvb839YNlg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The key concept of Functional Programming is &lt;strong&gt;Modularity&lt;/strong&gt;. The program functions are always defined in terms of other functions which are further defined in terms of smaller functions.&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%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A-p4k90uesC5rHtjfBOovlQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1024%2F1%2A-p4k90uesC5rHtjfBOovlQ.png"&gt;&lt;/a&gt;Functional Flowchart&lt;/p&gt;

&lt;p&gt;Functional Programs contains no assignment statements and contains no side-effects. The functions have to be &lt;strong&gt;Pure functions&lt;/strong&gt; i.e. will produce same output every time when given the same set of inputs.&lt;/p&gt;

&lt;p&gt;Hughes summed up FP perfectly:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The functional programmer sounds rather like a medieval monk, denying himself the pleasures of life in the hope that it will make him virtuous. To those more interested in material benefits, these “advantages” are totally unconvincing.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;ul&gt;
&lt;li&gt;Small modules can be coded quickly and easily.&lt;/li&gt;
&lt;li&gt;General purpose modules can be reusable, which leads to faster development of next programs.&lt;/li&gt;
&lt;li&gt;The modules of a program can be tested independently, helping to reduce the time spent debugging.&lt;/li&gt;
&lt;li&gt;Functional programs are &lt;strong&gt;referentially transparent&lt;/strong&gt; i.e. if a variable is assigned a certain value in a program, then this value cannot be changed again.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;The ways in which one can divide up the original problem depend directly on the ways in which one can glue solutions together.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The two glues are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Higher-order Functions&lt;/li&gt;
&lt;li&gt;Lazy Evaluation&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A function is called &lt;strong&gt;Higher-order function&lt;/strong&gt; if it takes a function as an argument or returns a function as a result. Simple functions can be &lt;em&gt;glued&lt;/em&gt; together to form a complex one. Here’s an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;add x y = x + y
sum = reduce add 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here add is a function which takes two variables x and y as arguments and returns their sum. And reduce is the higher-order function which has add function as its argument and ‘0’ is the passed as the first argument to add function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Brackets are added just to make things clear

sum = reduce(add(0)) 
sum = reduce(add 0)

//Printing sum(5) will print the sum of 5 and 0 i.e. 5
//This is how it happens

\&amp;gt; sum(5) = reduce(add 0) 5
\&amp;gt; sum(5) = reduce(add 0 5)
\&amp;gt; sum(5) = 5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Lazy Evaluation&lt;/strong&gt; is also referred to as call-by-need evaluation strategy which delays the evaluation of an expression until it is needed and is also avoids repeated evaluation.&lt;/p&gt;

&lt;p&gt;Lazy evaluation can be also be achieved in imperative languages but will make things rather difficult. This can only be of use when our programs have high modularity.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Because lazy evaluation’s power depends on the programmer giving up any direct control over the order in which the parts of a program are executed, it would make programming with side effects rather difficult, because predicting in what order — or even whether — they might take place would require knowing a lot about the context in which they are embedded. Such global interdependence would defeat the very modularity that — in functional languages — lazy evaluation is designed to enhance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Modularity is the key of successful programming and to assist modular programming, language must provide good glue.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;If you want to dig a little deeper into the details, then feel free to read the&lt;/em&gt; &lt;a href="https://github.com/papers-we-love/papers-we-love/blob/master/paradigms/functional_programming/why-functional-programming-matters.pdf" rel="noopener noreferrer"&gt;&lt;em&gt;whole paper&lt;/em&gt;&lt;/a&gt; &lt;em&gt;yourself or check out other interesting papers on&lt;/em&gt; &lt;a href="https://paperswelove.org" rel="noopener noreferrer"&gt;&lt;em&gt;PapersWeLove.org&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>paperswelove</category>
      <category>functional</category>
      <category>programming</category>
      <category>researchpaper</category>
    </item>
  </channel>
</rss>
