<?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>Forem: Int_Shibin</title>
    <description>The latest articles on Forem by Int_Shibin (@shibinlal).</description>
    <link>https://forem.com/shibinlal</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%2F438669%2Fa307fb34-740b-4cd2-9bc7-17e3a2c2bd14.jpeg</url>
      <title>Forem: Int_Shibin</title>
      <link>https://forem.com/shibinlal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shibinlal"/>
    <language>en</language>
    <item>
      <title>Web rendering methodologies, a quick snap .</title>
      <dc:creator>Int_Shibin</dc:creator>
      <pubDate>Wed, 30 Jun 2021 14:28:27 +0000</pubDate>
      <link>https://forem.com/shibinlal/web-rendering-methodologies-a-quick-snap-210g</link>
      <guid>https://forem.com/shibinlal/web-rendering-methodologies-a-quick-snap-210g</guid>
      <description>&lt;p&gt;When it comes the performance tradeoffs in application development , rendering methodologies plays an important role.&lt;br&gt;
Generally we classify this as server side rendering and client side rendering but there is more to it. for a detailed study anyone can refer this link &lt;a href="https://developers.google.com/web/updates/2019/02/rendering-on-the-web"&gt;https://developers.google.com/web/updates/2019/02/rendering-on-the-web&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But in this article i am trying to share a quick introduction to three types of the rendering .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static rendering &lt;/li&gt;
&lt;li&gt;Server rendering&lt;/li&gt;
&lt;li&gt;Client side rendering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before getting into the subject let us check the performance time gaps which we can take for guaging the efficiency of a web application.&lt;/p&gt;

&lt;p&gt;TTFB (Time To First Byte) - time between clicking link and first bit of content coming in.&lt;/p&gt;

&lt;p&gt;FP (First Paint) - The first time any pixel becomes visible to the user.&lt;/p&gt;

&lt;p&gt;FCP (First Content Paint) - The time when requested content becomes visible.&lt;/p&gt;

&lt;p&gt;TTI (Time To Interactive) - The time at which a page becomes interactive.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0Ko_hT9H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bzjapsqmv2qnxtln2wq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0Ko_hT9H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8bzjapsqmv2qnxtln2wq.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Server rendering generally produces a first paint(FP) and first contentful paint(FCP) .Running page logic and rendering on the server makes it possible to avoid sending lots of javascript to the client. Which helps to achieve a fast TTI (Time To Interactive) .Primary drawback of SSR is that generating pages on server takes time, which can often result in slower Time To First Byte(TTFB).&lt;/p&gt;

&lt;p&gt;Static rendering happens at build time offers a fast First Paint, First Content Paint and Time To Interactive assuming the client side js is limited.&lt;br&gt;
Unlike server side rendering consistantly fast Time To First Byte since the HTML for a page doesnt have to be generated on the fly.&lt;/p&gt;

&lt;p&gt;one of the drawback of the static rendering is that it individual HTML files must be generated for every possible Url.&lt;/p&gt;

&lt;p&gt;Where as in client side rendering rendering pages directly in the browser using javascript. All logic , data fetching, templpating and routing are handled on the client rather than the server.&lt;br&gt;
The primary downside to client side rendering is that the amount of javascript required tends to grow as an application grows. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>html</category>
    </item>
    <item>
      <title>Is Node multithreaded?</title>
      <dc:creator>Int_Shibin</dc:creator>
      <pubDate>Sun, 13 Jun 2021 12:01:17 +0000</pubDate>
      <link>https://forem.com/shibinlal/is-node-multithreaded-3m3k</link>
      <guid>https://forem.com/shibinlal/is-node-multithreaded-3m3k</guid>
      <description>&lt;p&gt;As we all know that javascript is a scripting language used for building web application. Node introduced to leverage the capacity of javascript to make it as a scalable network language.&lt;/p&gt;

&lt;p&gt;As per official definition Node is an asynchronous event-driven JavaScript runtime. this is in contrast to thread based networking.&lt;/p&gt;

