<?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 Sudip Bhattacharyya on Medium]]></title>
        <description><![CDATA[Stories by Sudip Bhattacharyya on Medium]]></description>
        <link>https://medium.com/@sudipb001?source=rss-bf3bcedd6068------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5wFPvpb_BBheHRSVBZTh0A.jpeg</url>
            <title>Stories by Sudip Bhattacharyya on Medium</title>
            <link>https://medium.com/@sudipb001?source=rss-bf3bcedd6068------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 07:07:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sudipb001/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[The Future of Web Development with Generative AI: Will the Bots Steal Our Jobs or Just Our Coffee?]]></title>
            <link>https://medium.com/@sudipb001/the-future-of-web-development-with-generative-ai-will-the-bots-steal-our-jobs-or-just-our-coffee-c4c4c3693bd7?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4c4c3693bd7</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[future-web-trends]]></category>
            <category><![CDATA[future-technology]]></category>
            <category><![CDATA[future-web]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Mon, 09 Dec 2024 14:33:50 GMT</pubDate>
            <atom:updated>2024-12-09T14:33:50.885Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*4Vai0HQL6C56ZWqYHgAjkw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@laurenmancke?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lauren Mancke</a> on <a href="https://unsplash.com/photos/turned-off-macbook-pro-beside-white-ceramic-mug-filled-with-coffee-aOC7TSLb1o8?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>Ah, web development — once a realm ruled by mortals with coffee-stained keyboards and dark mode IDEs. Now, a new contender enters the arena: <strong>Generative AI</strong>, the digital wizard that claims it can do everything from coding your website to designing your dreams (yes, even that homepage with the spinning globe and Comic Sans you’ve been fantasizing about since 1999).</p><p>So, let’s embark on a lighthearted journey through the futuristic world where web developers and generative AI become unlikely coworkers. Spoiler: There will be code, chaos, and maybe a robot uprising… but mostly laughs.</p><h3>Meet Your New Coworker: A Bot with a Sense of (Somewhat) Humor</h3><p>Imagine this: you walk into your virtual office (thanks, remote work) and greet your AI assistant.</p><p><strong>You:</strong> “Hey, I need a responsive layout with a sticky navbar and a cool hero section.”<br><strong>AI:</strong> “Here you go. Also, I fixed your syntax error from last night. You’re welcome.”</p><p>It’s the perfect coworker: no snarky comments, no sick days, and it doesn’t hog the office snacks. But be careful — it <em>does</em> have a tendency to suggest variable names like doStuff123.</p><h3>Web Development in the Year 2030: Bots Write the Code, Humans Drink the Coffee</h3><p>Let’s fast-forward to a decade from now. What might web development look like in this AI-powered wonderland? Here are a few plausible (and slightly absurd) scenarios:</p><h3>The “One-Click Website” Era</h3><p>Websites are no longer built, they’re summoned. You type, “Create me a portfolio site for my cat,” and voila! AI generates a purr-fect (pun intended) site complete with paw-themed buttons, a blog about naps, and a photo carousel of your furry CEO. The downside? AI sometimes uses placeholder text like <em>Meow Ipsum!</em></p><h3>Debugging with Sarcasm</h3><p>Forget cryptic error messages. In the future, generative AI gives you real talk:<br><strong>Error:</strong> “Your code broke because you didn’t close your div tag. Again.”<br><strong>Fix Suggestion:</strong> “How about I fix it for you while you rethink your life choices?” (damn it!)</p><h3>AI-Generated Design Trends</h3><p>AI won’t just follow design trends — it’ll create them. One day it might decide that websites should be shaped like pizzas. The next? Parallax scrolling on <em>everything</em>. It’s like having a designer with creative ADHD! (Oh my!)</p><h3><strong>Generative AI: The Good, the Bad, and the Hilarious</strong></h3><h3>The Good</h3><ul><li><strong>Speedy Deliveries:</strong> AI knocks out boilerplate code and repetitive tasks faster than you can say “Ctrl+C, Ctrl+V.”</li><li><strong>Design on Steroids:</strong> Say goodbye to the blank-canvas blues. AI will churn out dozens of mockups before you’ve finished your coffee.</li><li><strong>Infinite Patience:</strong> Unlike humans, AI won’t be angry when you ask for the 14th revision on that button color or “half” a pixel coordinate change!</li></ul><h3>The Bad</h3><ul><li><strong>Overconfidence:</strong> Sometimes, AI <em>thinks</em> it knows better (than atleast you).<br><strong>You:</strong> “I need a minimalist design.”<br><strong>AI:</strong> <em>[Generates a website with neon pink text, five gradients, and a background video of cats dancing.]</em></li><li><strong>Buggy Sense of Humor:</strong> Debugging AI-generated code can feel like deciphering ancient runes.</li></ul><h3>And The Hilarious</h3><ul><li><strong>The AI Naming Game:</strong> “Here’s your new JavaScript function: doTheThingNowForRealThisTime().” Thanks, AI. Very helpful.</li><li><strong>Unintentional Easter Eggs:</strong> Ever had an AI design a footer with a copyright notice for 2055? It’s an optimist, at least.</li></ul><h3>Will AI Take Over Web Development?</h3><p>The burning question: Will generative AI make human developers obsolete? Relax. AI may be great at cranking out lines of code, but it lacks something irreplaceable: <strong>human creativity, empathy, and the ability to come up with obscure variable names like </strong><strong>potatoCounter9753.</strong></p><p>Generative AI is a tool, not a replacement. It’s like a trusty sidekick — smart, efficient, and occasionally prone to hilariously bad suggestions. Developers will always be needed to bring the spark of humanity to web projects and fix the inevitable AI-induced chaos. Plus, who’s going to debug the bots when they start writing poetic 404 pages?</p><h3>Embrace the Future (And Maybe Teach AI Some Manners)</h3><p>Generative AI is here to stay, and honestly, it’s kind of awesome. It’s like having a superpower that helps you work smarter, not harder. Just remember to keep your creativity, humor, and problem-solving skills sharp — because the bots might write the code, but it’s the humans who give it <strong><em>soul</em></strong>.</p><p>So, to all the web developers out there: raise your coffee mugs to the future! It’s bright, it’s exciting, and it’s probably written in JavaScript.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4c4c3693bd7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Infinite Scroll]]></title>
            <link>https://medium.com/@sudipb001/infinite-scroll-814d27437c8d?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/814d27437c8d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[infinite-scroll]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Mon, 02 Dec 2024 15:58:09 GMT</pubDate>
            <atom:updated>2024-12-02T15:58:09.750Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*w6_FI8KrmCEzlaKgdWeb-Q.png" /></figure><p>Sometimes we need infinite scroll for some specific web sites, eg., some posts. Here is a easier version of that infinite scroll. First create 3 files in your folder, viz, index.html, styles.css and script.js.</p><p>I recommend VSCode editor along with LiveServer extension for this small project.</p><p>Codes are as follows:</p><p>index.html:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;title&gt;Infinite Scroll&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot; /&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;header&gt;<br>      &lt;h1&gt;Infinite Scroll&lt;/h1&gt;<br>    &lt;/header&gt;<br>    &lt;main id=&quot;content&quot;&gt;<br>      &lt;!-- Content dynamically loaded here --&gt;<br>    &lt;/main&gt;<br>    &lt;footer&gt;<br>      &lt;p&gt;Scroll to load more content!&lt;/p&gt;<br>    &lt;/footer&gt;<br>    &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>styles.css:</p><pre>body {<br>  font-family: Arial, sans-serif;<br>  margin: 0;<br>  padding: 0;<br>}<br><br>header,<br>footer {<br>  text-align: center;<br>  padding: 1rem;<br>  background-color: #333;<br>  color: white;<br>}<br><br>main {<br>  max-width: 600px;<br>  margin: auto;<br>  padding: 1rem;<br>}<br><br>.post {<br>  margin-bottom: 1rem;<br>  padding: 1rem;<br>  background: #f4f4f4;<br>  border: 1px solid #ddd;<br>  border-radius: 5px;<br>  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);<br>}<br><br>footer {<br>  margin-top: 2rem;<br>  font-size: 0.9rem;<br>}</pre><p>script.js:</p><pre>const content = document.getElementById(&#39;content&#39;);<br><br>// Simulated API Data<br>let postCount = 1;<br><br>function createPost() {<br>  const post = document.createElement(&#39;div&#39;);<br>  post.classList.add(&#39;post&#39;);<br>  post.innerHTML = `&lt;h2&gt;Post #${postCount}&lt;/h2&gt;<br>                    &lt;p&gt;This is some content for post #${postCount}.&lt;/p&gt;`;<br>  postCount++;<br>  return post;<br>}<br><br>// Add multiple posts to the DOM<br>function loadPosts(number = 5) {<br>  for (let i = 0; i &lt; number; i++) {<br>    content.appendChild(createPost());<br>  }<br>}<br><br>// Check if user is near the bottom of the page<br>function isNearBottom() {<br>  return window.innerHeight + window.scrollY &gt;= document.body.offsetHeight - 100;<br>}<br><br>// Infinite Scroll Logic<br>window.addEventListener(&#39;scroll&#39;, () =&gt; {<br>  if (isNearBottom()) {<br>    loadPosts();<br>  }<br>});<br><br>// Initial Load<br>loadPosts();</pre><p>Now right-click on index.html file at the left pane and select “Open with Live-Server”.</p><p>Voila!!! Your infinite scroll is ready!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=814d27437c8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Garbage Collection in JavaScript]]></title>
            <link>https://medium.com/@sudipb001/understanding-garbage-collection-in-javascript-08cf4e2279d1?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/08cf4e2279d1</guid>
            <category><![CDATA[garbage-collection]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Sun, 01 Dec 2024 07:08:42 GMT</pubDate>
            <atom:updated>2024-12-01T07:08:42.725Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*OWeGjUAvDL1YDLPhNn3k_w.jpeg" /><figcaption>Photo by Thirdman : <a href="https://www.pexels.com/photo/a-man-holding-a-sack-of-garbage-7656998/">https://www.pexels.com/photo/a-man-holding-a-sack-of-garbage-7656998/</a></figcaption></figure><p>Garbage collection (GC) in JavaScript is a critical mechanism that ensures efficient memory management by automatically reclaiming memory that is no longer being used. Developers would need to manually allocate and free memory without garbage collection. This could lead to memory leaks or crashes.</p><h3>What is Garbage Collection?</h3><p>Garbage collection refers to the process of identifying and reclaiming memory which is occupied by objects that are no longer accessible or needed by the program. JavaScript’s runtime environment, most commonly the browser’s JavaScript engine (e.g., V8 in Chrome), handles this automatically.</p><h3>How Memory Works in JavaScript</h3><h3>1. Memory Allocation</h3><p>When you create variables, objects, or functions in JavaScript, the memory is allocated from the system’s resources. Here’s an example:</p><pre>let str = &quot;Hello, World!&quot;;<br>let obj = { name: &quot;Sudip&quot;, age: 30 };</pre><h3>2. Memory Use</h3><p>Memory is actively used as long as there are references to the allocated data. For example:</p><pre>let user = { name: &quot;Sudip&quot; }; // Memory is in use because &#39;user&#39; refers to the object</pre><h3>3. Memory Release</h3><p>When a reference to an object or variable is no longer accessible, it becomes eligible for garbage collection:</p><pre>user = null; // The object is now unreachable</pre><h3>Garbage Collection Algorithms</h3><p>JavaScript engines use various algorithms to determine which objects can be safely removed from memory. The two main algorithms are:</p><h3>1. Mark-and-Sweep</h3><p>The most common garbage collection algorithm is “mark-and-sweep.” Here’s how it works:</p><ul><li><strong>Mark Phase:</strong> The garbage collector starts at the root (e.g., window in browsers or global in Node.js) and marks all objects reachable from the root.</li><li><strong>Sweep Phase:</strong> Objects that are not marked are considered unreachable and their memory is reclaimed.</li></ul><p>Example:</p><pre>function example() {<br>    let localObj = { name: &quot;Temp&quot; };<br>    console.log(localObj.name);<br>}<br>// After the function finishes, &#39;localObj&#39; is no longer accessible and becomes garbage.</pre><h3>2. Reference Counting</h3><p>This older algorithm keeps track of the number of references to each object. When an object’s reference count drops to zero, it is garbage-collected. However, this method can lead to issues with <strong>circular references</strong>, which is why modern engines primarily use mark-and-sweep.</p><h3>Common Memory Issues</h3><h3>1. Memory Leaks</h3><p>A memory leak occurs when memory that is no longer needed is not reclaimed. Common causes include:</p><p><strong>Global Variables:</strong> Accidentally declaring variables globally can keep them in memory.</p><pre>function createLeak() {<br>    leakedVariable = &quot;I am global!&quot;;<br>}</pre><p><strong>Event Listeners:</strong> Not removing event listeners can retain references.</p><pre>element.addEventListener(&#39;click&#39;, handler);<br>// Failing to call element.removeEventListener can cause leaks</pre><p><strong>Closures:</strong> Nested functions that reference outer variables can cause memory to persist.</p><pre>function outer() {<br>    let data = &quot;Hello&quot;;<br>    return function inner() {<br>        console.log(data);<br>    };<br>}<br>let closure = outer();</pre><h3>2. Unreferenced Timers</h3><p>Timers that are not cleared will hold onto memory:</p><pre>let timer = setInterval(() =&gt; console.log(&quot;Running&quot;), 1000);<br>// Failing to call clearInterval(timer) will cause the interval to persist</pre><h3>Tips for Efficient Memory Management</h3><h3>1. Avoid Global Variables</h3><p>Use let, const, or var to limit variables to local scopes.</p><h3>2. Clear References Explicitly</h3><p>Set unused objects to null when they are no longer needed:</p><pre>let obj = { name: &quot;John&quot; };<br>obj = null; // Helps the garbage collector identify it as unreachable</pre><h3>3. Remove Event Listeners</h3><p>Always clean up event listeners when they are no longer needed:</p><pre>element.removeEventListener(&#39;click&#39;, handler);</pre><h3>4. Use WeakMaps and WeakSets</h3><p>For objects that are meant to be used temporarily without preventing garbage collection, use WeakMap or WeakSet:</p><pre>let weakMap = new WeakMap();<br>let obj = {};<br>weakMap.set(obj, &quot;value&quot;);<br>// When &#39;obj&#39; is no longer referenced, it will be garbage-collected</pre><h3>Debugging Memory Issues</h3><p>Modern browsers like Chrome and Firefox offer tools to monitor and debug memory usage:</p><ol><li><strong>Chrome DevTools:</strong></li></ol><ul><li>Open DevTools and navigate to the <strong>Memory</strong> tab.</li><li>Take a heap snapshot to inspect objects and detect leaks.</li></ul><ol><li><strong>Node.js:</strong></li></ol><ul><li>Use tools like node --inspect or packages like heapdump to analyze memory usage.</li></ul><h3>Final Words</h3><p>Garbage collection is a behind-the-scenes process. It makes JavaScript easier to work with by automating memory management. By understanding how it works and following best practices, you can write efficient code and avoid common pitfalls like memory leaks. For complex applications, using modern debugging tools can help maintain best performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08cf4e2279d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Closures in JavaScript]]></title>
            <link>https://medium.com/@sudipb001/closures-in-javascript-e44fe133c704?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/e44fe133c704</guid>
            <category><![CDATA[closure]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[closure-in-javascript]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Thu, 14 Nov 2024 12:08:34 GMT</pubDate>
            <atom:updated>2024-11-14T12:16:06.200Z</atom:updated>
            <content:encoded><![CDATA[<p>Closure is a feature in JavaScript which allows a function to <strong><em>remember </em></strong>the environment where it was created. Not only that, it remembers it even after the function finished its execution!!!</p><p>Technically speaking, it gives access to an outer function’s scope from the inner function even after outer function was executed!!!</p><p>Let’s try to find out <strong>how closures work</strong>.</p><p>Closures are created when a function has an inner function. And that inner function can access the variables of the outer function even after the outer function has finished its execution.</p><p>This feature also enables data encapsulation (like a Class) by hiding certain variables from the “<em>evil</em>” eyes of the other codes outside of the outer function.</p><p>OK, let’s have an example to clarify this.</p><pre>function outerFunc() {<br>  let outerVar = &#39;Hey, I am outside!&#39;;<br><br>  function innerFunc() {<br>    console.log(outerVar);<br>  }<br><br>  return innerFunc;<br>}<br><br>const closureFunc = outerFunc();<br>closureFunc(); // Output: &#39;Hey, I am outside!&#39;</pre><p>I don’t know about you, but let me explain it for myself, what I understood from this code snippet.</p><p>The <strong>outerFunc </strong>defines a variable, <strong>outerVar </strong>and then it creates (or “<strong>defines” </strong>for the technical guys like you) another function, named <strong>innerFunction</strong>. And this baby can access <strong>outerVar </strong>from its parent (ie, the good old <strong>outerFunc</strong>) .</p><p>This good old <strong>outerFunc </strong>returns its little baby, the <strong>innerFunc, </strong>which is stored in a constant variable called <strong>closureFunc</strong>.</p><p>When closureFunc is called, it still has access to outerVar, even though outerFunc has completed its life, just like a <strong><em>dead man walking</em></strong>!!!</p><p><strong><em>Okey, but is there any practical usage of those closures?</em></strong></p><p>Hmm, the first one which I can guess is <strong><em>data privacy</em></strong>!</p><pre>function createCounter() {<br>  let count = 0;<br>  return function() {<br>    count += 1;<br>    return count;<br>  };<br>}<br><br>const counter = createCounter();<br>console.log(counter()); // 1<br>console.log(counter()); // 2<br>console.log(counter()); // 3</pre><p>Here you (I mean your codes outside the <strong>createCounter </strong>function) can’t access the <strong>count </strong>variabble directly. Hmm, I can bet that you are now thinking about <strong><em>data encapsulation</em></strong>.</p><p>Have you heard about <strong><em>Function Factories</em></strong>? Yes, you can do this also using closures and even with parameters customized for you (I mean your codes)!</p><pre>function createGreeting(greeting) {<br>  return function(name) {<br>    return `${greeting}, ${name}!`;<br>  };<br>}<br><br>const sayHello = createGreeting(&#39;Hello&#39;);<br>console.log(sayHello(&#39;Sudip&#39;)); // Output: &quot;Hello, Sudip!&quot;<br><br>const sayHi = createGreeting(&#39;Hi&#39;);<br>console.log(sayHi(&#39;Patrick&#39;)); // Output: &quot;Hi, Patrick!&quot;</pre><p>Each call to <strong>createGreeting</strong> generates a closure that “<strong><em>remembers</em></strong>” the <strong>greeting</strong> variable passed in. Due to this, we call it a <strong><em>Function Factory</em></strong>!</p><p>What about <strong>Asynchronous Operations</strong>? Does our closure can retain the state of acynchronous codes? Let’s check.</p><pre>function delayedGreeting(name) {<br>  const greeting = `Hello, ${name}!`;<br>  setTimeout(() =&gt; console.log(greeting), 1000);<br>}<br><br>delayedGreeting(&#39;Sudip&#39;); // After 1 second: &quot;Hello, Sudip!&quot;</pre><p>See, like everybody, I love my name, Sudip. I am not hiding it at all. But after running this code snippet, I found it really retained my name (sorry, the <strong>greeting </strong>variable)!</p><p>Hope till now, you are with me and are not suffering from a headache. Then a big <strong>THANK </strong>to <strong>YOU </strong>for helping me to understand closures!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e44fe133c704" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sorting JavaScript array of objects using multiple keys:]]></title>
            <link>https://medium.com/@sudipb001/sorting-javascript-array-of-objects-using-multiple-keys-4a9be7be5f5a?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a9be7be5f5a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[sort]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Tue, 12 Nov 2024 13:55:11 GMT</pubDate>
            <atom:updated>2024-11-12T13:55:11.578Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oj-kK_dcwMP3BgpIM-t0NA.png" /></figure><p>When I started professional programming with JavaScript, I faced problem on how to sort an array of objects using multiple keys. As far as I can remember it was an array which stored Excel data.</p><p>It’s not an easy task to sort this array and it should be flexible (as the Excel file has multiple columns to sort). Finally I solved this problem by Array object’s sort() method documentation.</p><p>Here is a simple implementation of that function for the budding programmers.</p><p>Enjoy!</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;title&gt;Document&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Please view the console for sorted array output.&lt;/h1&gt;<br>    &lt;script&gt;<br>      const originalArray = [<br>        { name: &quot;Ram&quot;, age: 32 },<br>        { name: &quot;Shyam&quot;, age: 25 },<br>        { name: &quot;Jadu&quot;, age: 40 },<br>        { name: &quot;Ram&quot;, age: 20 },<br>      ]<br><br>      // Sort the array by multiple keys<br>      function sortByMultiKeys(arr, keys) {<br>        return arr.sort((x, y) =&gt; {<br>          for (let key of keys) {<br>            if (x[key] &lt; y[key]) return -1<br>            if (x[key] &gt; y[key]) return 1<br>          }<br>          return 0<br>        })<br>      }<br><br>      // Copy original array<br>      const copyOrgArr = [...originalArray]<br><br>      // Sorting by &#39;name&#39; and then &#39;age&#39;<br>      const sortedArray = sortByMultiKeys(copyOrgArr, [&quot;name&quot;, &quot;age&quot;])<br><br>      console.log(&quot;Original Array:&quot;, originalArray)<br>      console.log(&quot;Sorted Array (by name and age):&quot;, sortedArray)<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a9be7be5f5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tagged Templates in JavaScript]]></title>
            <link>https://medium.com/@sudipb001/tagged-templates-in-javascript-3e844a30202f?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e844a30202f</guid>
            <category><![CDATA[tagged-template-literals]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Mon, 11 Nov 2024 11:10:41 GMT</pubDate>
            <atom:updated>2024-11-11T11:22:07.805Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*RhcHcG6D6thKVxmaXoMVIw.png" /></figure><p><strong>Tagged templates</strong> are an advanced way to use <em>template literals</em> (those backtick-enclosed strings, like `Hello, ${name}!`) with a function.</p><p>With tagged templates, you can process and change template literals in a special way by using a function called a <strong>tag function</strong>.</p><p>Here’s how it works:</p><p><strong>Tag function basics</strong>: The tag function is a regular function, but it can take template literal values and modify them. The first argument to the tag function is an <em>array of strings</em> (parts of the literal). Any extra arguments are values from the expressions inside the template.</p><p><strong>What you can do with the tag function</strong>: Inside the tag function, you can use the strings and expression values however you want. You can return a new string, a number, an object, or something else entirely.</p><p><strong>Naming the tag function</strong>: You can name the tag function anything you like.</p><p>Here’s an example to help make this clearer:</p><pre>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;title&gt;Document&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;p&gt;User name: &lt;input type=&quot;text&quot; id=&quot;user&quot; /&gt;&lt;/p&gt;<br>    &lt;p&gt;Age: &lt;input type=&quot;number&quot; id=&quot;age&quot; /&gt;&lt;/p&gt;<br>    &lt;button onclick=&quot;addPara()&quot;&gt;Add new paragraph&lt;/button&gt;<br>    &lt;script&gt;<br>      function highlight(strings, ...values) {<br>        return strings.reduce(<br>          (result, str, i) =&gt;<br>            `${result}${str}&lt;strong&gt;${values[i] || &quot;&quot;}&lt;/strong&gt;`,<br>          &quot;&quot;<br>        )<br>      }<br><br>      function addPara() {<br>        const user = document.getElementById(&quot;user&quot;).value<br>        const age = document.getElementById(&quot;age&quot;).value<br>        const paragraph = document.createElement(&quot;p&quot;) // Create a &lt;p&gt; element<br>        paragraph.innerHTML = highlight`User: ${user}, Age: ${age}` // Set the html content<br>        document.body.appendChild(paragraph)<br>      }<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Thank you! :-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e844a30202f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regular Expression Generator]]></title>
            <link>https://medium.com/@sudipb001/regular-expression-generator-6c4b912d8594?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c4b912d8594</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Sun, 10 Nov 2024 09:38:35 GMT</pubDate>
            <atom:updated>2024-11-10T09:38:35.659Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*SFnlqGXOkDeHtXmG_RVJ7A.png" /></figure><p>Regular Expression is very important for any programming. But it’s hard to master. Here is a small code snippet created with HTML and JavaScript to generate Regular Expressions using some CheckBoxes and an Input control. Please note that this is a very simple and tiny project. I will be very happy if anyone will improve the project with more options.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot; /&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot; /&gt;<br>    &lt;title&gt;Regex Generator&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1&gt;Regular Expression Generator&lt;/h1&gt;<br><br>    &lt;form id=&quot;regexForm&quot;&gt;<br>      &lt;label&gt;<br>        Match digits:<br>        &lt;input type=&quot;checkbox&quot; id=&quot;digits&quot; /&gt; &lt;/label<br>      &gt;&lt;br /&gt;<br><br>      &lt;label&gt;<br>        Match lowercase letters:<br>        &lt;input type=&quot;checkbox&quot; id=&quot;lowercase&quot; /&gt; &lt;/label<br>      &gt;&lt;br /&gt;<br><br>      &lt;label&gt;<br>        Match uppercase letters:<br>        &lt;input type=&quot;checkbox&quot; id=&quot;uppercase&quot; /&gt; &lt;/label<br>      &gt;&lt;br /&gt;<br><br>      &lt;label&gt;<br>        Match special characters:<br>        &lt;input type=&quot;checkbox&quot; id=&quot;specialChars&quot; /&gt; &lt;/label<br>      &gt;&lt;br /&gt;<br><br>      &lt;label&gt;<br>        Length (optional):<br>        &lt;input type=&quot;number&quot; id=&quot;length&quot; min=&quot;1&quot; /&gt; &lt;/label<br>      &gt;&lt;br /&gt;&lt;br /&gt;<br><br>      &lt;button type=&quot;button&quot; onclick=&quot;generateRegex()&quot;&gt;Generate Regex&lt;/button&gt;<br>    &lt;/form&gt;<br><br>    &lt;h2&gt;Generated Regex:&lt;/h2&gt;<br>    &lt;p id=&quot;regexOutput&quot;&gt;&lt;/p&gt;<br><br>    &lt;script&gt;<br>      function generateRegex() {<br>        // Define the base components of the regex pattern<br>        let regexParts = &quot;[&quot; // Start the character set<br><br>        // Append specific character classes based on the form options<br>        if (document.getElementById(&quot;digits&quot;).checked) {<br>          regexParts += &quot;\\d&quot; // Digits<br>        }<br>        if (document.getElementById(&quot;lowercase&quot;).checked) {<br>          regexParts += &quot;a-z&quot; // Lowercase letters<br>        }<br>        if (document.getElementById(&quot;uppercase&quot;).checked) {<br>          regexParts += &quot;A-Z&quot; // Uppercase letters<br>        }<br>        if (document.getElementById(&quot;specialChars&quot;).checked) {<br>          regexParts += &quot;\\W&quot; // Non-word characters (special chars)<br>        }<br>        regexParts += &quot;]&quot; // End the character set<br><br>        // Get the length (if specified)<br>        const length = document.getElementById(&quot;length&quot;).value<br>        let quantifier = length ? `{${length}}` : &quot;+&quot; // Exact length or 1+ characters<br><br>        // Generate the final regex pattern<br>        const regexPattern = new RegExp(`^${regexParts}${quantifier}$`)<br><br>        // Display the result<br>        document.getElementById(&quot;regexOutput&quot;).innerText = regexPattern<br>      }<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><h3>Explanation of the code:</h3><p><strong>HTML Form</strong>: The form allows users to select criteria for the regex: digits, lowercase letters, uppercase letters, special characters, and an optional length for the match.</p><p><strong>JavaScript Function </strong><strong>generateRegex</strong>:</p><ul><li>Checks which options the user selected and builds the regular expression pattern accordingly.</li><li>Uses square brackets [] to denote a character class, and appends character classes (\d, a-z, etc.) based on selected options.</li><li>If the user specifies a length, it adds a quantifier {length}; otherwise, it defaults to + for matching one or more characters.</li></ul><p><strong>Display</strong>: The generated regex pattern is displayed on the page under “Generated Regex.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c4b912d8594" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Made Easy — From Basics to Brilliance. (Course Outline — 001)]]></title>
            <link>https://medium.com/@sudipb001/python-made-easy-from-basics-to-brilliance-course-outline-001-0827dfdf58d0?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/0827dfdf58d0</guid>
            <category><![CDATA[free-python-tutorials]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python3-tutorial]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 05:35:27 GMT</pubDate>
            <atom:updated>2024-11-05T05:35:27.083Z</atom:updated>
            <content:encoded><![CDATA[<h3>Python Made Easy — From Basics to Brilliance. (Course Outline — 001)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Gq4VEsiReJ6LHVZY_ji4tA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rubaitulazad?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Rubaitul Azad</a> on <a href="https://unsplash.com/photos/a-white-cube-with-a-yellow-and-blue-logo-on-it-ZIPFteu-R8k?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>I am a Senior Software Developer. I started programming professionally more than 32 years ago. Recently I learned Python by myself. I want to share my knowledge with all of you (free of cost). I want to create a Python course which will be helpful for everybody. Here is the outline of the course.</p><h3>1. Welcome and Course Introduction</h3><ul><li><strong>What to Expect</strong>: Overview of the course structure, goals, and how Python can empower learners in various fields.</li><li><strong>Setting Up</strong>: Guide on installing Python and setting up a development environment (Jupyter Notebooks, or VS Code).</li><li><strong>First Taste of Code</strong>: Running the classic “Hello, World!” program to kick off practical experience right away.</li></ul><h3>2. Python Fundamentals</h3><ul><li><strong>Understanding Variables and Data Types</strong>: Introduce numbers, strings, booleans, and lists, with interactive exercises to reinforce concepts.</li><li><strong>Basic Operators and Expressions</strong>: Arithmetic, assignment, comparison, and logical operators explained through playful, real-world examples.</li><li><strong>Control Flow</strong>: Decision-making with if statements, loops (for and while), and the use of break and continue.</li><li><strong>Mini Project</strong>: Building a simple number guessing game to consolidate fundamentals and make learning fun.</li></ul><h3>3. Functions and Modular Code</h3><ul><li><strong>What are Functions?</strong>: Explanation of function syntax, parameters, return values, and the importance of modular code.</li><li><strong>Scope and Lifetime</strong>: Exploring local vs. global variables with relatable scenarios.</li><li><strong>Error Handling</strong>: Introduction to try and except blocks to handle errors gracefully.</li><li><strong>Project</strong>: Create a basic calculator that can perform multiple operations, showcasing the power of functions.</li></ul><h3>4. Working with Data Structures</h3><ul><li><strong>Lists, Tuples, Sets, and Dictionaries</strong>: Explanation and comparison of each data structure, along with use cases.</li><li><strong>Manipulating Data</strong>: Adding, removing, and updating elements with examples that make each function memorable.</li><li><strong>Project</strong>: Build a simple contact book application that uses dictionaries to store names and numbers.</li></ul><h3>5. File Handling</h3><ul><li><strong>Reading and Writing Files</strong>: Teach the basics of reading from and writing to files.</li><li><strong>Working with CSVs and JSON</strong>: Parsing CSV and JSON files for more complex data handling.</li><li><strong>Project</strong>: Create a mini task manager that saves and loads tasks from a file, illustrating real-world applications.</li></ul><h3>6. Introduction to Object-Oriented Programming (OOP)</h3><ul><li><strong>Classes and Objects</strong>: Introduction to the concepts of classes, objects, and how they’re used in Python.</li><li><strong>Attributes and Methods</strong>: Show how to create attributes and methods, emphasizing the power of code organization.</li><li><strong>Inheritance and Polymorphism</strong>: Basics of extending classes and customizing behavior.</li><li><strong>Project</strong>: Design a simple library system where users can borrow and return books.</li></ul><h3>7. Essential Libraries and Modules</h3><ul><li><strong>Python’s Standard Library</strong>: Brief tour of essential modules (e.g., math, datetime, random).</li><li><strong>Data Analysis with Pandas</strong>: A beginner’s look at manipulating and analyzing data with Pandas.</li><li><strong>Plotting with Matplotlib</strong>: Introduction to data visualization, making learning fun with simple graphs and charts.</li><li><strong>Project</strong>: Create a basic data analysis script that plots a graph from sample data.</li></ul><h3>8. Working with APIs and Web Scraping</h3><ul><li><strong>Understanding APIs</strong>: Basics of RESTful APIs and how to make requests in Python.</li><li><strong>Parsing API Responses</strong>: Using JSON responses from APIs to interact with data.</li><li><strong>Intro to Web Scraping</strong>: Basics of BeautifulSoup and requests for beginner-friendly scraping (within legal and ethical boundaries).</li><li><strong>Project</strong>: Create a simple weather app that fetches and displays weather data from a free weather API.</li></ul><h3>9. Automation with Python</h3><ul><li><strong>Introduction to Automation</strong>: Explanation of scripting repetitive tasks with Python.</li><li><strong>Automating Everyday Tasks</strong>: Examples like renaming files, sending automated emails, and scheduling tasks.</li><li><strong>Project</strong>: Automate the generation of a report from a CSV file and send it via email.</li></ul><p>This outline serves as a general guide, but we may explore topics a bit differently as we go along. Our goal is to learn Python in a fun, engaging way. My focus will be on helping you develop a programmer’s mindset, which is crucial for solving real-world problems. Remember, consistent practice is the key to mastering any new language — so dive in and enjoy the journey.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0827dfdf58d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Dynamic Duo: Exploring Node.js and Express for Web Development in 2024]]></title>
            <link>https://medium.com/@sudipb001/the-dynamic-duo-exploring-node-js-and-express-for-web-development-in-2024-6c585e07eff3?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c585e07eff3</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Mon, 04 Nov 2024 09:42:01 GMT</pubDate>
            <atom:updated>2024-11-04T09:42:01.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Eckoh8WaB4pZhkO1Jd8QrA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@dkfra19?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Dimitri Karastelev</a> on <a href="https://unsplash.com/photos/a-close-up-of-a-network-switch-box-pl6My-v7gnE?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>Node.js and Express have been powering modern web applications for over a decade, transforming the way developers build backend services. Originally just a JavaScript runtime, Node.js evolved with Express to create a seamless platform for crafting server-side applications. Together, they offer simplicity, speed, and scalability — qualities that have made them essentials in web development. Let’s dive into what makes Node.js and Express so enjoyable to work with and why they remain popular in 2024.</p><h3>What Exactly is Node.js?</h3><p>Node.js was created in 2009 by Ryan Dahl, designed as a runtime to execute JavaScript on the server rather than in the browser. By using Google Chrome’s V8 engine, Node.js made it possible to run JavaScript code at blazing speeds, independent of the browser. Unlike traditional server languages like PHP or Java, Node.js uses a single-threaded, non-blocking architecture that’s highly efficient and well-suited for I/O-heavy tasks.</p><p>Think of it as an environment where JavaScript developers can extend their skills to the backend — creating powerful applications, real-time services, and data-driven systems using a language they already know and love.</p><h3>Enter Express: Node.js’s Best Friend</h3><p>Express, a minimal and flexible framework for Node.js, was introduced in 2010. Express is often described as “the unopinionated” framework, giving developers the freedom to structure their apps without enforcing strict rules. By simplifying and standardizing HTTP requests, routing, and middleware, Express lets you build robust applications quickly, with a foundation that’s easily customizable.</p><p>While Node.js provides the engine, Express gives developers a well-organized way to structure and serve HTTP responses, turning Node’s raw capabilities into a full-fledged web server with incredible ease.</p><h3>Why Node.js and Express Are Still Awesome in 2024</h3><p>Here’s why the Node-Express combo continues to hold a special place in the hearts of developers:</p><ol><li><strong>Speed and Efficiency</strong><br>Node.js’s non-blocking, event-driven architecture makes it particularly fast and efficient. For handling high volumes of simultaneous connections, Node.js shines, enabling performance-intensive applications like streaming services and real-time chat.</li><li><strong>Single Language for Full-Stack Development</strong><br>One of the main attractions of Node.js and Express is the ability to use JavaScript on both the front end and back end. This single-language approach reduces the cognitive load for developers and makes it easier to manage and share code across the stack.</li><li><strong>Vast Ecosystem of Libraries</strong><br>npm (Node Package Manager) offers a massive library of reusable code packages. Whether you need authentication, data validation, real-time messaging, or API integrations, there’s probably a npm package that does just that — making your development process faster and more enjoyable.</li><li><strong>Flexibility and Scalability</strong><br>Express is lightweight, so it doesn’t lock you into specific project structures or rules. This flexibility allows you to scale applications with your own architectural preferences, whether you’re creating a simple REST API, a single-page app (SPA), or a microservice.</li><li><strong>Active Community and Ongoing Improvements</strong><br>The Node.js and Express communities are vibrant and continuously improving. Node releases get updated with the latest JavaScript features, while Express remains simple and stable. Community support means you’re never alone when you run into a challenge; there’s always a tutorial, Stack Overflow thread, or GitHub repo that can help.</li></ol><h3>Getting Started with Node.js and Express</h3><p>To give you a taste of what it’s like to work with Node.js and Express, let’s walk through the setup for a basic Express app. Don’t worry if you’re new — one of the great things about this duo is how easy it is to start building right away!</p><h4>Step 1: Install Node.js and Initialize Your Project</h4><p>First, make sure you have <a href="https://nodejs.org/">Node.js installed</a>. Then, create a new project folder and initialize it:</p><pre>mkdir my-first-express-app<br>cd my-first-express-app<br>npm init -y</pre><h4>Step 2: Install Express</h4><p>Once your project is set up, install Express:</p><pre>npm install express</pre><p>This command will add Express to your project and create a node_modules folder with Express and its dependencies.</p><h4>Step 3: Set Up a Basic Express Server</h4><p>Create an index.js file with the following code:</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br>const port = 3000;<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello, World!&#39;);<br>});<br><br>app.listen(port, () =&gt; {<br>  console.log(`Server running at http://localhost:${port}`);<br>});</pre><p>Now, start your server:</p><pre>node index.js</pre><p>Open your browser, go to http://localhost:3000, and voilà! You should see “Hello, World!” displayed on your screen. In just a few lines, you’ve created a functioning server!</p><h4>Step 4: Adding Routes</h4><p>Adding new routes in Express is straightforward. Let’s expand the server by adding more endpoints:</p><pre>app.get(&#39;/about&#39;, (req, res) =&gt; {<br>  res.send(&#39;About Page&#39;);<br>});<br><br>app.get(&#39;/contact&#39;, (req, res) =&gt; {<br>  res.send(&#39;Contact Page&#39;);<br>});</pre><p>These routes let you customize responses to different URL paths. Want to add JSON responses for an API? Just replace res.send with res.json, and you’re ready to start serving data.</p><h3>Fun Features of Node.js and Express</h3><p>Here are some things that make Node.js and Express especially enjoyable:</p><p><strong>Middleware</strong><br>Express’s middleware functions add modularity to your application, allowing you to plug in features like logging, authentication, error handling, and more. Middleware functions are called sequentially, so you can chain them together to create sophisticated workflows with ease.</p><pre>const logger = (req, res, next) =&gt; {<br>  console.log(`Request made to: ${req.url}`);<br>  next();<br>};<br><br>app.use(logger);</pre><p><strong>Real-Time Capabilities</strong><br>Need real-time updates? With packages like socket.io, you can build a chat app or live update service in a matter of minutes. Node’s non-blocking nature makes it ideal for applications that require instant communication between the server and client.</p><p><strong>Working with Databases</strong><br>Node.js and Express work seamlessly with both SQL and NoSQL databases, from MySQL and PostgreSQL to MongoDB. Using libraries like mongoose or sequelize, you can handle complex queries and data models with minimal hassle.</p><p><strong>Error Handling Made Easy</strong><br>Handling errors gracefully is essential for user experience, and Express makes it easy to set up error-handling middleware. Simply add a function at the end of your middleware stack, and Express will use it to handle any errors that occur.</p><pre>app.use((err, req, res, next) =&gt; {<br>  console.error(err.stack);<br>  res.status(500).send(&#39;Something went wrong!&#39;);<br>});</pre><p><strong>API Development Simplified</strong><br>Express simplifies the process of building RESTful APIs. Its intuitive routing structure, middleware, and JSON handling make it an ideal choice for creating APIs that can power client applications on any platform.</p><h3>Building with Node.js and Express: An Experience, Not Just a Toolset</h3><p>Node.js and Express remain developer favorites because of their simplicity, performance, and flexibility. They offer an experience that’s empowering, allowing developers to create apps quickly without feeling restricted by rigid conventions. The ecosystem around Node and Express has only improved, and with continued community support, they’re well-equipped to handle the demands of modern web applications.</p><p>If you haven’t yet experienced Node.js and Express, there’s no better time than now. Whether you’re building your first REST API, creating a real-time chat app, or just experimenting, this dynamic duo makes backend development a smooth, satisfying experience.</p><p>So, fire up your terminal, start coding, and discover why Node.js and Express remain the ultimate power couple of web development in 2024.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c585e07eff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python Deep Copy and Shallow Copy: A Friendly Guide]]></title>
            <link>https://medium.com/@sudipb001/python-deep-copy-and-shallow-copy-a-friendly-guide-7edfaab5afb3?source=rss-bf3bcedd6068------2</link>
            <guid isPermaLink="false">https://medium.com/p/7edfaab5afb3</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Sudip Bhattacharyya]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 12:12:53 GMT</pubDate>
            <atom:updated>2024-11-02T12:12:53.532Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*3WlFkxqx_M8CGNtOF8bJFQ.jpeg" /><figcaption>Photo by Andrea Piacquadio at Pexels</figcaption></figure><p>In the world of Python, knowing the difference between <strong>shallow</strong> and <strong>deep copies</strong> can make your code cleaner and help avoid unexpected bugs. Whether you’re working with simple data structures or complex, nested lists and dictionaries, understanding copying is crucial. Let’s dive in!</p><h3>1. What is Copying in Python?</h3><p>In Python, copying is the process of creating a new variable that holds the same data as an existing one. However, this can happen in a few different ways. Sometimes, we end up referencing the original object (meaning changes to the new variable will affect the original data). Other times, we copy the data itself, so changes to the new object won’t impact the original.</p><p>Two main types of copying in Python are:</p><ul><li><strong>Shallow Copy</strong></li><li><strong>Deep Copy</strong></li></ul><p>Each one serves a different purpose, depending on the depth and structure of your data.</p><h3>2. Shallow Copy</h3><p>A <strong>shallow copy</strong> creates a new object but only “copies” references to the original items. Let’s look at a simple example:</p><pre>import copy<br><br># Original list with nested lists<br>original_list = [[1, 2, 3], [4, 5, 6]]<br>shallow_copied_list = copy.copy(original_list)</pre><p>Here, we use copy.copy() to create a shallow copy of original_list. Now, we have two lists:</p><ul><li>original_list</li><li>shallow_copied_list</li></ul><p>However, both lists <strong>point to the same inner lists</strong>. Changing elements within any nested lists in shallow_copied_list will affect original_list as well!</p><h3>Shallow Copy Example in Action</h3><pre># Modify the shallow copied list<br>shallow_copied_list[0][1] = &quot;Hello&quot;<br><br>print(&quot;Original List:&quot;, original_list) <br>print(&quot;Shallow Copied List:&quot;, shallow_copied_list)</pre><p>Output:</p><pre>Original List: [[1, &#39;Hello&#39;, 3], [4, 5, 6]]<br>Shallow Copied List: [[1, &#39;Hello&#39;, 3], [4, 5, 6]]</pre><p>Both lists show the change. This is because shallow_copied_list does not make a true “deep” copy of original_list. Only the references were copied.</p><h3>Shallow Copy Summary</h3><ul><li>Creates a new object.</li><li>Copies references to elements (only one level deep).</li><li>Modifying nested elements affects both the original and copied lists.</li></ul><h3>3. Deep Copy</h3><p>A <strong>deep copy</strong>, on the other hand, creates an entirely new object <strong>and recursively copies all nested objects</strong>. So, when you modify a nested element in the deep copy, the original remains unaffected.</p><p>To make a deep copy, use copy.deepcopy():</p><pre>deep_copied_list = copy.deepcopy(original_list)</pre><p>This time, deep_copied_list is an independent copy of original_list, even down to its nested elements. Changing any element in deep_copied_list won’t affect original_list.</p><h3>Deep Copy Example in Action</h3><pre># Modify the deep copied list<br>deep_copied_list[0][1] = &quot;Hello again&quot;<br><br>print(&quot;Original List:&quot;, original_list)<br>print(&quot;Deep Copied List:&quot;, deep_copied_list)</pre><p>Output:</p><pre>Original List: [[1, 2, 3], [4, 5, 6]]<br>Deep Copied List: [[1, &#39;Hello again&#39;, 3], [4, 5, 6]]</pre><p>Notice that only deep_copied_list has been changed. The original list remains unaffected, making deepcopy perfect for scenarios involving complex, nested data structures.</p><h3>Deep Copy Summary</h3><ul><li>Creates a new object.</li><li>Recursively copies all nested elements.</li><li>Modifying nested elements does NOT affect the original.</li></ul><h3>4. When to Use Shallow vs. Deep Copy</h3><p>Understanding when to use each is essential:</p><ol><li><strong>Shallow Copy</strong>: Use this when you have a simple data structure, or you don’t need to modify nested elements independently of the original. It’s faster and uses less memory.</li><li><strong>Deep Copy</strong>: Use this when working with complex, nested structures where you want to make changes without affecting the original data. It’s safer for nested data but requires more memory.</li></ol><h3>5. Important Considerations</h3><ul><li><strong>Immutable Objects</strong>: With objects like integers, strings, and tuples (which are immutable), shallow and deep copies behave the same way, as the values cannot change.</li><li><strong>Performance</strong>: Deep copies can be slower and memory-intensive for very large structures since they involve copying every nested element.</li></ul><p>Understanding shallow and deep copies in Python empowers you to handle data structures more effectively, letting you decide when to create copies that are either lightweight or fully independent. Just remember:</p><ul><li><strong>Shallow copy</strong> for light operations or non-nested structures.</li><li><strong>Deep copy</strong> when you need complete independence from the original data.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7edfaab5afb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>