<?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 Bhuvan Gandhi on Medium]]></title>
        <description><![CDATA[Stories by Bhuvan Gandhi on Medium]]></description>
        <link>https://medium.com/@bhuvan.gandhi?source=rss-5ec765c58c15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZZKhyPmxu2MVRsdY-8_IJA.jpeg</url>
            <title>Stories by Bhuvan Gandhi on Medium</title>
            <link>https://medium.com/@bhuvan.gandhi?source=rss-5ec765c58c15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:23:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhuvan.gandhi/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[Mastering Concurrency in Golang — The Art of Using Goroutines]]></title>
            <link>https://medium.com/@bhuvan.gandhi/mastering-concurrency-in-golang-12aea76b7034?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/12aea76b7034</guid>
            <category><![CDATA[gopher]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 05:09:51 GMT</pubDate>
            <atom:updated>2025-03-26T05:09:51.928Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering Concurrency in Golang — The Art of Using Goroutines</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*zmMEPE0yF6usEEv66H9ehA.png" /></figure><p>Concurrency has been an important part of Computer Science, and often one of the trickiest to learn. But then came Golang, with built-in support for concurrency that made working with it surprisingly simple.</p><p>In this blog, we will break down this complex topic in the most flavorful way possible — by cooking a delicious pasta recipe. Along the way, we will understand how Goroutines and Channels work together to make Go’s concurrency model powerful and elegant.</p><h4>Table of Contents</h4><ol><li>Basics — What is Concurrency?</li><li>Concurrency in Golang</li><li>Cooking with Goroutines, Channels, and Select</li><li>The Magic Behind Goroutines and Channels</li><li>Golang in Action</li><li>Conclusion</li></ol><h3>Basics — What is Concurrency?</h3><blockquote>Concurrency refers to the ability of a system to execute multiple tasks through simultaneous execution or time-sharing (context switching), sharing resources and managing interactions.</blockquote><blockquote>- Wikipedia</blockquote><p>In simpler words, <strong>the art of “dealing” with multiple things at once</strong>. Imagine you’re in the kitchen, cooking delicious Pasta for dinner. Now think of yourself as a single-core computer processor and the tasks that you will be doing — boiling water, chopping veggies, etc., as the processes that will be executed by the processor.</p><p>Being a single entity, you can’t do everything at once. Hence, you will switch between your tasks. First, you start boiling water, and then instead of standing idle till the water boils, you will start chopping veggies. The same thing happens with the computer processor. Just like you, it can execute only one process at any given point. So when a process is waiting i.e. I/O operation, the processor takes another process to execute. This efficient task-switching is what we call Concurrency.</p><h3>Concurrency in Golang</h3><p>Unlike other modern languages where threads and locks or async/await mechanisms have been used, working with concurrency in Golang is not only efficient but also straightforward.</p><p>Golang has three pillars that make it possible to handle concurrency smoothly — Goroutine, Channel, and the Select statement.</p><p><strong>Goroutine</strong> — Lightweight threads managed by the Go runtime.</p><p><strong>Channel</strong> — A medium for Goroutines to communicate.</p><p><strong>Select</strong> — Allows Goroutines to wait on multiple channels simultaneously and simplifies concurrency by handling multiple tasks.</p><h3>Cooking with Goroutine, Channel, and Select</h3><p>Let’s get back to our Pasta analogy. Consider Goroutines are the tasks you will perform, your Channels are your senses (sight, hearing, etc.), and your brain is the Select statement that helps to manage and prioritize tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*Vb5j-G8Kx3v7kqIfKrsNfg.png" /></figure><h4><strong>Goroutines / Starting the Tasks</strong></h4><p>Your first task is to start boiling water, so you launch a Goroutine for that. Simultaneously, you launch another Goroutine to chop veggies. Now both tasks are running concurrently — while you are chopping, your water is getting boiled. <strong>So instead of waiting idly for one task to finish, you continued doing the second one</strong>.</p><h4><strong>Channels / Sensing</strong></h4><p>While chopping, your senses (Channels) will keep you notified. Your sight sense tells you that the water has started boiling, and you hear the sound of the water bubbling. These senses communicate the status of each task and send the information to your brain to help you decide on the next step. <strong>The channels in Golang serve the same purpose — Communication</strong>.</p><h4>Select / Making a Decision</h4><p>Your brain picks up from the senses and makes decisions based on the information available. When your senses tell you that the water is boiling, your brain switches tasks — It tells you to stop chopping the veggies and move the pasta into the boiling water.</p><p>And once the pasta is in the pot, your brain switches focus back to chopping. Later, when your senses indicate that the pasta is done, your brain pauses chopping again and instructs you to remove the pasta from the pot.</p><h4>Concurrency / Efficient Management</h4><p>Even though you are handling multiple tasks, you’re not waiting idly for one to finish. <strong>The </strong><strong>select statement efficiently manages the tasks, continuously switching between them based on what’s ready</strong>. This ensures that you are always progressing, without unnecessary idle time.</p><h3>The Magic Behind Goroutines and Channels</h3><p>Diving into the technical aspect, let’s break down the key concepts that make Golang lightweight, simple, and yet highly efficient.</p><h4>Goroutine — The Lightweight Thread</h4><p>Managed by the Go runtime. It gets initialized with just 2 KB size, whereas OS threads typically occupy around 1 MB. This lightweight nature allows the Go runtime to schedule Goroutines dynamically, allowing millions of them to run concurrently with minimal overhead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*ADK3_OGFA0QtPZHDCr8IzQ.png" /></figure><p><strong>Go Scheduler, a part of the Go runtime, manages the execution of Goroutines by multiplexing M Goroutines onto N OS threads</strong>. Instead of blocking an OS thread when a Goroutine is waiting, the Go runtime parks that Goroutine and assigns another ready Goroutine to the thread. This boosts CPU utilization by minimizing context switching.</p><h4>Channel — The Communication Pipeline</h4><p>Provides a safe way to exchange data while ensuring communication without requiring explicit locks.</p><p>There are two types of Channels — <strong>Unbuffered and Buffered.</strong></p><h4>Unbuffered Channels</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Tcy9vfyMK9d0UlyewULZCg.png" /></figure><p>Used for <strong>synchronous communication </strong>between Goroutines. Here, sending and receiving happen simultaneously. <strong>The sender blocks until a receiver is ready to consume</strong> the message, which ensures the direct synchronization between Goroutines.</p><h4>Buffered Channels</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*g87Q9sR71kgTU5zV1pADyg.png" /></figure><p>Used for <strong>asynchronous communication</strong>. It allows the sender to continue execution without an immediate receiver, up to a defined capacity. The messages are stored in the buffer, allowing the receiver to consume them when needed. The <strong>sender only blocks when the buffer is full</strong>, and the <strong>receiver only blocks when the buffer is empty</strong>.</p><h4>Select — The Decision Maker</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*zCYa0y7z9spY09wWO4LxXw.png" /></figure><p>Allows a Goroutine to <strong>listen on multiple channels and handle whichever one is ready first</strong>. However, the selection is random if multiple channels are ready at the same time. And if no channels are ready, then the default case will be executed if available. This enables efficient handling of multiple concurrent operations.</p><h3>Golang in Action</h3><p>Now that we have explored Goroutines and Channels, let’s see them step-by-step in action using our Pasta analogy! The full code is available <a href="https://gist.github.com/bmg02/14630101e3671c800754e6dcaab2b196">here</a>.</p><h4>1. Boiling Water and Chopping Veggies</h4><pre>func boilWater(waterChan chan string) {<br>    fmt.Println(&quot;🔥 Boiling water...&quot;)<br>    time.Sleep(3 * time.Second)<br>    waterChan &lt;- &quot;Water is boiled.&quot;<br>}<br><br>func chopVeggies(veggiesChan chan string) {<br>    fmt.Println(&quot;🔪 Chopping vegetables...&quot;)<br>    time.Sleep(5 * time.Second)<br>    veggiesChan &lt;- &quot;Veggies are chopped.&quot;<br>}</pre><h4>2. Moving Pasta to Water (Only After Boiling)</h4><pre>func movePastaToWater(<br> waterChan chan string,<br> pastaChan chan string,<br>) {<br>    msg := &lt;-waterChan // Wait for boiling water to get ready<br>    fmt.Println(&quot;🍜&quot;, msg, &quot;Adding pasta to water...&quot;)<br>    time.Sleep(4 * time.Second)<br>    pastaChan &lt;- &quot;Pasta is cooked.&quot;<br>}</pre><h4>3. Cooking Pasta with Sauce (Waits for Both Pasta and Veggies)</h4><pre>func cookPasta(<br> pastaChan chan string,<br> veggiesChan chan string,<br> readyChan chan string,<br>) {<br>    pastaReady := false<br>    veggiesReady := false<br> <br>    // Wait for both to be ready<br>    for !pastaReady || !veggiesReady {<br>        select {<br>        case msg := &lt;- pastaChan:<br>            fmt.Println(&quot;✅&quot;, msg)<br>            pastaReady = true<br>        case msg := &lt;- veggiesChan:<br>            fmt.Println(&quot;✅&quot;, msg)<br>            veggiesReady = true<br>        }<br>    }<br><br>    fmt.Println(&quot;🍲 Cooking pasta with sauce using veggies and pasta...&quot;)<br>    time.Sleep(3 * time.Second)<br>    readyChan &lt;- &quot;Pasta is ready to eat!&quot;<br>}</pre><h4>4. Running the Program (Main Function)</h4><pre>func main() {<br>    waterChan := make(chan string)<br>    veggiesChan := make(chan string)<br>    pastaChan := make(chan string)<br>    readyChan := make(chan string)<br><br>    go boilWater(waterChan)<br>    go chopVeggies(veggiesChan)<br>    go movePastaToWater(waterChan, pastaChan)<br>    go cookPasta(pastaChan, veggiesChan, readyChan)<br><br>    msg := &lt;- readyChan<br>    fmt.Println(&quot;✅&quot;, msg)<br>}</pre><h4>Output — No waiting around unnecessarily</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*3L6DZEICbqUs5mxvvvNf1A.gif" /></figure><p>Of course, making pasta in real life surely takes more than just a few seconds, but I was in a bit of a hurry here, haha!</p><h4>Why loop with a Select statement?</h4><p>In Go, as the select statement allows a Goroutine to wait on multiple channel operations, the select statement picks the first one that’s ready. But if we want to continue checking multiple channels until all the required tasks are completed (like both pasta and veggies being ready), a loop is required.</p><h3>Conclusion</h3><p>Goroutine allows tasks to run concurrently, while Channels enable safe communication between them. This model simplifies concurrency management compared to traditional threading approaches.</p><p>While the pasta analogy was quick, Go’s concurrency model makes it ideal for building scalable and high-performance applications in real-world scenarios.</p><p>I hope you enjoyed reading this! For more interesting articles, connect with me on <a href="https://www.linkedin.com/in/bmgandhi/">LinkedIn</a> and <a href="https://medium.com/@bhuvan.gandhi">Medium</a>. Feel free to visit my portfolio website to learn more about my journey.</p><p>Cheers!</p><p><a href="https://bmgandhi.me/">Bhuvan Gandhi | A full-stack engineer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12aea76b7034" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generators in action — The most underrated feature of JavaScript ES6]]></title>
            <link>https://medium.com/@bhuvan.gandhi/generators-in-action-the-most-underrated-feature-of-javascript-es6-57ee972e9578?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/57ee972e9578</guid>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 06:45:11 GMT</pubDate>
            <atom:updated>2024-01-18T06:45:11.696Z</atom:updated>
            <content:encoded><![CDATA[<h3>Generators in action — The most underrated feature of JavaScript ES6</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*WuIw8WZvJCq3Rfrv9Zkt2Q.jpeg" /></figure><p>Generators was introduced in 2015 with the JavaScript ES6. Many of us might not have heard about it. Last year I encountered some weird “pointer” type syntax in JavaScript with a function while working with Redux-Saga. I got curious to know what the heck it is.</p><h3>What is a Generator</h3><p>A generator is a subclass of the Iterator class that returns an <em>iterable</em> object. It returns value on demand. In other words, <strong>it iterates and returns the value and waits for the caller to get iterated again from the point where it left the execution</strong>. It is also referred to as <em>Lazy Iterators</em> due to its execution nature.</p><p><strong>The generator function gets executed till it encounters the nearest yield statement. </strong>To continue the execution from where it left off, we use <strong>next()</strong> method from the caller.</p><h4>Syntax and return statement</h4><p>We write the generator function just like the normal function but with an asterisk after the keyword — <strong>function*</strong>. It returns two properties in the object — <strong>value</strong> with the processed value by the function and <strong>done</strong> with true/false value to indicate if there is further execution available or not.</p><p>Two methods that are useful to control the execution flow:</p><ul><li><strong>next()</strong> — It starts execution from where it left from the function</li><li><strong>return()</strong> — It forcefully returns from the function despite it has further yield operations</li><li><strong>throw()</strong> — It is used to throw an error inside the generator from outside</li></ul><h3>The execution</h3><p>Let’s consider the simplest code to understand the execution cycle of a generator function.</p><pre>function* generator() {<br>    yield 1;<br>    yield 2;<br>    return 3;<br>}<br><br>const a = generator();<br>console.log(a.next());<br>console.log(a.next());<br>console.log(a.next());</pre><pre>&gt; 1<br>&gt; 2<br>&gt; 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*gWQFi0Jur9s05KxiTqz-fQ.jpeg" /><figcaption>.</figcaption></figure><ol><li>We assign a function object to a variable to use it later</li><li><strong>next()</strong> method of the generator function is called to execute the generator function</li><li>The generator function gets executed till the <strong>nearest </strong><strong>yield statement</strong></li><li>Execution control gets back to the caller with the yielded value and <strong>done: false</strong> value as the generator function was not completed yet</li><li>Caller continues to execute further instruction <strong>till it encounters the </strong><strong>next() method</strong></li><li>Upon calling the <strong>next()</strong> method, the execution gets transferred back again to the generator function and it <strong>continues to execute from where it left earlier</strong></li><li>The execution gets transferred again to the point from where it gets called with a another value and false in the <strong>done</strong> property</li><li>The caller continues to execute the next instructions till it finds another <strong>next()</strong> method</li><li>The execution goes back to the generator function and it continues execution from where it left</li><li>On encounter of a return statement, the <strong>generator function returns the value with the </strong><strong>done: true</strong> <strong>flag</strong> to indicate that the execution of the generator function is completed</li></ol><h4>Using loop</h4><p>Instead of calling the <strong>next()</strong> method manually multiple times, we can use loop iterate through all the results returned by the generator function since it is nothing but an instance of the Iterator class.</p><pre>function* generator() {<br>    yield 1;<br>    yield 2;<br>    return 3;<br>}<br><br>for(let i of generator()) {<br>    console.log(i);<br>}</pre><pre>&gt; 1<br>&gt; 2</pre><p>You must be wondering where is 3, right? Well, while using the generator function in the loop, the <strong>termination condition is the return statement of a generator function</strong>. So, while encountering <strong>done: true</strong> from the generator function, it will come out of the loop without printing the value.</p><h3>Generators in action</h3><h4>To animate text</h4><p>Let’s implement simple typing animation on screen using the <strong>setInterval()</strong> method.</p><pre>function* typeChar(str) {<br>    for (let c of str) {<br>        yield c;<br>    }<br>}<br><br>function typeWithAnimation(str) {<br>    const a = typeChar(str);<br>    const interval = setInterval(() =&gt; {<br>        const c = a.next();<br>        if (!c.done) document.write(c.value);<br>        else clearInterval(interval);<br>    }, 100);<br>}<br><br>typeWithAnimation(&quot;Generators&quot;);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*bmcrask6DwYtsIuMh9CQqQ.gif" /></figure><h4>To chain asynchronous code</h4><p>Let’s take an example — We want to fetch blogs written by certain authors only. We have authors API that returns a list of authors and blogs API that returns blog names written by a specified author. So here <strong>our input for blogs API is dependent on the output of authors API</strong>.</p><pre>async function getAuthors() {<br>    // Request server to get authors data<br>    return await fetch(&quot;https://example.com/authors&quot;).then(resp =&gt; resp.json());<br>    /*<br>    Expected return value -<br>    [<br>        {<br>            username: &#39;john.doe&#39;,<br>            firstName: &#39;John&#39;,<br>            lastName: &#39;Doe&#39;<br>        },<br>        {<br>            username: &#39;olive.yew&#39;,<br>            firstName: &#39;Olive&#39;,<br>            lastName: &#39;Yew&#39;<br>        },<br>        ...<br>    ]<br>    */<br>}<br><br>async function getBlogs(authors) {<br>    // Request server to get blogs data of specific user one-by-one<br>    const blogs = {};<br>    for (let i in authors) {<br>        blogs[i.username] = await fetch(`https://example.com/${i.username}/blogs`).then(resp =&gt; resp.json());<br>    }<br>    return blogs;<br>    /*<br>    Expected return value -<br>    {<br>        &quot;john.doe&quot;: [&quot;Master in JavaScript&quot;, &quot;Dive into TypeScript&quot;],<br>        &quot;olive.yew&quot;: [&quot;Use Gin in Golang&quot;, &quot;Usage of Kafka&quot;],<br>        ...<br>    }<br>    */<br>}<br><br>async function* getAuthorsAndTheirBlogs() {<br>    const authors = await getAuthors();<br>    yield authors;<br>    return await getBlogs(authors);<br>}<br><br>async function render() {<br>    const gen = getAuthorsAndTheirBlogs();<br>    const authors = (await gen.next()).value;<br>    const blogs = (await gen.next()).value;<br><br>    // Render the list of authors and blogs<br>    renderUI(authors, blogs);<br>}<br><br>window.onload = () =&gt; render();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*l_azIxwJoLAs11CSACZUjw.png" /></figure><p>The full code is available here — <a href="https://gist.github.com/bmg02/56d86882f9fdec27d77dfc61e300ab72">https://gist.github.com/bmg02/56d86882f9fdec27d77dfc61e300ab72</a></p><h4>To implement infinite scrolling</h4><p>Let’s create a page that keeps giving us images of the aurora (I love it 😍) whenever the user reaches the end of the page. We will be using the Unsplash API for fetching the images.</p><pre>const MY_ACCESS_KEY = &#39;&lt;UNSPLASH_ACCESS_KEY&gt;&#39;;<br>async function* fetchImages() {<br>    let pageNum = 1;<br>    const loader = document.createElement(&#39;h2&#39;);<br>    loader.id = &#39;loader&#39;;<br>    document.body.appendChild(loader);<br>    while (true) {<br>        yield await new Promise((resolve) =&gt; {<br>            loader.style.display = &#39;block&#39;;<br>            typeWithAnimation(&quot;Loading...&quot;, loader);<br>            setTimeout(() =&gt; resolve(loader), 2000);<br>        }).then(async (loader) =&gt; {<br>            return await fetch(`https://api.unsplash.com/search/photos?query=Aurora&amp;page=${pageNum++}&amp;per_page=30&amp;client_id=${MY_ACCESS_KEY}`).then(resp =&gt; {<br>                if (!resp.ok) {<br>                    loader.textContent = &#39;Unable to fetch!&#39;;<br>                    return;<br>                }<br>                loader.style.display = &#39;none&#39;;<br>                return resp.json();<br>            });<br>        });<br>    }<br>}<br><br>async function renderImages(images, div) {<br>    const imgs = await images.next();<br>    if (imgs.value &amp;&amp; imgs.value.results) {<br>        div.innerHTML += imgs.value.results.map(obj =&gt; `&lt;img src=&#39;${obj.urls.small}&#39; /&gt;`).join(&#39;&#39;);<br>    }<br>}<br><br>async function render() {<br>    const images = fetchImages();<br>    const div = document.createElement(&#39;div&#39;);<br>    renderImages(images, div);<br>    document.onscroll = () =&gt; {<br>        if (parseInt(window.scrollY) &gt;= div.offsetTop + div.offsetHeight - window.innerHeight) {<br>            renderImages(images, div);<br>        }<br>    }<br>    document.body.appendChild(div);<br>}<br><br>window.onload = () =&gt; render();</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*OqvDcGs6W2y7A8dj8zhT9Q.gif" /></figure><p>The full code is available here — <a href="https://gist.github.com/bmg02/7c697efbc2c0ff72900bbac2ee17483e">https://gist.github.com/bmg02/7c697efbc2c0ff72900bbac2ee17483e</a></p><h3>Conclusion</h3><p>The generators are super useful to handle complex execution flow. Although this article has covered only the basics of Generators, you can learn more about it from the docs of MDN Web and JavaScript. There are a lot of real-world use-cases out there where generators might be a perfect fit.</p><p>I hope you enjoyed reading this! For more interesting articles, connect with me on <a href="https://www.linkedin.com/in/bmgandhi/">LinkedIn</a> and <a href="https://medium.com/@bhuvan.gandhi">Medium</a>. Feel free to visit my portfolio website to know more about me.</p><p>Cheers!</p><p><a href="https://bmgandhi.me/">Bhuvan Gandhi | A full-stack engineer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57ee972e9578" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Event loop — The backbone of JavaScript explained in a simpler way]]></title>
            <link>https://levelup.gitconnected.com/event-loop-the-backbone-of-javascript-explained-in-a-simpler-way-0b93bf009cc4?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b93bf009cc4</guid>
            <category><![CDATA[event-loop]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 15:45:55 GMT</pubDate>
            <atom:updated>2024-01-04T15:45:55.474Z</atom:updated>
            <content:encoded><![CDATA[<h3>Event loop — The backbone of JavaScript explained in a simpler way</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*ccBRhGFjcCD1KksQSTT0Lw.jpeg" /></figure><p>JavaScript is an event-driven programming language. This means it reacts to the events. In your journey of working with JavaScript, you must have come across a word <em>“event loop”</em> at least one time in your life, right? Today we will try to understand the concept of event loop in deep and see how JavaScript works under the hood.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*rcJG61fWGgFOW9FI_MAQHQ.png" /></figure><h4>How these terminologies are connected?</h4><h4>JavaScript Engine</h4><p>It is not only responsible for executing the JavaScript code but also responsible for handling errors, managing memory as well as optimizing performance. Every browser comes with different JS engines. For instance, Chrome uses <em>V8</em>, Firefox uses <em>SpiderMonkey</em>, and Edge uses <em>Chakra</em>. These engines use Web API provided by the host environment, browser on client-side, and Node JS on server-side, to allow the use of extended functionalities like timers, network requests, and so on.</p><h4>Web Application Programming Interfaces (Web API)</h4><p>It is a set of functions provided by the host environment that JS engine can utilize to process the code. For instance, Promise, async/await, timeout, XMLHttpRequest, and fetch API are functionalities provided by the Web API.</p><h4>Single-threaded nature</h4><p>You must have heard this word as well at some point in life. What does that mean? It just means that there is <strong>only a main thread</strong> that not only deals with executing JavaScript code but is also responsible for handling user interactions, UI rendering, and so on. <strong>This thread is shared between the JavaScript engine and the host environment</strong>.</p><h4>Non-blocking I/O model</h4><p>Due to the JS nature of executing one thing at a time, we need to be very conscious while writing the code. If a time-consuming or dependent operation like waiting for I/O or response of a network request, comes and if it gets executed synchronously then it will block the main thread till it gets finished. Till that time, the user window will be blocked as the main thread will be in the waiting state, and the user cannot interact with the window anymore. To avoid this kind of situation, <strong>the event loop delegates time-consuming tasks such as timeout and asynchronous operations to the Web API</strong>. When the operation gets finished, the Web API puts the result of the work in a queue to get picked up by the event loop for the execution.</p><p>You must be wondering, <strong>if async operations get executed by Web API on another thread then how it is single-threaded</strong>, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ucbppgEXJWfMW5okCjyHFg.gif" /></figure><p>Well, the thing is, <strong>the “execution of JavaScript” itself happens only on the main thread</strong>. The async operations are unloaded from the main thread to get executed by the Web API. And when these operations get finished, the Web API pushes the respective callbacks into the Macrotasks or Microtasks queue, depending on the type of callback, to get picked up by the event loop for execution.</p><h4>Call Stack</h4><p>As the name suggests, it is a stack data structure implemented <strong>to keep track of function calls and their execution</strong>. When a function returns then it gets popped out from the stack and the control goes back to the caller. The <strong>synchronous code</strong> is getting executed in the stack. Due to the single-threaded nature, only one call stack is maintained in JS.</p><h4>Macrotasks Queue</h4><p>Also known as the Task Queue. <strong>It maintains the track of callbacks of finished asynchronous operations</strong>. Thus it is also known as Callback Queue. UI events and rendering tasks also get queued in this queue.</p><h4>Microtasks Queue</h4><p>It is another type of queue that is maintained to <strong>keep track of high-priority tasks</strong> that need to be executed before the Task Queue. The callback of Promise and DOM manipulation tasks are queued here. Whenever the event loop comes to check the Microtasks queue, it executes all tasks from the queue before going to check if anything is available in the Macrotasks or Call Stack.</p><h3>Event Loop in Action</h3><p>The event loop is a mechanism used <strong>to process the JavaScript code while providing concurrency in a non-blocking manner</strong>. Let’s see how the above learned concepts work in the event loop with a given set of instructions.</p><pre>async function getBlogs() {<br>    const resp = await fetch(&quot;https://example.com/blogs.json&quot;);<br> const blogs = await resp.json();<br> return blogs;<br>}<br><br>function handleBlogs(list) {<br>    console.log(&quot;Loading...&quot;);<br>    setTimeout(() =&gt; {<br>        console.log(&quot;number of blogs:&quot;, list.length)<br>    }, 0);<br>    console.log(&quot;Loaded&quot;);<br>}<br><br>getBlogs().then(handleBlogs);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Je6ss90pwprbz66wqNzWRQ.gif" /><figcaption>Event loop visualization</figcaption></figure><ol><li><strong>getBlogs()</strong> will be pushed into the Call Stack</li><li>It is an <strong>async</strong> function, so it will be handled by the Web API</li><li>This function has <strong>.then()</strong> callback, so the callback function will be moved to the Microtasks queue</li><li>The instructions of callback will be pushed into the Call Stack</li><li>When <strong>setTimeout()</strong> comes, it will be moved to the Web API</li><li>Event loop continues to execute further instructions while the Web API is handling the <strong>setTimeout()</strong></li><li><strong>setTimeout()</strong> callback will be pushed to the Macrotasks queue to get executed later</li><li>Once the Call Stack gets empty, the event loop checks the Microtasks queue for any high-priority tasks. Upon not finding that, it will move forward to pick up a task available in the Macrotasks queue</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZZjoEXr5L4EjYKkwOjK0MQ.jpeg" /><figcaption>How event loop decides to pick a task</figcaption></figure><h4>What will be the output?</h4><p>As you have closely seen how the event loop works, can you guess what will be the output of the given code?</p><pre>&gt; Loading...<br>&gt; Loaded<br>&gt; Number of blogs: 11</pre><p>Did you guess it correctly? You must be wondering how the event loop continued to take the next instruction despite setTimeout() being set to 0 ms, right?</p><p>It does not matter if setTimeout() is set to 0 ms. <strong>Once the event loop encounters an instruction that is supposed to be handled by the Web API, it quickly moves that to the Web API and continues to execute the next instructions.</strong> So, now after moving the setTimeout() to the Web API, the event loop starts executing the next instruction. Later setTimeout() is resolved and the callback is sent to the Macrotasks so event loop executes the callback function of setTimeout().</p><h3>Conclusion</h3><p>Understanding event loop is important to learn how to write code efficiently. I hope you enjoyed reading this article and have learned something new today!</p><p>To get notification about my latest articles, feel free to connect with me on <a href="https://www.linkedin.com/in/bmgandhi/">LinkedIn</a> and <a href="https://medium.com/@bhuvan.gandhi">Medium</a>. Feel free to visit my portfolio website to know more about me.</p><p>Cheers!</p><p><a href="https://bmgandhi.me/">Bhuvan Gandhi | A full-stack engineer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b93bf009cc4" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/event-loop-the-backbone-of-javascript-explained-in-a-simpler-way-0b93bf009cc4">Event loop — The backbone of JavaScript explained in a simpler way</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chrome Extension V3: Mitigate service worker timeout issue in the easiest way]]></title>
            <link>https://medium.com/@bhuvan.gandhi/chrome-extension-v3-mitigate-service-worker-timeout-issue-in-the-easiest-way-fccc01877abd?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/fccc01877abd</guid>
            <category><![CDATA[service-worker]]></category>
            <category><![CDATA[bhuvan-gandhi]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[chrome]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Thu, 21 Dec 2023 21:16:36 GMT</pubDate>
            <atom:updated>2023-12-21T21:16:36.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*_k_m7z8zCr7l4RNPGbryBg.jpeg" /></figure><p>The Manifest V3 in Chrome Extension introduced a ton of features that enhanced the security by specifying what is allowed and what is not. It improved performance by avoiding running the service in the background forever. The resources on Google Developers are great if you want to dig deep into this -</p><p><a href="https://developer.chrome.com/docs/extensions/develop/migrate">Migrate to Manifest V3 | Extensions | Chrome for Developers</a></p><p>In V3, the service worker is used instead of the background script. The background script always runs in the background as long as the extension is active whereas the service worker only runs when the user clicks on the extension to execute it and gets terminated when it’s work is over.</p><p>Now this creates an issue. We use Port to connect our content script with the service worker. <strong>Because of the service worker’s non-persistent behavior, the port that we used to establish a connection, gets disconnected in a while despite the user using the extension at that moment.</strong> Due to this, the extension gets crashed and the user has to re-launch the extension and use it till the time it crashes again :(</p><p><a href="https://github.com/GoogleChrome/developer.chrome.com/issues/504">port disconnect in MV3 · Issue #504 · GoogleChrome/developer.chrome.com</a></p><p>Let me guess, just like me, you are also in this journey with frustration to fix this issue? Then you are at the right place!</p><h3>A funny/tragic incident</h3><p>I have connected my content script with a service worker using a Port connection. I was requesting APIs from the service worker and passing data to the content script after filtering out the necessary data. In the beginning, after using the extension for a few seconds only, the port got disconnected. I thought it might be due to some random issues. Then encountering the same situation several times, <strong>I kept my service worker’s devtools open so that I could monitor where my code is getting crashed.</strong> But then, I encountered ZERO time! So I tried to debug things but couldn’t find anything. So I ignored this and gave the extension to the client confidently :)</p><p>They faced 9/10 times the same issue! I again tried to debug but was not able to reproduce the error. I argued, <strong><em>“IT IS RUNNING PERFECTLY IN MY MACHINE”</em></strong>. I was hopeless and couldn’t understand what was happening. I spent almost a month but got nothing.</p><p>On one fine day, when I believed the celestial alignments in cosmos might be in my favor, I happened to observe that <strong>when my service worker’s devtools were opened, my service worker kept being alive and didn’t get terminated.</strong> And when I close devtools and use the extension, it starts getting crash in just a few seconds. <em>Woah! Wtf! What I am suspecting is true? </em>I was enjoying and dancing on finding the cause but at the same time, I was crying by thinking “At what cost” — A month, really!?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*sSxHsaXAfcpagXxsLjPh0w.gif" /></figure><h3>Back to the topic — The workaround</h3><p>A piece of code that pings the content script on a specific interval from the service worker. Because of this, a service worker will have one task all the time on it’s plate. So it won’t go in an idle state and get terminated.</p><pre>// Code on service worker<br>const pingInterval = setInterval(() =&gt; {<br>  port.postMessage({<br>    status: &quot;ping&quot;,<br>  });<br>}, 10000); // Ping every 10 seconds</pre><p><strong>Don’t forget to clear the interval</strong> using clearInterval(pingInterval); while exiting from the extension.</p><h3>Conclusion</h3><p>This fix helped me to keep my service worker running as long as the user was using the extension. Your use-case might be different but I hope you will be able to solve your issue either by using the same technique or be able to find your own workaround through this fix.</p><p>I hope you enjoyed reading this! For more interesting articles, connect with me on LinkedIn and Medium. Feel free to visit my portfolio website to know more about me.</p><p>Cheers!</p><p><a href="https://bmgandhi.me/">Bhuvan Gandhi | A full-stack engineer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fccc01877abd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chrome extension set up with TypeScript, SCSS and Webpack]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@bhuvan.gandhi/chrome-extension-set-up-with-typescript-scss-and-webpack-612ed2015b93?source=rss-5ec765c58c15------2"><img src="https://cdn-images-1.medium.com/max/1080/1*8P3Rh-jz_ChbEeTSrmfQhg.png" width="1080"></a></p><p class="medium-feed-snippet">Build Chrome Extension using TypeScript, SCSS and Webpack using the following steps or with the given boilerplate.</p><p class="medium-feed-link"><a href="https://medium.com/@bhuvan.gandhi/chrome-extension-set-up-with-typescript-scss-and-webpack-612ed2015b93?source=rss-5ec765c58c15------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@bhuvan.gandhi/chrome-extension-set-up-with-typescript-scss-and-webpack-612ed2015b93?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/612ed2015b93</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[scss]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 06:32:47 GMT</pubDate>
            <atom:updated>2023-12-28T03:10:23.595Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Capture network traffic of mobile device in PC using Burp Suite]]></title>
            <link>https://medium.com/@bhuvan.gandhi/capture-network-traffic-of-mobile-device-in-pc-using-burp-suite-8ff0882d9e81?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ff0882d9e81</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[proxy]]></category>
            <category><![CDATA[mobile-apps]]></category>
            <category><![CDATA[burpsuite]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Tue, 12 Jul 2022 04:45:58 GMT</pubDate>
            <atom:updated>2023-12-28T03:11:18.710Z</atom:updated>
            <content:encoded><![CDATA[<p>We often use a mediator between our computer and Internet for various reasons. This mediator is often called as a Proxy server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Se4r0mvt58kPCO11xga0vw.jpeg" /></figure><h3>Why we need proxy server?</h3><p>The main purpose of proxy server is work as a <strong>middleman between client and server</strong> and manage <strong>request coming from client and response coming from server</strong>. The use-cases may change as per the goals of an individual. Some use-cases are as follows for quick reference.</p><ul><li>Don’t want that request with client header directly reach to the destination server.</li><li>Need to validate request and response while sending to server and client respectively.</li><li>Debug requests in the production environment.</li></ul><p>Today, we are going to use <strong>Burp Suite to debug our requests coming from mobile device</strong>.</p><h3>About Burp Suite</h3><ul><li>A web penetration testing framework, written in Java.</li><li>Works as interceptor (middle-man) between PC and default gateway by creating proxy server.</li><li>Used to find vulnerabilities that are affecting web applications.</li></ul><h3>Network topology</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*-DTI0FoKbG9WAmMVgK135Q.png" /></figure><p>Our <strong>PC and mobile device connected to the same Wi-Fi network</strong>. Now, we will use our PC as a proxy server by running Burp Suite in it and we will be listening on a specific port for all incoming requests from mobile device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*9vvjUiJvhEUwPtJZMP7TLQ.png" /></figure><p>Enough talk, <strong>it’s time for action</strong>!</p><ul><li>Download and install Burp Suite</li><li>Configure proxy server</li><li>Modify Wi-Fi settings in mobile</li><li>Download and install CA certificate</li><li>Let’s roll..!</li></ul><h4>Download and install Burp Suite</h4><p>If you don’t have Burp Suite in your PC, go to the <a href="https://portswigger.net/burp/communitydownload"><strong>official website of PortSwigger to download a community version of Burp Suite</strong></a> which is absolutely free. Once you download and install, open it and follow the below steps. You will see a dashboard with lots of options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OaeKBRWVRfvGlzrUUXU8Kw.gif" /></figure><h4><strong>Configure proxy server</strong></h4><p>Once you have started Burp Suite, you will see a lot of options. For now, let’s focus on Proxy tab. After navigating to Proxy tab, follow these steps:</p><ul><li>Go to <strong>Options</strong> and click on <strong>Add</strong> button of <strong>Proxy Listener</strong> section</li><li>Add <strong>port on which we are going to listen requests</strong> from mobile device i.e. 8032</li><li>Enable for <strong>all interfaces</strong> (all devices which sends request on our IP address with 8032 port)</li></ul><p>And then save it. Cool, our proxy server is ready to use.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vyvl8p1yOaXsdq1B42SKlg.gif" /></figure><p>For next step, we need an <strong>IP address of PC</strong>. For that, we need to run command line utility.</p><p>For windows, open <strong>command prompt</strong> and run below command.</p><pre>&gt; ipconfig</pre><p>For Linux or Mac, open <strong>terminal</strong> and run below command.</p><pre>&gt; ifconfig</pre><p>Find out your connected Wi-Fi interface and <strong>note down the IPv4 address</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ybPaXifmgN6jK5qznTC2hA.gif" /></figure><h4>Modify Wi-Fi settings in mobile</h4><p>To divert the requests to PC instead of sending directly to router, we need to <strong>configure Wi-Fi settings</strong> in the mobile. For that follow these steps:</p><ul><li>Open <strong>Wi-Fi settings</strong> and click on edit button of connected Wi-Fi network</li><li>Click on <strong>Advanced options</strong>. Click on <strong>Manual in Proxy</strong></li><li>Enter an <strong>IP address of PC in host</strong> and <strong>8032 in port</strong></li></ul><p>Save these changes. Now all the traffic of mobile device will go through PC. <strong>You will see a prompt in your mobile that Wi-Fi has no internet. That’s fine because our mobile has not recognized the proxy server to which we are connected.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7q5vIF4piCYJ9dyvTq0OWw.gif" /></figure><h4>Download and install CA certificate</h4><p>To download the proxy server in your mobile, type <a href="http://burp/">http://burp</a> in your browser. You will see <strong>a Burp Suite page</strong> and a button in top-right corner to <strong>download a CA certificate</strong>. Click on that and it will get downloaded.</p><p>To install this certificate, follow these steps:</p><ul><li>Open <strong>File Explorer</strong> in mobile and navigate to the <strong>download folder</strong> (where you have downloaded certificate file)</li><li>Rename cacert.der to <strong>cacert.cer</strong></li><li>Open Settings &gt; Security &gt; Encryption and Credentials &gt; Install a certificate &gt; <strong>CA certificate</strong></li><li><strong>Import cacert.cer</strong></li></ul><p><strong>Note: These steps may change as per devices and Operating Systems.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*69a0K08Qf1CHHcqfap3h5A.gif" /></figure><p>So finally, we are ready to test network traffic coming from mobile device.</p><h4>Let’s roll</h4><p>Each and every network request will pass through the proxy server. Thus, to intercept the request to view, click on <strong>Intercept is off</strong> button in the Intercept tab of Proxy, it will <strong>turn into Intercept is on</strong>. Now, any request come from your mobile will be visible in the Burp Suite.</p><p>Once you have intercepted a request, <strong>you will see request header and body. You can modify it if you want</strong>. Then you can forward the request to the destination server by clicking on the forward button. If you want to cancel, means you don’t want that request to reach server, then press Drop button.</p><p>Let’s try this. Open a browser, and type a URL. I am opening <a href="https://medium.com/@bhuvan.gandhi">https://medium.com/@bhuvan.gandhi</a>. So, as soon as I press submit, the request will be captured in Burp Suite. Because every network request will go via our proxy server i.e. our PC.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C02chmHk_ehfYyrxbBMCKQ.png" /></figure><p>Your request is not getting captured? <strong>Reconnect to the Wi-Fi</strong>. It may take a few seconds to show effects of updated configuration. Don’t worry, the configuration will remain there until you don’t change it manually.</p><p>So, this is how we can capture network traffic coming from mobile device in PC. For more interesting articles, connect with me on <a href="https://medium.com/@bhuvan.gandhi">Medium</a> and <a href="https://www.linkedin.com/in/bmgandhi">LinkedIn</a>.</p><p><a href="https://medium.com/@bhuvan.gandhi">Bhuvan Gandhi - Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ff0882d9e81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.JS: A React JS framework to achieve better performance — Part 2/2]]></title>
            <link>https://medium.com/@bhuvan.gandhi/next-js-a-react-js-framework-to-achieve-better-performance-part-2-2-906ad8997d9a?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/906ad8997d9a</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[image-optimization]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 11:47:11 GMT</pubDate>
            <atom:updated>2022-06-28T12:26:47.839Z</atom:updated>
            <content:encoded><![CDATA[<h3>Next.JS: A React JS framework to achieve better performance — Part 2/2</h3><p>Next.JS — a wonderful open-source framework for web development which is allows to write frontend in React JS and backend in Node JS. We have seen in previous article <a href="https://medium.com/@bhuvan.gandhi/next-js-a-react-js-framework-to-achieve-better-performance-part-1-2-c79dee4b8584">the importance of Next.JS and how to setup it</a>. In this article, we are going to decode on the surface-level what is Next.JS is capable of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*mVO41r0pwudjdMnFRDsrIw.jpeg" /></figure><p>Before we can start on how we achieve better performance in Next.JS, let’s first <strong>understand how it works</strong> in the first place. Next.JS follows certain steps to build files for production server.</p><h4>Compiling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*5pXJ0EI7A9yPMMFipFF-7Q.jpeg" /></figure><p><strong>It is a process of taking code in one language and giving another language.</strong></p><p>We write code in JSX, TypeScript and other modern versions of JavaScript. As these languages serves their own benefits by providing efficiency, we need to compile them into JavaScript so that browser can understand. When we write code and save it, Next.JS compiler starts its job.</p><h4>Minifying</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*sP-1vPa-Kz-EJCft19BCJQ.jpeg" /></figure><p>We write code which is readable by the humans. It contains extra information which is not required to run like spaces, indents, comments and multiple lines. In this phase, <strong>compiler removes unnecessary formatting and comments.</strong> This phase is executed for production build.</p><h4>Bundling</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*uxbfR7reRPFvL2GXYoTO9w.jpeg" /></figure><p>We have <strong>a good habit of dividing our application into components and modules</strong> that can be used to build larger pieces of application by combining them. We also use third-party packages which are dependent on one or multiple modules. This creates a complex dependency graph. <strong>Using Webpack, Next.JS solves the dependencies and create bundle files.</strong></p><h4>Code splitting</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*hXg9RxqrK0Vdk1o9y_Z4JQ.jpeg" /></figure><p>As we are dividing our website in different pages where the pages are entry-points for the website, Next.JS splits bundle files into smaller files called chunk where a chunk file is associated with an entry-point page. So, <strong>when a client requests for a page, Next.JS sends a chunk file which has code and dependencies for that page only.</strong> This reduces load time drastically.</p><h3>Ways to improve performance</h3><p>There is a lot thing in the Next.JS which can be used to improve application performance. I have covered three major ways which are useful for everyone including beginners.</p><h3>Using rendering methods</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Y78qohnB7mR-Fwucx4iNLQ.jpeg" /></figure><p><strong>The process of converting code into representation of UI </strong>— React to HTML is called rendering. This process is either take place on server or client. Next.JS supports three types of rendering methods:</p><p>And an interesting thing is, we can use multiple rendering methods based on requirements for different pages. And <strong>these methods only work in the files which are in </strong><strong>/pages directory</strong>.</p><h4>Server-side rendering</h4><p>The process of <strong>generating HTML of a page with requested data for each request on the server and then send it to the client</strong>, is called server-side rendering. It is required when we have to fetch updated data on each request. Check out the <a href="https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props">official documentation</a> to know how to use it.</p><h4>Static-site generation</h4><p>Here, the <strong>HTML is generated on the server and once the content is generated, it gets stored on CDN and re-used for each request</strong>. There are different parameters available in SSG method configuration which allows to define when to request for data again. We can use this method when the data we are fetching doesn’t change frequently.</p><p><strong>This method is faster than SSR</strong> because it doesn’t request for data on every request and also it gets stored on CDN so that content can be delivered as request arrives without requesting server for data every time. Fascinating, right? Check out the <a href="https://nextjs.org/docs/basic-features/data-fetching/get-static-props">official documentation</a> on how to use it.</p><h4>Client-side rendering</h4><p>It is our normal way of rendering React application on browser. The browser receives an empty HTML from the server along with the JavaScript files which contains the instructions to build the UI.</p><h3>Using dynamic imports</h3><p>By the nature, application loads all the components and their CSS required by the requested page in the initial load. This will increase the load on application as browser has to download unnecessary resources. To avoid this, <strong>we can use dynamic imports where a separate chunk file will be created by Next.JS compiler which will be downloaded on-demand when it is required</strong>.</p><p>This will create a huge impact in performance, especially on mobile devices.</p><pre>import dynamic from &#39;next/dynamic&#39;;<br>import { Suspense } from &#39;react&#39;;<br><br>const Menubar = dynamic(() =&gt; import(&#39;../components/Menubar&#39;), {<br>    suspense: true,<br>})<br><br>export default function HomePage() {<br>    return (<br>        &lt;Suspense fallback={&#39;Loading...&#39;}&gt;<br>            &lt;Menubar /&gt;<br>        &lt;/Suspense&gt;<br>    )<br>}</pre><h3>Using optimized images</h3><p>Static files like images, videos etc. files are also important while measuring application performance. We can improve the performance by reducing the size of image files and using correct format. JPG/JPEG is better for photos and PNG is better for graphics.</p><p>Next.JS has its own image component which is a wrapper of &lt;img /&gt;tag. It does these all things for us without any major configuration.</p><pre>&lt;Image<br>    alt=&quot;Next.JS image cover&quot;<br>    src=&quot;/image-cover.jpg&quot;<br>    placeholder=&quot;blur&quot;<br>    width={640}<br>    height={480}<br>/&gt;</pre><ul><li><strong>Lazy loading</strong>: Image will be loaded only when it is visible in the client viewport. Thus, all images of a web page will not get downloaded on initial load. Though, we can disable it by setting priority={true}.</li><li><strong>Placeholder</strong>: We can blur image while the actual image is getting downloaded in the background.</li><li><strong>Quality</strong>: We can also manage which quality of image we want to download from the server. For example, downloading 4K image for small screen devices is not a good idea. So, we can specify quality range from 1 to 100, where 1 is worst and 100 is best quality.</li></ul><p><strong>By default, Next.JS image component ensures that the most optimal image with possibly best image size and format for responsiveness must be addressed.</strong></p><p>For more information, checkout this amazing <a href="https://blog.logrocket.com/next-js-automatic-image-optimization-next-image/">blog by LogRocket on image optimization in Next.JS</a>.</p><p>So, these are the tips and tricks we can use to achieve better performance, though the list is not limited to this. We will definitely check out more amazing things Next.JS capable for in upcoming articles.</p><p>Till that time, feel free to comment if you have any suggestion or tips for Next.JS. If you want to read more about Next.JS, check out its well-maintained <a href="https://nextjs.org/docs">official documentation</a>.</p><p>Connect with me for more interesting articles :)</p><p><a href="https://github.com/bmg02">GitHub</a> | <a href="https://www.linkedin.com/in/bmgandhi">LinkedIn</a></p><p><a href="https://medium.com/@bhuvan.gandhi">Bhuvan Gandhi - Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=906ad8997d9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.JS: A React JS framework to achieve better performance — Part 1/2]]></title>
            <link>https://medium.com/@bhuvan.gandhi/next-js-a-react-js-framework-to-achieve-better-performance-part-1-2-c79dee4b8584?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/c79dee4b8584</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[server-side-rendering]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Thu, 16 Jun 2022 18:01:42 GMT</pubDate>
            <atom:updated>2022-06-16T18:05:01.311Z</atom:updated>
            <content:encoded><![CDATA[<h3>Next.JS: A React JS framework to achieve better performance — Part 1/2</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*_Q6fyRtsoISp2953d-xp0w.png" /></figure><p>Next.JS is a framework that works on top of the React JS library. It is famous for providing features like server-side rendering, Node JS API in the project itself, and much more advanced stuff.</p><p>As we all know, React JS is one of the most widely used JavaScript frontend libraries. Because of its reusability and flexibility, many libraries and frameworks are being developed to use it more efficiently. Next.JS is one of them. This article is divided into 2 parts. The first one is about what is Next.JS and how to set up it. The second one is about how Next.JS works internally and how we can take benefit from it to achieve better performance.</p><blockquote>The fundamental difference between a library and a framework. Well, a library provides a set of functions and classes that developers use to speed up their development process. Whereas a framework is a foundation on which developers build their applications by following a specific way.</blockquote><h3>The motivation behind using Next.JS</h3><p>Before learning Next.JS and its features, let’s talk about why need it in the first place? As we know, React JS is a frontend library where the processing is done client-side i.e. browser. This makes it slower when the API requests are made to fetch the data while the browser is loading UI. Next.JS is having different data fetching methods which serves the rendered page with data directly to the browser so it doesn’t have to perform further operations. Interesting, isn’t it? And did I mention previously that it supports Node JS API? :)</p><h3>About Next.JS</h3><ul><li>An open-source framework for web development.</li><li>Allows to write frontend in React JS and backend in Node JS in the single application.</li><li>It runs on the server-side.</li><li>The compiler is written in Rust. It allows to transform and minify JavaScript code for production.</li></ul><h3>Features</h3><h4>API Routes</h4><p>Used to write APIs in Node JS. Any file inside /pages/api/* will be considered as an API endpoint.</p><h4>Automatic code splitting</h4><p>When we compile the project, a bundle.js file is created. It has the whole script of the project. Next.JS splits the bundle file into chunk files. Each file we have in /pages directory will have respective chunk file.</p><h4>Dynamic import</h4><p>It allows us to import file in runtime. A separate chunk file is created for dynamically imported component.</p><h4>Server-side rendering</h4><p>Next.JS allows to fetch data on server and convert HTML files on the server into a complete rendered HTML page for the browser. And the interesting part is, we can use different data fetching method in multiple pages as per requirements. Some pages may have static data whereas some pages may have server-side rendering method to fetch the data.</p><h4>Image components and optimization</h4><p>Next.JS has built-in image component which is an extension of of &lt;img /&gt; tag. It provides better performance by reducing the image size, on-demand image resizing and much more.</p><h4>Built-in CSS</h4><p>It allows to use global and component-level CSS in the project. It also supports SASS and LESS.</p><p>Component-level CSS is basically dynamic classnames generated by the compiler. For more information, checkout this article.</p><p><a href="https://medium.com/@bhuvan.gandhi/use-dynamic-css-class-names-along-with-global-classes-using-webpack-in-react-js-e78c2bf2ca3d">Use dynamic CSS class names along with global classes using Webpack in React JS</a></p><p>Next.JS supports a lot exciting features out-of-the-box. Let’s start with by creating our first Next.JS project!</p><h3>Setup</h3><h4>Requirements as per the official documentation:</h4><blockquote>Node JS 12.22.0 or later<br>MacOS, Windows (including WSL) and Linux are supported</blockquote><p>We will go with the easiest one by using the automatic setup.</p><p>Open the terminal and navigate to the directory where you want to create your project.</p><pre>/path/of/the/directory&gt; npx create-next-app my-app</pre><p>To run the project, navigate to the my-app directory and the run npm run dev command. This will start the server in development mode.</p><pre>&gt; cd my-app<br>&gt; npm run dev</pre><h3>File structure</h3><p>Next.JS has very straight-forward file structure. Let’s try to understand it by checking out what .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*p5X_S01VV71aX5dTdsrO4g.png" /></figure><h4>pages</h4><p>The directory /pages will have JS files which will be treated as a page. Node JS API routes will be in this directory under /api directory.</p><h4>_app.js</h4><p>This file is the entry point for the frontend. Every page will be get passed through this component. Every page will be get passed through this component. Code level changes which want to share across the project can be defined here.</p><h4>public</h4><p>This directory will contain the assets which will be available publically through URL like http://localhost:3000/vercel.svg to access a resource file. We can store media, fonts and other resources which we want to get accessed through the public URL.</p><h4>styles</h4><p>It is containing the CSS files including the global and component-level. The global CSS file will have only name with .css extension whereas component-level CSS file will have name with .module prefix along with .css extension.<br>We have to import global CSS files in the _app.js file so that compiler can identify them and don&#39;t treat them as component-level CSS file.</p><h4>next.config.js</h4><p>It is our regular Node JS file. It is the brain of our Next.JS project which governs the behaviour of our project through written configuration.</p><p>I hope you are now motivated enough to start with your first Next.JS project. Stay tuned with for the second part where I am explaining how the Next.JS works under the hood.</p><p>As you have reach till the end of this article, probably you are a React JS enthusiastic. Checkout this interesting article on data passing.</p><p><a href="https://medium.com/@bhuvan.gandhi/pass-data-from-child-component-to-parent-component-without-using-state-hook-b301a319b174">Pass data from child component to parent component without using state hook</a></p><p>Feel free to connect with me for more interesting articles :)</p><p><a href="https://github.com/bmg02">GitHub</a> | <a href="https://www.linkedin.com/in/bmgandhi">LinkedIn</a></p><p><a href="https://medium.com/@bhuvan.gandhi">Bhuvan Gandhi - Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c79dee4b8584" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use dynamic CSS class names along with global classes using Webpack in React JS]]></title>
            <link>https://medium.com/@bhuvan.gandhi/use-dynamic-css-class-names-along-with-global-classes-using-webpack-in-react-js-e78c2bf2ca3d?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/e78c2bf2ca3d</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[babel]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Tue, 31 May 2022 15:41:57 GMT</pubDate>
            <atom:updated>2022-05-31T15:41:57.786Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*pOPHpgMiJaZoF-eX-oZOkw.png" /></figure><p>As we know, React JS is heavily used nowadays for creating the frontend for web and mobile applications. It is quite famous for its flexibility and reusable components. While working as a frontend developer, <strong>we often encounter a common problem — giving unique CSS class name to components so that they don’t get overridden in runtime.</strong> I know, it is very painful and time consuming task. But not to worry, webpack is here to save us.</p><h3>What is dynamic CSS classes?</h3><p>The CSS classes we specify in style sheets, they get converted or appended with arbitrary value and that value is used as a class name for respective element. While compiling, <strong>Webpack generates dynamic unique class name for each class name across all the valid CSS files.</strong> Sounds interesting, isn’t it? Thus, it saves a great time and allow us to forget the worry and write the same class name for two different styles. The responsibility of distinguish classes will be on compiler.</p><p>Here are the <strong>quick and easy 5 steps</strong> to implement it in your project. If you want to clone the boilerplate directly, then the link is given in the end of this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/1*C3iU0SEj8uWSU47UT2ekUg.jpeg" /><figcaption>File structure</figcaption></figure><h4>Create a react project (if you don’t have one)</h4><p>Assuming that you already have Node JS installed. Open the terminal and create a new react application. It will create a boilerplate for react application.</p><pre>&gt; npx create-react-app &lt;project-name&gt;</pre><h4>Install dev dependencies for Webpack and Babel</h4><p>Once it gets done, go to your project directory in terminal and install the all the required dependencies — babel, webpack, style/css loader etc.</p><pre>&gt; npm i -D webpack webpack-cli webpack-dev-server html-webpack-plugin @babel/core @babel/preset-env babel-loader @babel/preset-react babel-plugin-transform-class-properties babel-plugin-transform-es2015-modules-commonjs style-loader css-loader</pre><h4>Configure Babel</h4><p>Create .babelrc file in project root directory and paste the babel configuration code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fa9de1a81627772a712d59960534807/href">https://medium.com/media/5fa9de1a81627772a712d59960534807/href</a></iframe><h4>Configure Webpack</h4><p>Now, create webpack.config.js file and write the webpack configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f89f29660f8e3446346c9efe6d92f4f6/href">https://medium.com/media/f89f29660f8e3446346c9efe6d92f4f6/href</a></iframe><p>Here, we are targeting only CSS files which have .module as postfix in their file name. Because we don’t want to convert all the class names across all the CSS files of the project.</p><p>We may need global CSS files (like main.css) to use the common classes which can be used across the project.</p><h4>Update package.json and run</h4><p>Add these lines in scripts section of package.json file. These are the commands which we will use to run and build React JS files.</p><pre>{<br>    ...<br>    &quot;scripts&quot;: {<br>        ...<br>        &quot;webpack&quot;: &quot;webpack&quot;,<br>        &quot;webpack-dev-server&quot;: &quot;webpack-dev-server&quot;,<br>        &quot;dev&quot;: &quot;npm run webpack-dev-server -- --node-env development&quot;,<br>        &quot;prod&quot;: &quot;npm run webpack -- --node-env production&quot;<br>    }<br>    ...<br>}</pre><p>To run the project, we will use dev command in the terminal.</p><pre>&gt; npm run dev</pre><h3>How to use?</h3><p>Open the App.css file, remove the existing code and add the sample CSS class name as shown in the code. And rename to App.module.css. Because as we have specified in webpack, we will only make dynamic class names of the CSS files which have .module in their file name.</p><pre>// App.module.css</pre><pre>.appDiv {<br>  padding: 10px;<br>  color: white;<br>  background-color: darkslategray;<br>}</pre><p>In the App.js, import the CSS file as styles and use it as the value of className attribute of the desired element.</p><pre>// App.js</pre><pre>import React from &quot;react&quot;;<br>import &quot;./main.css&quot;;   // Global CSS file<br>import styles from &quot;./App.module.css&quot;;</pre><pre>function App() {<br> return (<br>  &lt;section className=&quot;container&quot;&gt;<br>   &lt;div className={styles.appDiv}&gt;React Boilerplate&lt;/div&gt;<br>  &lt;/section&gt;<br> );<br>}</pre><pre>export default App;</pre><p>Now, open the browser and inspect the element. A random characters appended with the class name which makes it unique class name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*4vuVJVDRT1gD8KJIJPJ4LA.png" /><figcaption>Output on the browser</figcaption></figure><p>You may think .appDiv is converted, but not .container class, why so? Because we have defined .container in global CSS file — main.css. Which will not be converted.</p><pre>// main.css</pre><pre>body {<br>  background: yellowgreen;<br>}<br>.container {<br>  padding: 10px;<br>}</pre><p><strong>If you make any change in </strong><strong>package.json, </strong><strong>webpack.config.js or </strong><strong>.babelrc, then make sure you restart the server.</strong></p><p>GitHub repository: <a href="https://github.com/bmg02/reactjs-boilerplate">React JS Boilerplate</a></p><p>Feel free to clone and use it in your project. You can also send PR request if you have any interesting to add in boilerplate.</p><h4>Want to understand more?</h4><p>Visit the documentation sites of <a href="https://webpack.js.org/guides/">Webpack</a> and <a href="https://babeljs.io/docs/en/">Babel</a>.</p><p>I hope you liked this amazing time saving trick. Follow me on <a href="https://linkedin.com/in/bmgandhi">LinkedIn</a>, <a href="https://github.com/bmg02">GitHub</a> and <a href="https://medium.com/@bhuvan.gandhi">Medium</a> for more interesting content on software development.</p><p><a href="https://medium.com/@bhuvan.gandhi">Bhuvan Gandhi - Medium</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e78c2bf2ca3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 reasons why should a beginner must learn PHP in 2022]]></title>
            <link>https://medium.com/@bhuvan.gandhi/5-reasons-why-should-a-beginner-must-learn-php-in-2022-862f8b0199e6?source=rss-5ec765c58c15------2</link>
            <guid isPermaLink="false">https://medium.com/p/862f8b0199e6</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[php-development]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Bhuvan Gandhi]]></dc:creator>
            <pubDate>Mon, 16 May 2022 20:26:35 GMT</pubDate>
            <atom:updated>2022-05-17T05:01:24.167Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/433/1*WOFWCfcCVMTQCNXVoHJ7Mw.png" /></figure><p>PHP (Hypertext Preprocessor) is a backend language which is still used by many developers in the industry. It has been active in the industry for more than 2 decades now. According to the <a href="https://w3techs.com/technologies/details/pl-php">Web Technology Surveys</a>, <strong>PHP is used by 77.4% of all the websites whose server-side programming language we know.</strong> Two big examples are in-front of us, Facebook and WordPress. This number is not just a huge but also a shocking because we have seen downfall in the popularity of PHP.</p><h3>Why downfall?</h3><p>Because in the last decade, many competitors came and emerged in the industry as an alternative of it. <strong>They have provided lots of resources which made the life of developers so easy.</strong> Another thing is the reputation of PHP. Because as it is one of the oldest player in the industry, it is now reputed as an old man. Though, this old man has improved a lot himself in the last few years.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Jjufr95X17ILbKA03UPUw.png" /><figcaption>Image credits — <a href="https://www.youtube.com/watch?v=Og847HVwRSI">https://www.youtube.com/watch?v=Og847HVwRSI</a></figcaption></figure><h3>Why one should still learn it?</h3><p>If we talk about the advantages and disadvantages of using PHP, then checkout on the Internet, there are lots of debates going on in the developer community. We will stick here on the practical aspects of it. Because no programming language is good or bad. It is always depend on the use-case, because it is just a tool. Whenever someone asks me what to choose between PHP or something else as a beginner, then I always hands down to PHP. It is open-source and comparatively easy to start with. But apart from this, there are more reasons to it.</p><h3>5. Community support</h3><p>As we know, around 77.4% websites are running on PHP, we can understand how large the community will be. If you feel stuck in between, feel free to ask on online forums, you will get your answer for sure.</p><h3>4. Tried and tested</h3><p>It has been more than 2 decades that PHP exists. And it is still in use. From this, we know it has survived through all kinds of real-life environments. There are many frameworks of PHP available which makes it more secure and efficient.</p><h3>3. Performance and stability</h3><p>The newer versions of PHP (v7 and v8) are far better than older versions. PHP is exclusively available for the web. Thus, it contains all the necessary functionality related to browsers, servers and databases. That’s why it is more beginner friendly language. For more information regarding the performance, read the article given on <a href="https://kinsta.com/blog/php-benchmarks/#php-benchmarks-2022">Kinsta</a>.</p><h3>2. More control</h3><p>As PHP is specifically designed for the web, it supports HTML code in the file itself. We can configure the server configuration as per our requirements easily. We can build standalone server which works on REST API, as well as we can integrate HTML code in the PHP file which generates HTML file with dynamic content.</p><h3>1. Know the web closely!</h3><p>The major one — get to know more about web deeply. If we only talk about core PHP, it only comes with necessary things. We get to learn how really the web works. We have to build the APIs on our own. The significance of request headers, the art of organizing files, to implement an MVC architecture and much more.</p><h3>Job opportunities</h3><p>Again, as we have seen that 77.4% websites are using PHP as a server-side language whose technology we know. Thus, market opportunity is not ended yet. There are still demand for PHP developers. But as the competition is rising with other programming languages, the payout for the PHP developers are decreasing. But still, if you are good at what you do, then sky is a limit for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lO6DMch73oFAfwNspJ4U-Q.png" /><figcaption>Image credits: <a href="https://kinsta.com/blog/php-developer-salary/">https://kinsta.com/blog/php-developer-salary/</a></figcaption></figure><h3>From where to start?</h3><p>You may think that I got to know the importance of learning PHP, but from where shall I begin? Not an issue. I have attached a few resources here to getting started with. I would encourage to read from documentation of PHP also. Nothing is as accurate and clear as given on the documentation page.</p><p><a href="https://www.php.net/docs.php">PHP documentation</a></p><p><a href="https://www.youtube.com/watch?v=OK_JCtrrv-c">PHP full course by Freecodecamp — YouTube</a></p><p><a href="https://www.youtube.com/watch?v=hKB-YGF14SY">PHP tutorial in Hindi — YouTube</a></p><p>Remember, these sites are just giving you a kick start. Our main goal here is to learn about the fundamentals of web and of-course PHP also. Thus, you can also start learning from any other place also.</p><p>To learn more about the past, present and future of PHP, visit <a href="https://kinsta.com/blog/is-php-dead/">this article on Kinsta</a>.</p><h3>Conclusion</h3><p>If you choose any other programming language over PHP for web, you can still learn these all things. But most of the modern programming languages come with preloaded resources which makes our life more easier which is good but bad for a beginner. I hope this article has helped you to make a decision as a beginner in web development.</p><p>Interested in more articles, connect with me on <a href="https://www.linkedin.com/in/bmgandhi">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=862f8b0199e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>