&lt;p&gt;First let us make a basic understanding of thread and process's. The basic instance of a computer program is called a process. within a single process we can have multiple things called threads , threads are kind of set of instructions that computer CPU needs to do and Scheduling is the ability of OS to decide which thread to process at anyinstance in time. Urgent threads should not be waited for too long. &lt;/p&gt;

&lt;p&gt;strategies use to increase the rate in which these threads are getting processed are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more CPU cores to the machine.&lt;/li&gt;
&lt;li&gt;More closely examine the work that being done by each thread.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now let us understand the design of node ecosystem&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hXrtLxYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfz5s9if2rmk47a48cpl.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hXrtLxYv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sfz5s9if2rmk47a48cpl.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Node js ecosystem consists of three entities node js interface, v8 library and libUV library. Here 70 % of v8 and 100% of libUV is written in c++. Node leveraging functions from both these libraries. libUV is an open source c++ project gives node access to underlying O.S , file system and networking. &lt;br&gt;
&lt;code&gt;Process.binding()&lt;/code&gt; connect js and c++ functions . V8 connects values between js and c++ worlds. &lt;/p&gt;

&lt;p&gt;Now we can come back to our thread discusisons. So  node uses a hybrid implimentation of threading system . Node event model is based on an event loop. Whenever we start a node function it will run inside a event loop , which is truly single threaded. Node js simply enters the event loop, after executing the input script. nodejs exits the event loop when there is no more callbacks to perform.&lt;/p&gt;

&lt;p&gt;For some expesive functions Node LibUV(c++) part decide to execute outside the single thread which is used for eventloop execution. For this execution we have a threadpool which is a series of four(by default and can be increase) threads that are used to execute computational intensified tasks&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gRN-z2uG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plzhlcmcygixdxmgz7z0.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gRN-z2uG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/plzhlcmcygixdxmgz7z0.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How thread pool fitting in node ecosystem ? , tasks running in the threadpool are consdered as the &lt;em&gt;pending operation&lt;/em&gt; , which is considered as one of the three kinds of events which happens in the event loop other 2 are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;pending timeout operations.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;pending OS tasks.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So in this way we can conclude that Node is truly single threaded but few heavy function executions are taking place in the multi threaded thread pool.&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
Node official document.&lt;br&gt;
Udemy Nodejs: advanced concepts.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>multithread</category>
    </item>
    <item>
      <title>React, under the hoods.</title>
      <dc:creator>Int_Shibin</dc:creator>
      <pubDate>Sun, 30 May 2021 06:54:58 +0000</pubDate>
      <link>https://forem.com/shibinlal/react-under-the-hoods-19hh</link>
      <guid>https://forem.com/shibinlal/react-under-the-hoods-19hh</guid>
      <description>&lt;p&gt;In this article i am going to discuss about the basic functionalities and operational flow involved in the react rendering process. like all other peer front end library/ frameworks the basic architecture behind React is also a data driven architecture. Where we receive data from back end render it in client side and form visible UI. the difference of front end frameworks lies in the execution way of this transformation. &lt;/p&gt;

&lt;p&gt;React doesn't update or work on the enitre DOM( Document Object Model) each and every time when there is a change in data/ state. instead in react it uses a sophisticated algorithm to reduce the cost of DOM operations is called Fiber algorithm(Reconcile). &lt;/p&gt;

&lt;p&gt;I try to unravel the algoritham and point out few functions so that anyone can start dig the react source code by having a brief understanding. &lt;/p&gt;

&lt;p&gt;Lets start with the render method , which is apparantly returns the so called 'virtual DOM' . Virtual DOM primarily consist of a tree of immutable react elements. There are diffenet kinds of react elements like class / functional components, hostcomponents, portals etc. Besides the tree of this react elements Framework creat a tree of internal instances which is called Fiber. &lt;/p&gt;

&lt;p&gt;React Fiber is getting created in reconciliation , during this execution every react elements returned from render method creates a corresponding Fiber node . Fibers are mutable datastructure that holds component data structure and DOM &lt;/p&gt;

