<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nitesh Chowdhary on Medium]]></title>
        <description><![CDATA[Stories by Nitesh Chowdhary on Medium]]></description>
        <link>https://medium.com/@nitesh.chowdhary?source=rss-1d7017e0eec8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*y7UW8OW34UNf4xY0</url>
            <title>Stories by Nitesh Chowdhary on Medium</title>
            <link>https://medium.com/@nitesh.chowdhary?source=rss-1d7017e0eec8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 23:00:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nitesh.chowdhary/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Understanding React Native legacy Architecture]]></title>
            <link>https://medium.com/@nitesh.chowdhary/understanding-react-native-legacy-architecture-ccb87c63f2a5?source=rss-1d7017e0eec8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccb87c63f2a5</guid>
            <category><![CDATA[react-native-architecture]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native-bridge]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Nitesh Chowdhary]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 08:27:06 GMT</pubDate>
            <atom:updated>2026-02-24T08:27:06.657Z</atom:updated>
            <content:encoded><![CDATA[<p>Terms to know before we start —</p><blockquote><strong><em>Threads </em></strong>— Threads are workers which executes small chunks of program allowing multiple task to run at the same time.</blockquote><blockquote><strong><em>JS Thread</em></strong><em> </em>— Javascript (JS) thread is where all JS code runs.</blockquote><blockquote>This includes — hooks, business logic, state management, event handling.</blockquote><blockquote>JSX is compiled into JavaScript, so it also runs on the JS thread.</blockquote><blockquote><strong><em>Shadow thread</em></strong><em> </em>— Shadow thread is responsible for calculating the layout of the UI. This includes (position, size, layout structure etc).</blockquote><blockquote><strong><em>Main/UI thread</em></strong><em> </em>— Main thread is responsible for rendering / updating the UI. It draws UI component on the screen, handles user interaction like touch, scroll, gestures and updates the UI accordingly.</blockquote><blockquote><strong><em>Native code</em></strong> — Native code refers to the module written in platform-specific language. Example</blockquote><blockquote>Android — language (kotlin or Java) and for UI (xml or compose).</blockquote><blockquote>IOS — language (swift or objective c) and for UI (UI kit or swift UI).</blockquote><blockquote><strong><em>Shadow Tree — </em></strong>A native layout tree used for calculation of the position of the UI.</blockquote><blockquote><strong><em>Yoga Engine — </em></strong>Yoga engine calculates the layout for the UI.</blockquote><blockquote><strong><em>Batching </em></strong>— Combining multiple messages.</blockquote><p>Let’s start with a simple and concise explanation</p><p>Let’s imagine:</p><ul><li>There is a person named <strong>John</strong> who speaks only Spanish.</li><li>There is another person named <strong>Paul</strong> who speaks only English.</li></ul><p>If John and Paul want to communicate, they cannot talk directly because they don’t understand each other’s language.</p><p>So, they need a <strong>translator</strong> — someone who understands both Spanish and English.</p><p>Here’s what happens:</p><ol><li>John speaks in Spanish.</li><li>The translator listens and understands.</li><li>The translator converts it into English.</li><li>The translator conveys the message to Paul in English.</li></ol><p>Communication becomes possible because of the translator.</p><p>Simple, right? Let’s see</p><h3>How This Relates to React Native</h3><p>In React Native’s legacy architecture:</p><ul><li><strong>John</strong> represents the <strong>JavaScript code</strong>.</li><li><strong>Paul</strong> represents the <strong>Native code</strong> (Android/iOS).</li><li>The <strong>translator</strong> represents the <strong>Bridge</strong>.</li></ul><p>JavaScript and Native code cannot communicate directly.<br>They send messages through the Bridge, which translates data between JS and native side.</p><p>This same flow happens internally in React Native’s old architecture.</p><pre>JS &lt;------ Bridge ------&gt; Native</pre><h3>Deep Dive</h3><p>let’s take a piece of code as example —</p><pre>const UI = () =&gt; {<br>  return (<br>      &lt;Text&gt;Nitesh&lt;/Text&gt;<br>  )<br>}</pre><p>As the above code starts to execute</p><ol><li><strong>JS thread (Brain) —</strong></li></ol><p>JS thread will run the js code which includes bussiness logic, api calls, state management, state update, jsx etc but what JS cannot do is, it cannot draw UI. So, js thread sends instruction to bridge.</p><p>2.<strong> Bridge (Translator / Messenger) —</strong></p><p>Bridge will</p><ul><li><strong>serializes </strong>messages into JSON.</li><li><strong>batches </strong>them</li><li>send to native</li><li>native deserializes</li></ul><p>Example —</p><p>Instead of creating UI, JS sends :</p><pre>{<br>  &quot;type&quot;: &quot;createView&quot;,<br>  &quot;view&quot;: &quot;Text&quot;,<br>  &quot;props&quot;: { &quot;text&quot;: &quot;Hello&quot; }<br>}</pre><p>Bridge delivers to native.</p><p>3. <strong>Shadow Thread —</strong></p><p>Native parts starts here.</p><p>Shadow thread creates layout using yoga engine.<br>It calculates position, heigh, width, layout etc and it will create a shadow tree.</p><p>4. <strong>Main/UI Thread (Painter) —</strong></p><p>UI thread create native views for android and ios. UI thread is responsible for creating button, text, images etc. This thread is responsible to draw pixels in the screen.</p><p><strong>Summary</strong></p><pre>JS Thread<br>   ↓<br>Bridge  (messages only, no UI)<br>   ↓<br>Shadow Thread (layout only)<br>   ↓<br>UI Thread (draw only)<br>   ↓<br>Screen</pre><p>I hope it helps you to understand the old architecture in react native.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccb87c63f2a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding call, apply, and bind in JavaScript]]></title>
            <link>https://medium.com/@nitesh.chowdhary/understanding-call-apply-and-bind-in-javascript-e084bce9f7f6?source=rss-1d7017e0eec8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e084bce9f7f6</guid>
            <category><![CDATA[apply]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bind]]></category>
            <category><![CDATA[call]]></category>
            <dc:creator><![CDATA[Nitesh Chowdhary]]></dc:creator>
            <pubDate>Mon, 09 Feb 2026 11:26:00 GMT</pubDate>
            <atom:updated>2026-02-09T11:26:00.776Z</atom:updated>
            <content:encoded><![CDATA[<h3>Terms to know</h3><blockquote><strong>Method</strong>: A function associated with a class or object.</blockquote><h3>What is call?</h3><p>call is a method that lets you call a function with a <strong>desired </strong><strong>this value</strong>.</p><ul><li>Because it is associated with the <strong>Function class</strong> in JavaScript so it called a method.</li></ul><p>Let’s understand it by an example:</p><pre>const person = {<br>  name: &quot;Nitesh&quot;,<br>  myName: function() {<br>      console.log(this.name);<br>  }<br>}</pre><p>Here, person has a name and a method myName. If we call person.myName(), it prints &quot;Nitesh&quot;.</p><pre>// Case 1<br>person.myName(); // Nitesh<br><br>// Case 2<br>const { myName } = person;<br>myName(); // undefined</pre><ul><li>In <strong>case 1</strong>, the output is &quot;Nitesh&quot; because myName is called on person.</li><li>In <strong>case 2</strong>, the output is undefined because myName is no longer attached to person, so this is undefined.</li></ul><h3>Using call to fix this</h3><pre>myName.call(person); // Nitesh</pre><ul><li>We pass the object we want as this to the function.</li><li>Useful if we want to <strong>reuse methods across different objects</strong>:</li></ul><pre>const animal = { name: &quot;Tiger&quot; };<br>myName.call(animal); // Tiger</pre><ul><li>You can also pass arguments after the object:</li></ul><pre>const person = {<br>  name: &quot;Nitesh&quot;,<br>  myName: function(greeting) {<br>      console.log(greeting, this.name);<br>  }<br>};<br><br>myName.call(animal, &quot;Hi&quot;); // Hi Tiger</pre><ul><li>If you have <strong>multiple arguments</strong>, just pass them one by one.</li></ul><h3>Using apply to pass arguments as an array</h3><p>apply is almost identical to call, but it takes the arguments as an <strong>array</strong>:</p><pre>const person = {<br>  name: &quot;Nitesh&quot;,<br>  myName: function(greeting, punctuation) {<br>      console.log(greeting, this.name + punctuation);<br>  }<br>};<br><br>const animal = { name: &quot;Tiger&quot; };<br>// Using call<br>person.myName.call(animal, &quot;Hello&quot;, &quot;!&quot;); // Hello Tiger!<br>// Using apply<br>person.myName.apply(animal, [&quot;Hello&quot;, &quot;!&quot;]); // Hello Tiger!</pre><ul><li><strong>call → comma-separated arguments</strong></li><li><strong>apply → array of arguments</strong></li></ul><h3>Using bind to create a new function</h3><p>bind is similar to call, but <strong>it does not call the function immediately</strong>. Instead, it returns a <strong>new function with </strong><strong>this bound</strong> to the object you provide:</p><pre>const person = {<br>  name: &quot;Nitesh&quot;,<br>  myName: function(greeting) {<br>      console.log(greeting, this.name);<br>  }<br>};</pre><pre>const animal = { name: &quot;Tiger&quot; };</pre><pre>const printAnimalName = person.myName.bind(animal);</pre><pre>printAnimalName(&quot;Hey&quot;); // Hey Tiger</pre><ul><li>Useful for <strong>event handlers</strong> or <strong>callbacks</strong>, where this may otherwise change.</li><li>You can also preset arguments when using bind:</li></ul><pre>const greetTiger = person.myName.bind(animal, &quot;Hello&quot;);<br>greetTiger(); // Hello Tiger</pre><h3>Benefits</h3><ul><li><strong>Reuse methods across objects</strong> → avoids repeating code.</li><li><strong>Control the value of </strong><strong>this</strong> explicitly.</li><li><strong>Pass arguments flexibly</strong> (individual or as an array).</li><li><strong>Create bound functions</strong> for callbacks or events.</li></ul><h3>Conclusion</h3><p>call, apply, and bind are powerful tools in JavaScript that help you <strong>reuse functions</strong>, <strong>control </strong><strong>this</strong>, and <strong>write cleaner code</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e084bce9f7f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How JAVASCRIPT runs under the hood?]]></title>
            <link>https://medium.com/@nitesh.chowdhary/how-javascript-runs-under-the-hood-991e81284d91?source=rss-1d7017e0eec8------2</link>
            <guid isPermaLink="false">https://medium.com/p/991e81284d91</guid>
            <category><![CDATA[runtime]]></category>
            <category><![CDATA[v8-engine]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bytecode]]></category>
            <dc:creator><![CDATA[Nitesh Chowdhary]]></dc:creator>
            <pubDate>Sat, 11 Oct 2025 06:20:47 GMT</pubDate>
            <atom:updated>2025-10-13T05:17:38.382Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s understand few terms that I will use along the article:</p><blockquote><strong>V8 engine — </strong><em>the engine used by browser or node to execute JS code.</em></blockquote><blockquote><strong>V8 ignition</strong> — an interpreter in v8 engine.</blockquote><blockquote><strong>Turbofan</strong> — V8 optimizing compiler(converts byte-code to machine code).</blockquote><blockquote><strong>Runtime — </strong>a period when a piece of code is executed by machine or virtual machine.</blockquote><blockquote><strong>Bytecode — </strong>an intermediate low level language between high level code and machine code. Byte-code is a engine level instruction that v8 can easily understand.</blockquote><blockquote><strong>Interpreted language — </strong>a language in which piece of code runs line by line at runtime(JS is one among them).</blockquote><pre>function add (a, b){<br>  return a + b;<br>}</pre><p>I will use this code block as an example</p><p>once we start to run JS code —</p><ol><li><strong>Parsing — </strong><em>V8 parses it into AST(Abstract Syntax Tree).</em></li></ol><pre>Function declaration (add) <br>  |-- Parameter (a)<br>  |-- Parameter (b)<br>  |__ Return Statement <br>          |__ Binary Expression (+)</pre><p>2. <strong>Interpreter —</strong> AST is converted into byte-code using V8 ignition.</p><pre>Lda a<br>Add b<br>Return</pre><p>At this stage v8 may start to execute code without any delay, even before generating optimized machine code.</p><p><strong>3. Profiling </strong>— As the program runs, v8 monitors which code block is run frequently, if any piece of code crosses a threshold, it is marked as hot code and scheduled for optimization.</p><p>For instance, let suppose that threshold is 10(actual number varies by engine) and if the <strong>add(a, b)</strong> function is called more than 10 times V8 will mark it as hot code and decides to optimize the add function.</p><p><strong>4. Optimization</strong> — All code block marked as hot code is passed to turbofan.</p><ul><li><strong>Turbofan</strong> : Analyzes type info(a, b are usually number). Generates optimize code based on your CPU architecture(x86, ARM, etc).</li></ul><p>Once turbofan generated the machine code, CPU executes it directly through it’s instruction cycle(fetch -&gt; decode -&gt; execute).</p><ul><li>fetch is like reading the line.</li><li>decode is like understanding the meaning of it.</li><li>execute is to perform the action and go to the next line.</li></ul><p><strong>5. De-optimization</strong> — if the type of param changes, for example the type of a changes from number to string(type stability matters), v8 realized it’s assumption was wrong. It discards the compiled code and falls back to interpreter(This operation is very expensive) .</p><p>Key points:-</p><ul><li>Hot code is the reason why we should write DRY code.</li><li>Hot code is the reason for c++, java or static languages to be much faster than dynamic languages.</li></ul><p>I hope this articles adds value to your knowledge😊.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=991e81284d91" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>