&lt;p&gt;All the Fiber nodes are connected through a linked list. First time react element moved to fiber and for the subsequent updates react reuses the same Fiber. When react working on first time render/update there will be two trees current and WIP. Fiber node object have all the necessery details require for the work to perform on that node or connected nodes( Through effect list). few of the fields are alternateTag, effectList and stateNode rest of the fields you can explore in the source code .&lt;/p&gt;

&lt;p&gt;Reacts performs work in two phases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Render &lt;/li&gt;
&lt;li&gt;Commit&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Render refering the first time creation of the fiber and subsequent updations on the same fiber. &lt;br&gt;
result of this phase is the tree of fiber nodes marked with side effects. It can be asynchronous.&lt;/p&gt;

&lt;p&gt;In Commit phase React takes the fiber nodes which is marked with effects and appliens them to the instances . in this phase goes over the list and performs DOM update which is visible to the users , because of that it will always be synchronous. &lt;/p&gt;

&lt;p&gt;Main functions in Fiber node work loop( Where the nodes are getting processed) are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;performUnitOfWork.&lt;/li&gt;
&lt;li&gt;beginWork.&lt;/li&gt;
&lt;li&gt;completeUnitOfWork.&lt;/li&gt;
&lt;li&gt;completeWork.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;in the execution variable nextUnitOfWOrk holds a refernece to the node in WIP it checks for the next node , the performUnitOfWOrk which then fetch the node. once it got the node it starts the execution which always return next child in the process if available or null. if a next child available then assign the refernece to nextUnitOfWOrk variable. once the work finishes backtrack execution starts to fetch next branch or sibling. which is done by completeUnitOfWork.&lt;/p&gt;

&lt;p&gt;Refernce:&lt;br&gt;
&lt;a href="https://indepth.dev/posts/1008/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react"&gt;https://indepth.dev/posts/1008/inside-fiber-in-depth-overview-of-the-new-reconciliation-algorithm-in-react&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>reactnative</category>
      <category>javascript</category>
      <category>reconcile</category>
    </item>
    <item>
      <title>Linked list in javasript</title>
      <dc:creator>Int_Shibin</dc:creator>
      <pubDate>Thu, 06 Aug 2020 10:25:46 +0000</pubDate>
      <link>https://forem.com/shibinlal/linked-list-in-javasript-3il5</link>
      <guid>https://forem.com/shibinlal/linked-list-in-javasript-3il5</guid>
      <description>&lt;p&gt;Linked list as an integral part of software engineering learning has a huge impact on every engineers career. It is important to have a deep understanding of various datastructures and their ability to solve different types of problems. &lt;br&gt;
Linkedlist is a linear datastructure in which each element is a seperate object. unlike array linked list is dynamic datastructure, meaning the memory allocated has flexibility to grow or shrink. Developer has the power to do that.&lt;br&gt;
Linked list diffrentiated into two &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SinglyLinkedList- which has only next property in node.&lt;/li&gt;
&lt;li&gt;DoublyLinkedList- which has both next and prev property in it's node class, &amp;gt;dll is more flexible when it comes to the reverse traversal.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article we are going to use singlyLinkedList. Okey then let's dive into the concepts and implimentations.&lt;/p&gt;

&lt;p&gt;Let us call each linked list element as node , each node has a data and a reference to next node .Last node has a reference to null.&lt;/p&gt;

&lt;p&gt;A node 'll look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Node{
  constructor(data){
    this.data = data;
    this.next = null
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To define a linked list another class need to create&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class LinkedList{
  constructor(){
    this.head = null;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;and a method &lt;code&gt;addEl&lt;/code&gt; for making a connected links of these nodes. in this method we have two conditions, one to add element in empty linked list another to add element to existing linked list which has nodes.&lt;br&gt;
In the later condition we need to traverse through the linked list till the last element to add a new node with a data&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;addEl(data){
    let newNode = new Node(data),current;
    if(!this.head){
      this.head = newNode;
    }else{
      current = this.head;
      while(current.next){
        current = current.next
      }
      current.next = newNode;
      newNode = current
    }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;For traversing linkedlist need to set a pivot/current node, for moving forward or backward we need to replace the current node.&lt;/p&gt;

&lt;p&gt;Let us move on to delete operation now&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deleteEl(data) {
    if (this.head == null) {
      return false;
    } else {
      let current, temp;
      current = this.head;
      if (current.data == data) {
        this.head = current.next;
      } else {
        while (current.next.data != data) {
          current = current.next;
        }
        temp = current.next;
        current.next = temp.next;
      }
      this.size--;
    }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;here if data passed is valid then we have to again traverse through the linkedlist to fetch the node unless we have the data available in the head itself.Once we find out the data we need to rearrange the chain by linking previous node and next node of the deleted node.&lt;/p&gt;

&lt;p&gt;Finally we can analyse reverse operation in linked list&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reverseLinkedList() {
    let nodes = [],
      current,
      node;
    current = this.head;
    while (current) {
      nodes.push(current);
      current = current.next;
    }
    let revLl = new LinkedList();
    revLl.head = nodes.pop();
    current = revLl.head;
    node = nodes.pop();
    while (node) {
      node.next = null;
      current.next = node;
      current = current.next;
      revLl.size++;
      node = nodes.pop();
    }
    return revLl;
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;First thing we need to initialise a diffrent linkedlist and required to add elements in reverse order, for doing that i created a stack and added all my nodes to it and retreive one by one and added to the new linkedlist.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>linkedlist</category>
      <category>datastructure</category>
      <category>interview</category>
    </item>
    <item>
      <title>Two major polyfill interview question's every js developer face.</title>
      <dc:creator>Int_Shibin</dc:creator>
      <pubDate>Thu, 30 Jul 2020 06:00:11 +0000</pubDate>
      <link>https://forem.com/shibinlal/two-major-polyfill-interview-question-s-every-js-developer-face-5d7o</link>
      <guid>https://forem.com/shibinlal/two-major-polyfill-interview-question-s-every-js-developer-face-5d7o</guid>
      <description>&lt;p&gt;Js interviews are pretty much tricky in nature. Since js realm consist of myriad libraries and frameworks it demands a huge time for brief preperation itself. But many companies focus only on your core domain and technical understanding, here comes the importance of fundamentals. &lt;br&gt;
           Two importance areas companies evaluate are design patterns and your ability to write robust and reusable code.&lt;br&gt;
           That is the primary reason most of the interviewer 've this question in their bag. Here i try to explain two commonly asked polyfill questions.One is bind and another one is reduce&lt;/p&gt;

&lt;p&gt;Let's start with bind. Bind method enable us to call a function with different context.Bind primarily return a new function which has context provided as first argument and parameters as second.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function.prototype.customBind=function(...args){
  let params = args.slice(1);
  let tempObj= {
    fn:this,
    ...args[0]
  }
    return ()=&amp;gt;tempObj.fn(...params);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The catch here is the &lt;code&gt;this&lt;/code&gt; value of our customBind , since it is getting called on another function we 'll receive a function as &lt;code&gt;this&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const obj={
  name:"Adam"
}
function show(age){
  console.log(this.name,age)
}
let outFn = show.customBind(obj,29);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Considering above code snippet , we 'll receive function show as &lt;code&gt;this&lt;/code&gt; value inside cutomBind.&lt;/p&gt;

&lt;p&gt;Reduce is another one ,find my custom reduce function here&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Array.prototype.customReduce = function(fn,acc){
  let contextArr = this;
  for(let i=0;i&amp;lt;contextArr.length;i++){
    acc = acc!==undefined?fn(acc,contextArr[i]):contextArr[0];
  }
  return acc
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here reduce method has two parameters 1. function 2. accumulator  later one is optional. In this case we need to add this function to Array prototype since it is an array function , thus value of &lt;code&gt;this&lt;/code&gt; become the provided array upon which we called the reduce method. we can then iterate over the array and make an accumulated value by running the function provided.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>interview</category>
      <category>polyfill</category>
      <category>reduce</category>
    </item>
  </channel>
</rss>
