<?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"><channel><title><![CDATA[Subhrangsu]]></title><description><![CDATA[Subhrangsu]]></description><link>https://blog.subhrangsu.in</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 17:49:17 GMT</lastBuildDate><atom:link href="https://blog.subhrangsu.in/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding the this Keyword in JavaScript]]></title><description><![CDATA[Comeing soon]]></description><link>https://blog.subhrangsu.in/understanding-the-this-keyword-in-javascript</link><guid isPermaLink="true">https://blog.subhrangsu.in/understanding-the-this-keyword-in-javascript</guid><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 26 Mar 2026 05:27:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69501e7828e1e24f5f1d7676/80955851-c7c2-4032-b62a-98ac8b252a61.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Comeing soon</p>
]]></content:encoded></item><item><title><![CDATA[Control Flow in JavaScript: If, Else, and Switch]]></title><description><![CDATA[In the previous blog of this JavaScript series, we explored JavaScript Operators: The Basics You Need to Know and learned how operators help us perform calculations, comparisons, and logical checks.
B]]></description><link>https://blog.subhrangsu.in/control-flow-in-javascript-if-else-and-switch</link><guid isPermaLink="true">https://blog.subhrangsu.in/control-flow-in-javascript-if-else-and-switch</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[node]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 05 Mar 2026 18:05:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69501e7828e1e24f5f1d7676/3325fd4e-3135-4b76-acf2-4e509eb8b7ed.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the <strong>previous blog of this JavaScript series</strong>, we explored <a href="https://subhrangsu.hashnode.dev/javascript-operators-the-basics-you-need-to-know"><strong>JavaScript Operators: The Basics You Need to Know</strong></a> and learned how operators help us perform calculations, comparisons, and logical checks.</p>
<p>But once we can <strong>compare values</strong>, the next question is:</p>
<blockquote>
<p>How does a program decide <strong>what code should run and what should not?</strong></p>
</blockquote>
<p>This is where <strong>control flow</strong> comes in.</p>
<p>Control flow allows a program to <strong>make decisions and execute different code depending on conditions</strong>.</p>
<p>Just like in real life, we make decisions based on situations.</p>
<p>For example:</p>
<ul>
<li><p>If it rains → take an umbrella</p>
</li>
<li><p>If you are hungry → eat food</p>
</li>
<li><p>If you finish work → relax</p>
</li>
</ul>
<p>Programs work in a similar way.</p>
<p>In this article, we will learn how JavaScript handles decisions using:</p>
<ul>
<li><p><code>if</code></p>
</li>
<li><p><code>if...else</code></p>
</li>
<li><p><code>else if</code></p>
</li>
<li><p><code>switch</code></p>
</li>
</ul>
<h2><strong>What is Control Flow?</strong></h2>
<p><strong>Control flow</strong> refers to the <strong>order in which statements are executed in a program</strong>.</p>
<p>Normally, JavaScript executes code <strong>line by line from top to bottom</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">console.log("Step 1");
console.log("Step 2");
console.log("Step 3");
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Step 1
Step 2
Step 3
</code></pre>
<p>But sometimes we want code to run <strong>only if a condition is true</strong>.</p>
<p>This is where <strong>conditional statements</strong> help us control the program flow.</p>
<h2><strong>The</strong> <code>if</code> <strong>Statement</strong></h2>
<p>The <code>if</code> <strong>statement</strong> runs a block of code <strong>only when a condition is true</strong>.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">if (condition) {
	// code to execute
}
</code></pre>
<h3><strong>Example</strong></h3>
<p>Let's check if someone is eligible to vote.</p>
<pre><code class="language-javascript">let age = 20;

if (age &gt;= 18) {
	console.log("You are eligible to vote.");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">You are eligible to vote.
</code></pre>
<p>Here:</p>
<pre><code class="language-plaintext">age &gt;= 18
</code></pre>
<p>If the condition is <strong>true</strong>, the code inside the block runs.</p>
<h2><strong>The</strong> <code>if...else</code> <strong>Statement</strong></h2>
<p>Sometimes we want to run <strong>one block of code if the condition is true and another if it is false</strong>.</p>
<p>This is where <code>if...else</code> is used.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">if (condition) {
	// runs if condition is true
} else {
	// runs if condition is false
}
</code></pre>
<h3><strong>Example</strong></h3>
<pre><code class="language-javascript">let age = 16;

if (age &gt;= 18) {
	console.log("You can vote.");
} else {
	console.log("You are too young to vote.");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">You are too young to vote.
</code></pre>
<p>In JavaScript, you don't always need a comparison operator like <code>age &gt;= 18</code>. JavaScript can evaluate any variable as a boolean. For example:</p>
<pre><code class="language-JavaScript">let username = "Alice";

if (username) {
    // This runs because a non-empty string is "truthy"
    console.log("Welcome, " + username);
}
</code></pre>
<h2><strong>The</strong> <code>else if</code> <strong>Ladder</strong></h2>
<p>Sometimes we need to check <strong>multiple conditions</strong>.</p>
<p>For that, we use <code>else if</code>.</p>
<h3><strong>Example: Checking Marks</strong></h3>
<pre><code class="language-javascript">let marks = 75;

if (marks &gt;= 90) {
	console.log("Grade: A");
} else if (marks &gt;= 70) {
	console.log("Grade: B");
} else if (marks &gt;= 50) {
	console.log("Grade: C");
} else {
	console.log("Fail");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Grade: B
</code></pre>
<p>The program checks conditions <strong>from top to bottom</strong>.</p>
<p>Once a condition is <strong>true</strong>, the rest are skipped.</p>
<img src="https://github.com/user-attachments/assets/082b9d2f-bc93-4f73-87f2-e9648a934af7" alt="if_else" style="display:block;margin:0 auto" />

<h2><strong>Example Program: Positive, Negative, or Zero</strong></h2>
<p>Let’s write a simple program to determine the type of a number.</p>
<pre><code class="language-javascript">let number = -5;

if (number &gt; 0) {
	console.log("Positive number");
} else if (number &lt; 0) {
	console.log("Negative number");
} else {
	console.log("The number is zero");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Negative number
</code></pre>
<p>Here we used an <strong>if–else if ladder</strong> because we had <strong>multiple possible conditions</strong>.</p>
<h2><strong>The</strong> <code>switch</code> <strong>Statement</strong></h2>
<p>The <code>switch</code> <strong>statement</strong> is used when we want to compare <strong>one value against multiple possible cases</strong>.</p>
<h3><strong>Syntax</strong></h3>
<pre><code class="language-javascript">switch (expression) {
	case value1:
		// code
		break;

	case value2:
		// code
		break;

	default:
	// code
}
</code></pre>
<h2><strong>Example: Day of the Week</strong></h2>
<pre><code class="language-javascript">let day = 3;

switch (day) {
	case 1:
		console.log("Monday");
		break;

	case 2:
		console.log("Tuesday");
		break;

	case 3:
		console.log("Wednesday");
		break;

	case 4:
		console.log("Thursday");
		break;

	case 5:
		console.log("Friday");
		break;

	case 6:
		console.log("Saturday");
		break;

	case 7:
		console.log("Sunday");
		break;

	default:
		console.log("Invalid day");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Wednesday
</code></pre>
<img src="https://github.com/user-attachments/assets/800b578c-a0f4-4c68-943a-4e5183fb3318" alt="switch" style="display:block;margin:0 auto" />

<h2><strong>Why</strong> <code>break</code> <strong>is Important</strong></h2>
<p>Inside a <code>switch</code>, the <code>break</code> <strong>statement stops execution</strong>.</p>
<p>Without <code>break</code>, JavaScript will continue running the next cases.</p>
<p>Example without break:</p>
<pre><code class="language-javascript">let day = 1;

switch (day) {
	case 1:
		console.log("Monday");

	case 2:
		console.log("Tuesday");

	case 3:
		console.log("Wednesday");
}
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Monday
Tuesday
Wednesday
</code></pre>
<p>This happens because <strong>switch keeps executing cases until it finds a break</strong>.</p>
<h2><strong>When to Use</strong> <code>switch</code> <strong>vs</strong> <code>if...else</code></h2>
<table>
<thead>
<tr>
<th>Situation</th>
<th>Recommended</th>
</tr>
</thead>
<tbody><tr>
<td>Checking ranges (age, marks, numbers)</td>
<td><code>if...else</code></td>
</tr>
<tr>
<td>Comparing one value with many fixed options</td>
<td><code>switch</code></td>
</tr>
</tbody></table>
<p>Example:</p>
<pre><code class="language-plaintext">marks &gt; 80 → if-else
day = Monday/Tuesday/Wednesday → switch
</code></pre>
<h2><strong>Final Thoughts</strong></h2>
<p>Control flow is what makes programs <strong>smart and dynamic</strong>.</p>
<p>Using <code>if</code>, <code>else</code>, <code>else if</code>, and <code>switch</code>, we can make our programs:</p>
<ul>
<li><p>Take decisions</p>
</li>
<li><p>Handle multiple conditions</p>
</li>
<li><p>Execute different logic based on data</p>
</li>
</ul>
<p>These concepts are used <strong>everywhere in real applications</strong>.</p>
<p>In the next article of this JavaScript series, we will explore another important concept that allows programs to <strong>repeat tasks automatically</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[JavaScript Operators: The Basics You Need to Know]]></title><description><![CDATA[In the previous blog of this JavaScript series, we learned about Variables and Data Types — how JavaScript stores information.
Now the next question is:

How do we actually work with those values?

Th]]></description><link>https://blog.subhrangsu.in/javascript-operators-the-basics-you-need-to-know</link><guid isPermaLink="true">https://blog.subhrangsu.in/javascript-operators-the-basics-you-need-to-know</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[node]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 05 Mar 2026 17:50:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69501e7828e1e24f5f1d7676/e6bd13e8-2859-4fd7-bed0-b52234443eb1.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the <strong>previous blog of this JavaScript series</strong>, we learned about <a href="https://subhrangsu.hashnode.dev/understanding-variables-and-data-types"><strong>Variables and Data Types</strong></a> — how JavaScript stores information.</p>
<p>Now the next question is:</p>
<blockquote>
<p>How do we actually <strong>work with those values?</strong></p>
</blockquote>
<p>That’s where <strong>operators</strong> come in.</p>
<p>Operators allow us to <strong>perform calculations, compare values, and create logic in our programs</strong>. They are a fundamental part of writing any JavaScript code.</p>
<p>In this article, we'll explore the most common operators you will use every day.</p>
<img src="https://github.com/user-attachments/assets/ca83f532-6d1c-4809-a6b0-eb49fc879e31" alt="operator-categories" style="display:block;margin:0 auto" />

<p>JavaScript operators can be grouped into several categories such as arithmetic, comparison, logical, and assignment operators.</p>
<h2><strong>What Are Operators?</strong></h2>
<p>An <strong>operator</strong> is a symbol that performs an operation on values or variables.</p>
<p>For example:</p>
<pre><code class="language-javascript">let a = 10;
let b = 5;

let result = a + b;

console.log(result);
</code></pre>
<p>Here:</p>
<pre><code class="language-plaintext">+  → is an operator
a and b → are operands
</code></pre>
<p>The operator <strong>combines values to produce a result</strong>.</p>
<h2><strong>Arithmetic Operators</strong></h2>
<p>Arithmetic operators are used to perform <strong>basic mathematical calculations</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Description</th>
</tr>
</thead>
<tbody><tr>
<td><code>+</code></td>
<td>Addition</td>
</tr>
<tr>
<td><code>-</code></td>
<td>Subtraction</td>
</tr>
<tr>
<td><code>*</code></td>
<td>Multiplication</td>
</tr>
<tr>
<td><code>/</code></td>
<td>Division</td>
</tr>
<tr>
<td><code>%</code></td>
<td>Modulus (remainder)</td>
</tr>
</tbody></table>
<h3><strong>Example</strong></h3>
<pre><code class="language-javascript">let a = 10;
let b = 3;

console.log("Addition:", a + b);
console.log("Subtraction:", a - b);
console.log("Multiplication:", a * b);
console.log("Division:", a / b);
console.log("Remainder:", a % b);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Addition: 13
Subtraction: 7
Multiplication: 30
Division: 3.3333
Remainder: 1
</code></pre>
<p>The <strong>modulus operator</strong> <code>%</code> is commonly used when checking <strong>even or odd numbers</strong>.</p>
<p>Example:</p>
<pre><code class="language-javascript">let number = 10;

console.log(number % 2);
</code></pre>
<p>If the result is <code>0</code>, the number is <strong>even</strong>.</p>
<h2><strong>Comparison Operators</strong></h2>
<p>Comparison operators allow us to <strong>compare two values</strong>.</p>
<p>They always return <strong>true or false</strong>.</p>
<table>
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><code>==</code></td>
<td>Equal</td>
</tr>
<tr>
<td><code>===</code></td>
<td>Strict equal</td>
</tr>
<tr>
<td><code>!=</code></td>
<td>Not equal</td>
</tr>
<tr>
<td><code>&gt;</code></td>
<td>Greater than</td>
</tr>
<tr>
<td><code>&lt;</code></td>
<td>Less than</td>
</tr>
</tbody></table>
<h3><strong>Example</strong></h3>
<pre><code class="language-javascript">let a = 10;
let b = 5;

console.log(a &gt; b);
console.log(a &lt; b);
console.log(a == b);
console.log(a != b);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
false
false
true
</code></pre>
<h2><strong>Difference Between</strong> <code>==</code> <strong>and</strong> <code>===</code></h2>
<p>This is one of the <strong>most important things to understand in JavaScript</strong>.</p>
<h3><code>==</code> <strong>(Loose Equality)</strong></h3>
<p><code>==</code> compares values <strong>after converting the type if necessary</strong>.</p>
<pre><code class="language-javascript">console.log(5 == "5");
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
</code></pre>
<p>Because JavaScript converts <code>"5"</code> to a number.</p>
<h3><code>===</code> <strong>(Strict Equality)</strong></h3>
<p><code>===</code> compares <strong>both value and type</strong>.</p>
<pre><code class="language-javascript">console.log(5 === "5");
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">false
</code></pre>
<p>Because:</p>
<pre><code class="language-plaintext">5 → number
"5" → string
</code></pre>
<p>Different types → result is <code>false</code>.</p>
<p><strong>Best Practice</strong></p>
<p>Most developers prefer using <code>===</code> because it avoids unexpected type conversions.</p>
<h2><strong>Logical Operators</strong></h2>
<p>Logical operators help us <strong>combine multiple conditions</strong>.</p>
<img src="https://github.com/user-attachments/assets/f1369bbb-871b-4c12-b626-d4bdde4e9a92" alt="logical-truth-table" style="display:block;margin:0 auto" />

<table>
<thead>
<tr>
<th>Operator</th>
<th>Meaning</th>
</tr>
</thead>
<tbody><tr>
<td><code>&amp;&amp;</code></td>
<td>AND</td>
</tr>
<tr>
<td>`</td>
<td></td>
</tr>
<tr>
<td><code>!</code></td>
<td>NOT</td>
</tr>
</tbody></table>
<h3><strong>AND Operator</strong> <code>&amp;&amp;</code></h3>
<p>Both conditions must be <strong>true</strong>.</p>
<pre><code class="language-javascript">let age = 20;

console.log(age &gt; 18 &amp;&amp; age &lt; 30);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
</code></pre>
<h3><strong>OR Operator</strong> <code>||</code></h3>
<p>At least <strong>one condition must be true</strong>.</p>
<pre><code class="language-javascript">let age = 16;

console.log(age &lt; 18 || age &gt; 60);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
</code></pre>
<h3><strong>NOT Operator</strong> <code>!</code></h3>
<p>Reverses the result.</p>
<pre><code class="language-javascript">let isLoggedIn = false;

console.log(!isLoggedIn);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
</code></pre>
<h2><strong>Final Thoughts</strong></h2>
<p>Operators are one of the <strong>most fundamental parts of JavaScript</strong>.</p>
<p>They allow us to:</p>
<ul>
<li><p>Perform calculations</p>
</li>
<li><p>Compare values</p>
</li>
<li><p>Build logical conditions</p>
</li>
<li><p>Update variable values</p>
</li>
</ul>
<p>Once you become comfortable with operators, writing real programs becomes much easier.</p>
<p>In the <strong>next article of this JavaScript series</strong>, we’ll explore another core concept that helps control how our programs run.</p>
<p>If you're learning JavaScript, keep practicing small examples in the console. That’s the fastest way to build confidence.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Variables and Data Types in JavaScript]]></title><description><![CDATA[If you're starting your JavaScript journey, one of the first concepts you'll encounter is Variables and Data Types.
They are the foundation of everything in programming — from storing a user's name to]]></description><link>https://blog.subhrangsu.in/understanding-variables-and-data-types</link><guid isPermaLink="true">https://blog.subhrangsu.in/understanding-variables-and-data-types</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[Cohort2026]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Wed, 04 Mar 2026 21:58:34 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69501e7828e1e24f5f1d7676/0be2a0cf-4476-4d01-83d3-c5db986d7a1c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If you're starting your JavaScript journey, one of the first concepts you'll encounter is <strong>Variables and Data Types</strong>.</p>
<p>They are the foundation of everything in programming — from storing a user's name to handling complex application state.</p>
<p>In this guide, we'll break down:</p>
<ul>
<li><p>What variables are</p>
</li>
<li><p>How <code>var</code>, <code>let</code>, and <code>const</code> work</p>
</li>
<li><p>JavaScript primitive data types</p>
</li>
<li><p>How JavaScript stores and copies values</p>
</li>
</ul>
<p>All explained with <strong>simple examples and real code outputs</strong>.</p>
<p>So, let's start...</p>
<p>Imagine you are moving into a brand-new house. You have a truckload of items: furniture, clothes, kitchen gadgets, and some very fragile family heirlooms. To stay sane, you don’t just throw everything into the middle of the living room. You use <strong>boxes</strong>, and more importantly, you <strong>label</strong> them.</p>
<p>In the world of JavaScript, <strong>Variables</strong> are those labeled boxes, and <strong>Data Types</strong> are the specific items you put inside them. Understanding how to use these boxes correctly is the first step to becoming a master architect of the web.</p>
<h2>1. The Labeled Boxes: What are Variables?</h2>
<p>In programming, variables are containers used for storing data values. They allow us to give a name to a piece of information so we can refer to it, move it around, or change it later in our code.</p>
<h3>Example</h3>
<pre><code class="language-javascript">let userName = "Subhrangsu";
let age = 25;
let isDeveloper = true;

console.log(userName);
console.log(age);
console.log(isDeveloper);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Subhrangsu
25
true
</code></pre>
<p>Here:</p>
<ul>
<li><p><code>userName</code> → stores a <strong>string</strong></p>
</li>
<li><p><code>age</code> → stores a <strong>number</strong></p>
</li>
<li><p><code>isDeveloper</code> → stores a <strong>boolean</strong></p>
</li>
</ul>
<h2>The Rules of the Label (Naming Conventions)</h2>
<p>Before you start labeling your boxes, JavaScript has a few rules you must follow.</p>
<h3>Case Sensitivity</h3>
<pre><code class="language-javascript">let myVariable = "Hello";
let myvariable = "World";

console.log(myVariable);
console.log(myvariable);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Hello
World
</code></pre>
<p>These are <strong>two different variables</strong>.</p>
<h3>Characters Allowed</h3>
<pre><code class="language-javascript">let user_name = "Subhrangsu";
let $price = 100;
let _count = 10;

console.log(user_name, $price, _count);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Subhrangsu 100 10
</code></pre>
<p><strong>Note:</strong> Reserved keywords cannot be used as variable names.</p>
<h3>The Pro Tip: camelCase</h3>
<pre><code class="language-javascript">let isUserLoggedIn = true;
let totalPriceOfItems = 250;

console.log(isUserLoggedIn);
console.log(totalPriceOfItems);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
250
</code></pre>
<p>This naming style improves readability.</p>
<h2>2. Meet the Three Label Makers: <code>var</code>, <code>let</code>, and <code>const</code></h2>
<p>Not all labels are created equal. Depending on which label you use, your variable behaves differently.</p>
<h3>The Old Reliable: <code>var</code></h3>
<p>The traditional method, <code>var</code>, is <strong>function-scoped</strong>. If declared outside a function, it becomes <strong>global</strong>.</p>
<pre><code class="language-javascript">var city = "Kolkata";

console.log(city);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Kolkata
</code></pre>
<p>But <code>var</code> has a problem — it ignores block scope.</p>
<p>Example:</p>
<pre><code class="language-javascript">if (true) {
	var hobby = "Coding";
}

console.log(hobby);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Coding
</code></pre>
<p>Even though it was declared inside the block, it is still accessible outside.</p>
<h3>The Modern Standard: <code>let</code></h3>
<p>Introduced in 2015 (ES6), Introduced in ES6 (2015), <code>let</code> is used for variables whose values may change. It is block-scoped, meaning the variable only exists within the specific set of curly braces {} where you created it.</p>
<pre><code class="language-javascript">let age = 30;

console.log(age);

age = 31;

console.log(age);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">30
31
</code></pre>
<p>Example with block scope:</p>
<pre><code class="language-javascript">if (true) {
	let message = "Hello";
	console.log(message);
}

console.log(message);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Hello
ReferenceError: message is not defined
</code></pre>
<p>If a variable is declared but not assigned a value, JavaScript automatically assigns <code>undefined</code>.</p>
<pre><code class="language-js">let a;
console.log(a); // undefined

a = 45;
console.log(a); // 45
</code></pre>
<h3>The Permanent Vault: <code>const</code></h3>
<p><code>const</code> is for constants. Once you assign a value to a <code>const</code> box, you cannot reassign it to something else. It is also block-scoped.</p>
<p><em>Important nuance:</em> While you cannot reassign the entire object or array stored in a <code>const</code> variable, you can still modify the values inside it.</p>
<pre><code class="language-javascript">const myCity = "New York";

console.log(myCity);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">New York
</code></pre>
<p>Trying to change it:</p>
<pre><code class="language-javascript">const myCity = "New York";

myCity = "London";
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">TypeError: Assignment to constant variable
</code></pre>
<h3>Important Nuance with Objects</h3>
<pre><code class="language-javascript">const hero = {
	name: "Spider-Man",
	city: "New York",
};

hero.name = "Iron Man";

console.log(hero);
</code></pre>
<p>Output</p>
<pre><code class="language-shell">{ name: 'Iron Man', city: 'New York' }
</code></pre>
<p>You <strong>cannot replace the object</strong>, but you <strong>can modify its properties</strong>.</p>
<h2>3. What is Scope? (Your Variable's Neighborhood)</h2>
<p>Scope is the context in which a variable is visible.</p>
<h3>Global Scope</h3>
<pre><code class="language-javascript">let greeting = "Hello World";

function showMessage() {
	console.log(greeting);
}

showMessage();
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Hello World
</code></pre>
<p>The variable is accessible everywhere.</p>
<h3>Local / Block Scope</h3>
<pre><code class="language-javascript">function testScope() {
	let secret = "Hidden Message";
	console.log(secret);
}

testScope();

console.log(secret);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Hidden Message
ReferenceError: secret is not defined
</code></pre>
<p>The variable only exists <strong>inside the function</strong>.</p>
<h2>4. Understanding Data Types: What’s in the Box?</h2>
<p>JavaScript data types are generally divided into two categories:</p>
<ol>
<li><p>Primitive</p>
</li>
<li><p>Non-Primitive</p>
</li>
</ol>
<h3>Primitive Data Types</h3>
<p>Primitive values are <strong>immutable</strong>, meaning their values cannot be changed once created. This means operations on primitive values always produce a new value rather than modifying the original one.</p>
<h3>String</h3>
<pre><code class="language-javascript">let name = "Subhrangsu";

console.log(name);
console.log(typeof name);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Subhrangsu
string
</code></pre>
<h3>Number</h3>
<pre><code class="language-javascript">let age = 25;
let price = 199.99;

console.log(age);
console.log(typeof age);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">25
number
</code></pre>
<h3>Boolean</h3>
<pre><code class="language-javascript">let isStudent = true;

console.log(isStudent);
console.log(typeof isStudent);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">true
boolean
</code></pre>
<h3>Null</h3>
<pre><code class="language-javascript">let weatherCondition = null;

console.log(weatherCondition);
console.log(typeof weatherCondition);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">null
object
</code></pre>
<p>Note: <code>typeof null</code> returns <code>"object"</code> due to a historical bug in JavaScript that has been kept for backward compatibility.</p>
<h3>Undefined</h3>
<pre><code class="language-javascript">let userInput;

console.log(userInput);
console.log(typeof userInput);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">undefined
undefined
</code></pre>
<h3>Symbol</h3>
<pre><code class="language-javascript">const uniqueId = Symbol("user");

console.log(uniqueId);
console.log(typeof uniqueId);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Symbol(user)
symbol
</code></pre>
<h3>BigInt</h3>
<pre><code class="language-javascript">const bigNumber = 9007199254740991n;

console.log(bigNumber);
console.log(typeof bigNumber);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">9007199254740991n
bigint
</code></pre>
<h2>Checking the Type with <code>typeof</code></h2>
<pre><code class="language-javascript">console.log(typeof "Hello");
console.log(typeof 42);
console.log(typeof true);
console.log(typeof null);
console.log(typeof undefined);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">string
number
boolean
object
undefined
</code></pre>
<h2>5. Copying Values: The Beginner's Trap</h2>
<p>Understanding how JavaScript copies values is very important because it affects how data behaves when assigned to another variable.</p>
<h3>Primitive → Copy by Value</h3>
<pre><code class="language-javascript">let hero = "Batman";
let copiedHero = hero;

copiedHero = "Superman";

console.log(hero);
console.log(copiedHero);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">Batman
Superman
</code></pre>
<p>They are <strong>independent copies</strong>.</p>
<h3>Objects → Copy by Reference</h3>
<pre><code class="language-javascript">let heroStats = { strength: 80 };

let copiedStats = heroStats;

copiedStats.strength = 100;

console.log(heroStats);
console.log(copiedStats);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">{ strength: 100 }
{ strength: 100 }
</code></pre>
<p>Both variables point to the <strong>same object in memory</strong>.</p>
<h3>Deep Copy Example</h3>
<pre><code class="language-javascript">let original = { power: 50 };

let clone = { ...original };
clone.power = 90;

console.log(original);
console.log(clone);
</code></pre>
<p>Output</p>
<pre><code class="language-plaintext">{ power: 50 }
{ power: 90 }
</code></pre>
<p>Now they are <strong>independent objects</strong>. For simple objects, the spread operator can be used. For deep nested objects, <code>structuredClone()</code> is safer.</p>
<h2>6. Practical Lab: Observe the Behavior</h2>
<pre><code class="language-javascript">const studentName = "Subhrangsu";
let studentAge = 25;
let isGraduated = false;

console.log("Name:", studentName, "| Type:", typeof studentName);
console.log("Age:", studentAge, "| Type:", typeof studentAge);

// studentName = "Subha"
// TypeError: Assignment to constant variable.

studentAge = 26;

console.log("New Age:", studentAge);

let graduationYear = null;

console.log("Graduation Year:", graduationYear);
</code></pre>
<p>Output</p>
<pre><code class="language-shell">Name: Subhrangsu | Type: string
Age: 25 | Type: number
New Age: 26
Graduation Year: null
</code></pre>
<h2>Summary Checklist</h2>
<img src="https://github.com/user-attachments/assets/de5c47cc-ded7-42d1-ba59-820452d5f4e9" alt="var_let_const" style="display:block;margin:0 auto" />

<h2>Final Thoughts</h2>
<p>Variables and data types are the building blocks of JavaScript.</p>
<p>Every program — from simple scripts to large applications — relies on variables to store and manipulate data.</p>
<p>Key takeaways:</p>
<ul>
<li><p>Use <code>const</code> by default</p>
</li>
<li><p>Use <code>let</code> when values need to change</p>
</li>
<li><p>Avoid <code>var</code> in modern JavaScript</p>
</li>
<li><p>Understand primitive vs reference types</p>
</li>
</ul>
<p>Once you're comfortable with these concepts, you can move on to operators, conditions, and functions in JavaScript.</p>
<h2>Deepen Your Learning</h2>
<p>For the full code examples used in this blog:</p>
<ol>
<li><p><strong>Exploring Variables</strong> <a href="https://github.com/Subhrangsu90/JavaScript/blob/master/js-basics/02-variables.js">variables.js</a></p>
</li>
<li><p><strong>Mastering Data Types</strong> <a href="https://github.com/Subhrangsu90/JavaScript/blob/master/js-basics/03-datatypes.js">datatypes.js</a></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[JavaScript Promises — Office Chai Edition (States, Methods & Event Loop)]]></title><description><![CDATA[JavaScript Promises are one of the most misunderstood yet essential features in modern JavaScript development.
Most articles explain the syntax.
Very few explain:

Why Promises exist

How they actuall]]></description><link>https://blog.subhrangsu.in/javascript-promises</link><guid isPermaLink="true">https://blog.subhrangsu.in/javascript-promises</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[promises]]></category><category><![CDATA[Cohort2026]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Sun, 01 Mar 2026 10:13:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/69501e7828e1e24f5f1d7676/e40ea8ab-5b50-426d-b088-e6ce0e20fe78.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>JavaScript Promises are one of the most misunderstood yet essential features in modern JavaScript development.</p>
<p>Most articles explain the syntax.</p>
<p>Very few explain:</p>
<ul>
<li><p>Why Promises exist</p>
</li>
<li><p>How they actually behave internally</p>
</li>
<li><p>Why <code>.then()</code> doesn’t run immediately</p>
</li>
<li><p>How microtasks change execution order</p>
</li>
</ul>
<p>So let’s break it down properly.</p>
<p>And to make it memorable, we’ll use something every startup developer understands:</p>
<p>☕ <strong>The 4:30 PM Office Chai Break</strong></p>
<h2>What Is a Promise — Really?</h2>
<p>A <strong>Promise</strong> represents the eventual result of an asynchronous operation. It’s a placeholder for a value that will exist in the future.</p>
<p>That means:</p>
<ul>
<li><p>A Promise starts in <strong>pending</strong></p>
</li>
<li><p>It becomes <strong>fulfilled</strong> (success) or <strong>rejected</strong> (failure)</p>
</li>
<li><p>Once settled, it never changes again</p>
</li>
</ul>
<p>Think of it like ordering chai at work.</p>
<p>You don’t get tea immediately. You get a commitment that tea will arrive later.</p>
<p>Or maybe it won’t.</p>
<p>That’s a Promise.</p>
<h2>☕ The Startup Office Chai Scenario</h2>
<p>It’s 4:30 PM.</p>
<p>Sprint is heavy. Production bug open. Everyone tired.</p>
<p>Someone says:</p>
<blockquote>
<p>“Bhai, chai order karo.”</p>
</blockquote>
<p>You place the order.</p>
<pre><code class="language-js">const chaiOrder = new Promise((resolve, reject) =&gt; {
	setTimeout(() =&gt; resolve("☕ Chai Arrived!"), 3000);
});

console.log(chaiOrder);
</code></pre>
<p>At this moment:</p>
<pre><code class="language-shell">Promise { &lt;pending&gt; }
</code></pre>
<p>The chai is <strong>pending</strong>.</p>
<p>Not here yet. But expected.</p>
<h2>Promise States — Office Meaning</h2>
<table>
<thead>
<tr>
<th>Promise State</th>
<th>Office Reality</th>
</tr>
</thead>
<tbody><tr>
<td><code>pending</code></td>
<td>Chai being prepared</td>
</tr>
<tr>
<td><code>fulfilled</code></td>
<td>Chai delivered</td>
</tr>
<tr>
<td><code>rejected</code></td>
<td>Chai wala cancelled</td>
</tr>
<tr>
<td><code>settled</code></td>
<td>Final outcome decided</td>
</tr>
</tbody></table>
<p>Important insight:</p>
<p>Even if the Promise resolves immediately, <code>.then()</code> still won’t execute instantly.</p>
<p>It gets queued.</p>
<p>That’s where microtasks enter the story.</p>
<h3><code>.then()</code> — When Chai Finally Arrives</h3>
<pre><code class="language-js">chaiOrder.then((message) =&gt; {
	console.log(message);
});
</code></pre>
<p>Meaning:</p>
<blockquote>
<p>“Notify me when chai arrives.”</p>
</blockquote>
<p>But here’s the deeper truth:</p>
<p>Even if the Promise resolves instantly, <code>.then()</code> runs <strong>after the current call stack clears</strong>.</p>
<p>This is because Promise callbacks are queued as <strong>microtasks</strong>.</p>
<p>They don’t interrupt running code.</p>
<p>They wait politely.</p>
<h3><code>.catch()</code> — Handling Rejection</h3>
<pre><code class="language-js">chaiOrder.catch(() =&gt; {
	console.log("No chai today 😭");
});
</code></pre>
<p>If chai doesn’t arrive, you handle the failure gracefully.</p>
<p>Without <code>.catch()</code>, rejected Promises can cause unhandled errors.</p>
<p>In production systems, that’s dangerous.</p>
<h3><code>.finally()</code> — Break Over Either Way</h3>
<pre><code class="language-js">chaiOrder.finally(() =&gt; {
	console.log("Back to debugging 🧑‍💻");
});
</code></pre>
<p>Whether chai arrived or not, break time ends.</p>
<p><code>.finally()</code> always runs after settlement.</p>
<h2>Now Let’s Order Multiple Things (Static Methods)</h2>
<p>Because one chai is never enough.</p>
<h3><code>Promise.all()</code> — Full Snacks or Nothing</h3>
<pre><code class="language-js">function orderChai() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("☕ Chai ready"), 2000);
	);
}

function orderSamosa() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("🥟 Samosa ready"), 1500),
	);
}

function orderBiscuit() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("🍪 Biscuit ready"), 1000),
	);
}

Promise.all([orderChai(), orderSamosa(), orderBiscuit()])
	.then((items) =&gt; {
		console.log("Break Started:", items);
	})
	.catch((error) =&gt; {
		console.log("Break Failed:", error);
	});
</code></pre>
<p>Output:</p>
<pre><code class="language-code">Break Started: [
  '☕ Chai ready',
  '🥟 Samosa ready',
  '🍪 Biscuit ready'
]
</code></pre>
<p>This returns a single Promise that:</p>
<ul>
<li><p>Fulfills when <strong>all input promises fulfill</strong> with array of the fulfillment values</p>
</li>
<li><p>Rejects immediately when <strong>any one rejects</strong></p>
</li>
</ul>
<p>Office logic:</p>
<blockquote>
<p>“Break tabhi jab chai + samosa + biscuit sab aaye.”</p>
</blockquote>
<p>If even one fails, the whole break fails.</p>
<p>Use when:</p>
<ul>
<li><p>All API calls are required</p>
</li>
<li><p>All resources must load</p>
</li>
<li><p>Deployment depends on everything</p>
</li>
</ul>
<h3><code>Promise.race()</code> — Fastest Wins</h3>
<pre><code class="language-js">function chai() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("☕ Chai arrived"), 2000),
	);
}

function coffee() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("☕ Coffee arrived"), 1000),
	);
}

Promise.race([chai(), coffee()]).then((result) =&gt;
	console.log("First Item:", result),
);
</code></pre>
<p>Output:</p>
<pre><code class="language-code">First Item: ☕ Coffee arrived
</code></pre>
<p>Returns a Promise that settles with the first settled input Promise.</p>
<p>It does not care whether that result is success or failure.</p>
<p>Office logic:</p>
<blockquote>
<p>Whoever arrives first decides mood.</p>
</blockquote>
<p>Used for:</p>
<ul>
<li><p>Timeout patterns</p>
</li>
<li><p>Competing APIs</p>
</li>
<li><p>Fastest response logic</p>
</li>
</ul>
<h3><code>Promise.any()</code> — First Success Wins</h3>
<pre><code class="language-js">function failedOrder() {
	return new Promise((_, reject) =&gt;
		setTimeout(() =&gt; reject("Out of stock"), 1000),
	);
}

function successfulOrder() {
	return new Promise((resolve) =&gt;
		setTimeout(() =&gt; resolve("☕ Chai delivered"), 2000),
	);
}

Promise.any([failedOrder(), successfulOrder()])
	.then((result) =&gt; console.log("Success:", result))
	.catch((err) =&gt; console.log(err));
</code></pre>
<p>Output:</p>
<pre><code class="language-code">Success: ☕ Chai delivered
</code></pre>
<ul>
<li><p>Fulfills when <strong>any promise fulfills</strong></p>
</li>
<li><p>Rejects only if <strong>all promises reject</strong></p>
</li>
<li><p>Returns <code>AggregateError</code> if all fail</p>
</li>
</ul>
<p>Office logic:</p>
<blockquote>
<p>“Kuch bhi caffeine mil jaaye.”</p>
</blockquote>
<p>Failures ignored unless everyone fails.</p>
<p>Perfect for fallback strategies where at least one success is enough.</p>
<h3><code>Promise.allSettled()</code> — Manager Wants Full Report</h3>
<pre><code class="language-js">const orders = [
	Promise.resolve("☕ Chai ready"),
	Promise.reject("❌ Biscuit unavailable"),
	Promise.resolve("🥟 Samosa ready"),
];

Promise.allSettled(orders).then((results) =&gt; {
	console.log(results);
});
</code></pre>
<p>Always fulfills with an array of result objects:</p>
<pre><code class="language-js">[
	{ status: "fulfilled", value: "☕ Chai ready" },
	{ status: "rejected", reason: "❌ Biscuit unavailable" },
	{ status: "fulfilled", value: "🥟 Samosa ready" },
];
</code></pre>
<p>Office logic:</p>
<p>The manager wants a full sprint report.</p>
<p>Never rejects. Always returns structured results.</p>
<p>Ideal for dashboards and logging.</p>
<h2>Advanced Promise Utilities — Hidden Power Tools</h2>
<p>Now let’s explore less commonly used but powerful Promise utilities.</p>
<h3><code>Promise.resolve()</code> — Instant Chai</h3>
<pre><code class="language-js">const readyChai = Promise.resolve("☕ Instant chai");

readyChai.then(console.log);
</code></pre>
<p>Output:</p>
<pre><code class="language-code">☕ Instant chai
</code></pre>
<p>Creates an already fulfilled Promise.</p>
<p>Office analogy:</p>
<blockquote>
<p>Chai already on your desk.</p>
</blockquote>
<p>But if you pass a thenable:</p>
<pre><code class="language-js">const thenable = {
	then(resolve) {
		resolve("Followed thenable result");
	},
};

Promise.resolve(thenable).then(console.log);
</code></pre>
<p>It will <em>follow</em> that Promise’s state.</p>
<p>Meaning:</p>
<ul>
<li><p>If it resolves → it resolves</p>
</li>
<li><p>If it rejects → it rejects</p>
</li>
</ul>
<p>This is called <strong>Promise assimilation</strong>.</p>
<h3><code>Promise.reject()</code> — Instant Cancellation</h3>
<pre><code class="language-js">Promise.reject("❌ Order cancelled").catch((error) =&gt; console.log(error));
</code></pre>
<p>Creates an already rejected Promise.</p>
<p>Useful for:</p>
<ul>
<li><p>Failing fast</p>
</li>
<li><p>Input validation</p>
</li>
<li><p>Early exit in async logic</p>
</li>
</ul>
<p>Office analogy:</p>
<blockquote>
<p>Chai wala immediately says no.</p>
</blockquote>
<h3><code>Promise.try()</code> (Non-standard Utility) — Normalize Sync and Async</h3>
<pre><code class="language-js">Promise.try(() =&gt; {
	throw new Error("Something went wrong");
}).catch((err) =&gt; console.log(err.message));
</code></pre>
<p>Wraps any function:</p>
<ul>
<li><p>If it returns value → resolved</p>
</li>
<li><p>If it throws → rejected</p>
</li>
<li><p>If it returns Promise → followed</p>
</li>
</ul>
<p>Office analogy:</p>
<blockquote>
<p>You safely handle unpredictable chaiwala behavior.</p>
</blockquote>
<p>It unifies sync and async error handling.</p>
<h3><code>Promise.withResolvers()</code> — Manual Control Room</h3>
<pre><code class="language-js">const { promise, resolve, reject } = Promise.withResolvers();

promise.then(console.log).catch(console.error);

setTimeout(() =&gt; {
	resolve("☕ Chai approved!");
}, 2000);
</code></pre>
<p>Returns:</p>
<ul>
<li><p>A new Promise</p>
</li>
<li><p>Its resolve function</p>
</li>
<li><p>Its reject function</p>
</li>
</ul>
<p>Separately.</p>
<p>Example:</p>
<pre><code class="language-js">const { promise, resolve } = Promise.withResolvers();

setTimeout(() =&gt; resolve("☕ Delivered"), 2000);

promise.then(console.log);
</code></pre>
<p>Office analogy:</p>
<blockquote>
<p>You hold the “Approve” and “Cancel” buttons yourself.</p>
</blockquote>
<p>Useful for:</p>
<ul>
<li><p>Event systems</p>
</li>
<li><p>Deferred patterns</p>
</li>
<li><p>Framework internals</p>
</li>
<li><p>State machines</p>
</li>
</ul>
<h2>How Promise Chaining Actually Flows</h2>
<p>Before we dive into the event loop, let’s visualize how Promise chaining creates new Promises and propagates fulfillment or rejection through the chain.</p>
<img src="https://github.com/user-attachments/assets/713fad45-912e-4b9a-ad9d-2bdea6306e72" alt="promise-flow" style="display:block;margin:0 auto" />

<p><em>How Promise fulfillment, rejection, and chaining return a new Promise in the async workflow.</em></p>
<h2>The Real Magic — Microtasks &amp; Execution Order</h2>
<p>Consider this:</p>
<pre><code class="language-js">setTimeout(() =&gt; console.log("Timeout"), 0);

Promise.resolve().then(() =&gt; console.log("Promise"));

console.log("I am Hero");
</code></pre>
<h3>Output</h3>
<pre><code class="language-plaintext">I am Hero      ← synchronous
Promise        ← microtask
Timeout        ← task
</code></pre>
<p>Even though the timeout delay is <code>0</code>.</p>
<p>Why?</p>
<p>Because JavaScript always executes in this priority order:</p>
<ol>
<li><p><strong>Synchronous code (call stack)</strong></p>
</li>
<li><p><strong>Microtasks (Promise callbacks)</strong></p>
</li>
<li><p><strong>Tasks / macrotasks (setTimeout, setInterval, etc.)</strong></p>
</li>
</ol>
<p><code>console.log("I am Hero")</code> runs first because it is synchronous — it executes immediately in the call stack before JavaScript even looks at any queues.</p>
<p><code>Promise.resolve().then()</code> goes to the <strong>microtask queue</strong>, which has higher priority than the task queue.</p>
<p><code>setTimeout()</code> goes to the <strong>task queue</strong>, which runs only after all microtasks are cleared.</p>
<p>So the final order becomes:</p>
<pre><code class="language-plaintext">I am Hero
Promise
Timeout
</code></pre>
<h3>Office Analogy</h3>
<ul>
<li><p><strong>Call Stack</strong> → Developer’s desk</p>
</li>
<li><p><strong>Microtask Queue</strong> → High-priority Slack notifications</p>
</li>
<li><p><strong>Task Queue</strong> → Normal emails</p>
</li>
<li><p><strong>Event Loop</strong> → Office manager</p>
</li>
</ul>
<p>Work already on the desk is done first. Slack messages are handled next. Emails are checked afterward.</p>
<p>That’s why Promises feel “faster” — they’re just processed with higher priority.</p>
<p>JavaScript stops feeling magical. And starts feeling architectural.</p>
<h2>References</h2>
<ul>
<li><p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">MDN Web Docs — Promise API</a></p>
</li>
<li><p><a href="https://www.joshwcomeau.com/javascript/promises/">Promises Deep Dive by Joshw Comeau</a></p>
</li>
<li><p>Concepts further reinforced through JavaScript Promise sessions from Cohort 2026 by Hitesh Choudhary.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[CSS Selectors 101: Targeting Elements with Precision (Advanced Guide)]]></title><description><![CDATA[CSS is not about colors and fonts.
CSS is about selecting the right elements and applying the right rules to them.
If you understand selectors deeply, you gain control over layouts, components, responsiveness, and performance. If you don’t — CSS feel...]]></description><link>https://blog.subhrangsu.in/css-selectors-101-targeting-elements-with-precision-advanced-guide</link><guid isPermaLink="true">https://blog.subhrangsu.in/css-selectors-101-targeting-elements-with-precision-advanced-guide</guid><category><![CDATA[CSS]]></category><category><![CDATA[CSS3]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[HTML5]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 21:29:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769722032319/8366281b-5e34-4ba5-90d4-890f64f19155.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>CSS is not about colors and fonts.</p>
<p>CSS is about <strong>selecting the right elements</strong> and applying the right rules to them.</p>
<p>If you understand selectors deeply, you gain control over layouts, components, responsiveness, and performance. If you don’t — CSS feels random and frustrating.</p>
<p>Let’s go beyond basics and build a strong mental model.</p>
<hr />
<h2 id="heading-why-css-selectors-exist-the-real-problem-they-solve">Why CSS Selectors Exist (The Real Problem They Solve)</h2>
<p>HTML creates structure.</p>
<p>CSS styles that structure.</p>
<p>But the browser needs answers to two questions:</p>
<ol>
<li>Which elements should be styled?</li>
<li>Which rule wins if multiple rules apply?</li>
</ol>
<p>Selectors solve the first problem.</p>
<p>Specificity and cascade solve the second.</p>
<p>Without selectors, CSS would be blind.</p>
<hr />
<h2 id="heading-think-of-selectors-as-querying-the-dom">Think of Selectors as Querying the DOM</h2>
<p>When CSS runs, the browser is basically doing this:</p>
<blockquote>
<p>“Find all elements that match this pattern.”</p>
</blockquote>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">p</span>
</code></pre>
<p>Means:</p>
<ul>
<li>Find all <code>p</code> tags</li>
<li>That are inside elements with class <code>card</code></li>
</ul>
<p>This is similar to searching inside a tree structure (DOM).</p>
<p>Understanding this mental model makes advanced selectors easier.</p>
<hr />
<h2 id="heading-element-selector-global-styling-tool">Element Selector (Global Styling Tool)</h2>
<p>Element selectors apply styles <strong>globally</strong> to all matching tags.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
    <span class="hljs-attribute">line-height</span>: <span class="hljs-number">1.6</span>;
}
</code></pre>
<p>This affects every paragraph on the page.</p>
<h3 id="heading-when-to-use">When to Use</h3>
<ul>
<li>Base typography</li>
<li>Default spacing</li>
<li>Consistent layout rules</li>
</ul>
<h3 id="heading-when-to-avoid">When to Avoid</h3>
<ul>
<li>Component-specific styling</li>
<li>UI variations</li>
</ul>
<p>Because element selectors are broad and can cause unwanted side effects.</p>
<hr />
<h2 id="heading-class-selector-component-level-control">Class Selector (Component-Level Control)</h2>
<p>Classes are the backbone of modern CSS architecture.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> {
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">16px</span>;
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">8px</span>;
}
</code></pre>
<h3 id="heading-why-classes-are-preferred">Why Classes Are Preferred</h3>
<p>Classes:</p>
<ul>
<li>Are reusable</li>
<li>Are predictable</li>
<li>Scale well in large projects</li>
<li>Work well with component systems</li>
</ul>
<p>Frameworks like React, Angular, and Vue rely heavily on class-based styling.</p>
<hr />
<h2 id="heading-id-selector-high-specificity-tool">ID Selector (High Specificity Tool)</h2>
<p>ID selectors target one unique element.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-id">#navbar</span> {
    <span class="hljs-attribute">position</span>: fixed;
}
</code></pre>
<h3 id="heading-important-reality">Important Reality</h3>
<p>IDs have very high specificity.</p>
<p>This means:</p>
<ul>
<li>They override many other rules</li>
<li>They are hard to override later</li>
</ul>
<h3 id="heading-best-practice">Best Practice</h3>
<p>Use IDs:</p>
<ul>
<li>For JavaScript targeting</li>
<li>For anchors</li>
<li>Rarely for styling</li>
</ul>
<p>Modern CSS avoids IDs for layout styling because they reduce flexibility.</p>
<hr />
<h2 id="heading-group-selectors-reducing-duplication">Group Selectors (Reducing Duplication)</h2>
<p>Group selectors help you avoid repeating CSS rules.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span>,
<span class="hljs-selector-tag">h2</span>,
<span class="hljs-selector-tag">h3</span> {
    <span class="hljs-attribute">font-family</span>: sans-serif;
}
</code></pre>
<h3 id="heading-why-this-matters">Why This Matters</h3>
<p>In production:</p>
<ul>
<li>Less CSS duplication</li>
<li>Smaller bundle size</li>
<li>Easier maintenance</li>
</ul>
<p>Grouping is simple but powerful.</p>
<hr />
<h2 id="heading-descendant-selectors-context-aware-styling">Descendant Selectors (Context-Aware Styling)</h2>
<p>Descendant selectors allow <strong>context-based styling</strong>.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.sidebar</span> <span class="hljs-selector-tag">p</span> {
    <span class="hljs-attribute">color</span>: gray;
}
</code></pre>
<p>This means:</p>
<ul>
<li>Only paragraphs inside <code>.sidebar</code> are affected</li>
</ul>
<h3 id="heading-this-enables-component-isolation">This Enables Component Isolation</h3>
<p>You can style the same element differently in different areas.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">button</span> {
    <span class="hljs-attribute">background</span>: blue;
}

<span class="hljs-selector-class">.modal</span> <span class="hljs-selector-tag">button</span> {
    <span class="hljs-attribute">background</span>: red;
}
</code></pre>
<p>Same <code>button</code> tag — different context.</p>
<hr />
<h2 id="heading-direct-child-selector-more-precision">Direct Child Selector (More Precision)</h2>
<p>Descendant selectors match all nested children.</p>
<p>But sometimes you want <strong>only direct children</strong>.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.container</span> &gt; <span class="hljs-selector-tag">p</span> {
    <span class="hljs-attribute">color</span>: green;
}
</code></pre>
<p>This selects:</p>
<ul>
<li>Only <code>p</code> elements directly inside <code>.container</code></li>
<li>Not deeply nested ones</li>
</ul>
<p>This improves predictability and performance.</p>
<hr />
<h2 id="heading-attribute-selectors-targeting-by-properties">Attribute Selectors (Targeting by Properties)</h2>
<p>You can select elements based on attributes.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">input</span><span class="hljs-selector-attr">[type=<span class="hljs-string">"text"</span>]</span> {
    <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid black;
}
</code></pre>
<p>This targets:</p>
<ul>
<li>Only text input fields</li>
</ul>
<p>Useful for:</p>
<ul>
<li>Forms</li>
<li>Buttons</li>
<li>Validation styling</li>
</ul>
<hr />
<h2 id="heading-understanding-selector-priority-specificity">Understanding Selector Priority (Specificity)</h2>
<p>When multiple selectors target the same element, CSS follows priority rules.</p>
<h3 id="heading-specificity-order-high-low">Specificity Order (High → Low)</h3>
<pre><code>Inline styles
↓
ID selectors
↓
Class / Attribute / Pseudo-<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">selectors</span>
↓
<span class="hljs-title">Element</span> <span class="hljs-title">selectors</span></span>
</code></pre><hr />
<h3 id="heading-example">Example</h3>
<p>CSS:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">p</span> {
    <span class="hljs-attribute">color</span>: blue;
}

<span class="hljs-selector-class">.text</span> {
    <span class="hljs-attribute">color</span>: green;
}

<span class="hljs-selector-id">#main</span> {
    <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<p>HTML:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>
    <span class="hljs-attr">id</span>=<span class="hljs-string">"main"</span>
    <span class="hljs-attr">class</span>=<span class="hljs-string">"text"</span>&gt;</span>
    Hello
<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<h3 id="heading-final-color">Final Color?</h3>
<p>Red.</p>
<p>Because ID selector wins.</p>
<hr />
<h2 id="heading-why-over-specific-selectors-are-dangerous">Why Over-Specific Selectors Are Dangerous</h2>
<p>This is a common beginner mistake:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">body</span> <span class="hljs-selector-class">.container</span> <span class="hljs-selector-class">.card</span> <span class="hljs-selector-class">.title</span> <span class="hljs-selector-tag">span</span> {
    <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<p>Problems:</p>
<ul>
<li>Hard to override</li>
<li>Hard to maintain</li>
<li>Breaks component reuse</li>
<li>Creates “CSS wars”</li>
</ul>
<h3 id="heading-better-approach">Better Approach</h3>
<p>Keep selectors:</p>
<ul>
<li>Short</li>
<li>Flat</li>
<li>Class-based</li>
</ul>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card-title</span> {
    <span class="hljs-attribute">color</span>: red;
}
</code></pre>
<hr />
<h2 id="heading-performance-consideration-yes-selectors-matter">Performance Consideration (Yes, Selectors Matter)</h2>
<p>Browsers match selectors from <strong>right to left</strong>.</p>
<p>This means:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.card</span> <span class="hljs-selector-tag">p</span> <span class="hljs-selector-tag">span</span>
</code></pre>
<p>Browser checks:</p>
<ul>
<li>span first</li>
<li>then parent p</li>
<li>then parent card</li>
</ul>
<p>Deep selectors increase work.</p>
<h3 id="heading-best-practice-1">Best Practice</h3>
<p>Prefer:</p>
<ul>
<li>Class selectors</li>
<li>Short selector chains</li>
<li>Component-based naming</li>
</ul>
<hr />
<h2 id="heading-before-and-after-real-example">Before and After (Real Example)</h2>
<h3 id="heading-html">HTML</h3>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"profile"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span>User<span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Developer<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-weak-css">Weak CSS</h3>
<pre><code class="lang-css"><span class="hljs-selector-tag">div</span> <span class="hljs-selector-tag">h2</span> {
    <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<p>Too generic.</p>
<hr />
<h3 id="heading-strong-css">Strong CSS</h3>
<pre><code class="lang-css"><span class="hljs-selector-class">.profile-title</span> {
    <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<p>Clear, reusable, predictable.</p>
<hr />
<h2 id="heading-why-selectors-are-the-foundation-of-css-architecture">Why Selectors Are the Foundation of CSS Architecture</h2>
<p>Modern CSS systems like:</p>
<ul>
<li>BEM</li>
<li>Utility-first CSS</li>
<li>Component styling</li>
<li>Design systems</li>
</ul>
<p>All depend on good selector strategy.</p>
<p>If your selectors are bad:</p>
<ul>
<li>Styling breaks</li>
<li>Debugging becomes painful</li>
<li>Scaling becomes impossible</li>
</ul>
<p>Selectors are not syntax — they are <strong>design decisions</strong>.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>CSS selectors are not just “ways to choose elements”.</p>
<p>They define:</p>
<ul>
<li>Maintainability</li>
<li>Performance</li>
<li>Scalability</li>
<li>Team collaboration</li>
</ul>
<p>Master these first:</p>
<ul>
<li>Element</li>
<li>Class</li>
<li>Descendant</li>
<li>Group</li>
<li>Attribute</li>
<li>Specificity basics</li>
</ul>
<p>Once these are solid, advanced CSS becomes much easier.</p>
]]></content:encoded></item><item><title><![CDATA[Emmet for HTML: A Beginner’s Guide to Writing Faster Markup]]></title><description><![CDATA[Let’s be honest.
Writing HTML like this again and again feels slow and repetitive:
<div class="card">
    <h1></h1>
    <p></p>
</div>

Now imagine writing one short line and getting all of this instantly.
That’s exactly what Emmet does.
Emmet is one...]]></description><link>https://blog.subhrangsu.in/emmet-for-html-a-beginners-guide-to-writing-faster-markup</link><guid isPermaLink="true">https://blog.subhrangsu.in/emmet-for-html-a-beginners-guide-to-writing-faster-markup</guid><category><![CDATA[HTML5]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[Emmet]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 21:16:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769721112609/367bbdb1-c4e8-4ac0-b1c1-4f7a8106be72.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s be honest.</p>
<p>Writing HTML like this again and again feels slow and repetitive:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Now imagine writing <strong>one short line</strong> and getting all of this instantly.</p>
<p>That’s exactly what <strong>Emmet</strong> does.</p>
<p>Emmet is one of the most powerful productivity tools for web developers — especially beginners learning HTML.</p>
<p>Let’s understand it step by step.</p>
<hr />
<h2 id="heading-what-is-emmet-in-very-simple-terms">What Is Emmet? (In Very Simple Terms)</h2>
<p><strong>Emmet is a shortcut language for writing HTML faster.</strong></p>
<p>Instead of typing full HTML tags manually, you write short abbreviations and let your code editor expand them into complete markup.</p>
<p>Think of Emmet as:</p>
<blockquote>
<p>Auto-complete on steroids for HTML.</p>
</blockquote>
<hr />
<h2 id="heading-why-emmet-is-useful-for-html-beginners">Why Emmet Is Useful for HTML Beginners</h2>
<p>When you are learning HTML, you already have many things to remember:</p>
<ul>
<li>Tags</li>
<li>Structure</li>
<li>Nesting</li>
<li>Attributes</li>
<li>Indentation</li>
</ul>
<p>Emmet helps you:</p>
<p>✅ Write less code
✅ Avoid typing mistakes
✅ Focus on structure
✅ Build layouts faster
✅ Practice HTML patterns</p>
<p>It saves time and keeps you motivated.</p>
<hr />
<h2 id="heading-how-emmet-works-inside-code-editors">How Emmet Works Inside Code Editors</h2>
<p>Emmet is built into most modern editors.</p>
<p>It works out of the box in:</p>
<ul>
<li>VS Code (recommended)</li>
<li>Sublime Text</li>
<li>Atom</li>
<li>WebStorm</li>
</ul>
<h3 id="heading-how-it-works">How It Works</h3>
<ol>
<li>You type an abbreviation</li>
<li>Press <strong>Tab</strong> or <strong>Enter</strong></li>
<li>Emmet expands it into HTML</li>
</ol>
<p>That’s it.</p>
<p>No installation needed in VS Code.</p>
<hr />
<h2 id="heading-basic-emmet-syntax-the-foundation">Basic Emmet Syntax (The Foundation)</h2>
<p>Let’s start small.</p>
<hr />
<h3 id="heading-creating-an-html-element">Creating an HTML Element</h3>
<p>Type this:</p>
<pre><code>p
</code></pre><p>Press Tab 👇</p>
<p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<hr />
<p>Another example:</p>
<pre><code>h1
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>You just created tags without typing angle brackets.</p>
<hr />
<h2 id="heading-adding-classes-ids-and-attributes">Adding Classes, IDs, and Attributes</h2>
<p>Now let’s make it more useful.</p>
<hr />
<h3 id="heading-adding-a-class">Adding a Class</h3>
<p>Use dot <code>.</code></p>
<pre><code>div.container
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"container"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-adding-an-id">Adding an ID</h3>
<p>Use hash <code>#</code></p>
<pre><code>section#hero
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">section</span> <span class="hljs-attr">id</span>=<span class="hljs-string">"hero"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-adding-attributes">Adding Attributes</h3>
<p>Use square brackets <code>[ ]</code></p>
<pre><code>img[src=<span class="hljs-string">"cat.jpg"</span> alt=<span class="hljs-string">"Cute Cat"</span>]
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span>
    <span class="hljs-attr">src</span>=<span class="hljs-string">"cat.jpg"</span>
    <span class="hljs-attr">alt</span>=<span class="hljs-string">"Cute Cat"</span> /&gt;</span>
</code></pre>
<p>Perfect for images and inputs.</p>
<hr />
<h2 id="heading-creating-nested-elements">Creating Nested Elements</h2>
<p>Real HTML is not flat — it’s nested.</p>
<p>Emmet makes nesting very easy using <code>&gt;</code>.</p>
<hr />
<h3 id="heading-example">Example</h3>
<pre><code>div&gt;p
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-deeper-nesting">Deeper Nesting</h3>
<pre><code>div&gt;ul&gt;li
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>You just created a structure in one line.</p>
<hr />
<h2 id="heading-repeating-elements-using-multiplication">Repeating Elements Using Multiplication</h2>
<p>Often we create multiple similar elements.</p>
<p>Emmet uses <code>*</code> for repetition.</p>
<hr />
<h3 id="heading-example-1">Example</h3>
<pre><code>li*<span class="hljs-number">3</span>
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-nested-repetition">Nested Repetition</h3>
<pre><code>ul&gt;li*<span class="hljs-number">4</span>
</code></pre><p><strong>Output:</strong></p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">ul</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">li</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">li</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">ul</span>&gt;</span>
</code></pre>
<p>Great for lists, cards, menus, grids.</p>
<hr />
<h2 id="heading-combining-everything-real-example">Combining Everything (Real Example)</h2>
<p>Let’s create a card layout.</p>
<h3 id="heading-emmet-input">Emmet Input:</h3>
<pre><code>div.card&gt;h2+p+button
</code></pre><h3 id="heading-output">Output:</h3>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"card"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">h2</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">h2</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">button</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<p>Readable. Clean. Fast.</p>
<hr />
<h2 id="heading-generating-full-html-boilerplate-with-emmet">Generating Full HTML Boilerplate with Emmet</h2>
<p>This is one of the most popular Emmet shortcuts.</p>
<p>Type:</p>
<pre><code>!
</code></pre><p>Press Tab.</p>
<hr />
<h3 id="heading-output-1">Output:</h3>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">"en"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">"UTF-8"</span> /&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>Document<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Your entire HTML page setup is ready in seconds.</p>
<p>This alone saves huge time daily.</p>
<hr />
<h2 id="heading-side-by-side-example-how-emmet-helps">Side-by-Side Example (How Emmet Helps)</h2>
<h3 id="heading-without-emmet">Without Emmet 😓</h3>
<p>You type:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"box"</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
</code></pre>
<hr />
<h3 id="heading-with-emmet">With Emmet 😎</h3>
<p>You type:</p>
<pre><code>div.box&gt;p
</code></pre><p>Press Tab → Done.</p>
<p>Less typing. Same result.</p>
<hr />
<h2 id="heading-common-beginner-mistakes">Common Beginner Mistakes</h2>
<p>Let’s avoid frustration early.</p>
<hr />
<h3 id="heading-mistake-1-forgetting-to-press-tab">Mistake 1: Forgetting to Press Tab</h3>
<p>Emmet works only when you press <strong>Tab</strong> or <strong>Enter</strong> after abbreviation.</p>
<hr />
<h3 id="heading-mistake-2-trying-too-much-syntax-early">Mistake 2: Trying Too Much Syntax Early</h3>
<p>Don’t jump into advanced Emmet tricks.</p>
<p>Start with:</p>
<ul>
<li>Elements</li>
<li>Classes</li>
<li>IDs</li>
<li>Nesting</li>
<li>Repetition</li>
</ul>
<p>That’s enough for daily use.</p>
<hr />
<h3 id="heading-mistake-3-thinking-emmet-is-mandatory">Mistake 3: Thinking Emmet Is Mandatory</h3>
<p>Emmet is optional.</p>
<p>HTML still works without it.</p>
<p>But once you use it, you won’t want to go back.</p>
<hr />
<h2 id="heading-why-emmet-is-a-superpower-for-daily-development">Why Emmet Is a Superpower for Daily Development</h2>
<p>Professional developers use Emmet daily for:</p>
<ul>
<li>Layout creation</li>
<li>UI scaffolding</li>
<li>Rapid prototyping</li>
<li>Repetitive HTML structures</li>
</ul>
<p>It keeps you fast and focused on logic instead of typing.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>Emmet doesn’t replace HTML.</p>
<p>It <strong>accelerates HTML writing</strong>.</p>
<p>If you are learning frontend development, mastering basic Emmet shortcuts will instantly boost your productivity and confidence.</p>
<p>Start small:</p>
<ul>
<li>Try <code>div</code>, <code>p</code>, <code>!</code></li>
<li>Practice nesting</li>
<li>Use repetition</li>
</ul>
<p>Within days, you’ll feel the speed difference.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding HTML Tags and Elements (Beginner-Friendly Guide)]]></title><description><![CDATA[Imagine a webpage like the framework of a house — it needs structure before style and behavior are added. That structure comes from HTML.
Every webpage you see is built with HTML. But what exactly are HTML tags and elements, and how do they shape wha...]]></description><link>https://blog.subhrangsu.in/understanding-html-tags-and-elements-beginner-friendly-guide</link><guid isPermaLink="true">https://blog.subhrangsu.in/understanding-html-tags-and-elements-beginner-friendly-guide</guid><category><![CDATA[HTML5]]></category><category><![CDATA[HTML]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 20:56:19 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769720081428/bfe6dd72-b5e7-42bc-ab7f-249a0d10e9df.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine a webpage like the <strong>framework of a house</strong> — it needs structure before style and behavior are added. That structure comes from <strong>HTML</strong>.</p>
<p>Every webpage you see is built with HTML. But what exactly are HTML tags and elements, and how do they shape what you see on the screen?</p>
<p>Let’s break it down in simple terms.</p>
<hr />
<h2 id="heading-what-html-is-and-why-we-use-it">What HTML Is and Why We Use It</h2>
<p><strong>HTML (HyperText Markup Language)</strong> is the language used to describe the <em>structure</em> of web pages. It tells the browser what parts of the content are headings, paragraphs, images, lists, links, and more. Browsers use this structure to render pages correctly. (<a target="_blank" href="https://en.wikipedia.org/wiki/HTML?utm_source=chatgpt.com">Wikipedia</a>)</p>
<p>🧠 Think of HTML like the <em>skeleton</em> of a webpage — everything else (CSS and JavaScript) adds style and behavior.</p>
<hr />
<h2 id="heading-what-an-html-tag-is">What an HTML Tag Is</h2>
<p>An <strong>HTML tag</strong> is a way of marking content so the browser knows <em>what it represents</em>.</p>
<p>Tags are written inside angle brackets:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This is a paragraph<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>Here:</p>
<ul>
<li><code>&lt;p&gt;</code> → opening tag</li>
<li><code>&lt;/p&gt;</code> → closing tag</li>
<li><code>This is a paragraph</code> → content</li>
</ul>
<p>Tags give meaning to content. Without tags, browsers would just display raw text.</p>
<hr />
<h2 id="heading-opening-tag-closing-tag-and-content">Opening Tag, Closing Tag, and Content</h2>
<p>A complete structure in HTML usually has:</p>
<ol>
<li>An <strong>opening tag</strong></li>
<li>Some <strong>content</strong></li>
<li>A <strong>closing tag</strong></li>
</ol>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello World!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
</code></pre>
<p>But note: some HTML tags don’t need a closing part — more on that next.</p>
<hr />
<h2 id="heading-what-an-html-element-means">What an HTML Element Means</h2>
<p>An <strong>HTML element</strong> is the complete unit that consists of:</p>
<ul>
<li>The <strong>opening tag</strong></li>
<li>The <strong>content</strong> (optional)</li>
<li>The <strong>closing tag</strong> (if required)</li>
</ul>
<p>So this whole thing:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>Hello<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
</code></pre>
<p>counts as <em>one HTML element</em>. (<a target="_blank" href="https://en.wikipedia.org/wiki/HTML_element?utm_source=chatgpt.com">Wikipedia</a>)</p>
<hr />
<h2 id="heading-self-closing-void-elements">Self-Closing (Void) Elements</h2>
<p>Some elements don’t wrap content — they just represent something by themselves.</p>
<p>These are called <strong>void elements</strong> or <strong>self-closing elements</strong>.</p>
<p>Examples:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">img</span>
    <span class="hljs-attr">src</span>=<span class="hljs-string">"puppy.jpg"</span>
    <span class="hljs-attr">alt</span>=<span class="hljs-string">"A cute puppy"</span> /&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">br</span> /&gt;</span>
</code></pre>
<p>They don’t have closing tags because they don’t contain content — they simply act. (<a target="_blank" href="https://en.wikipedia.org/wiki/HTML_element?utm_source=chatgpt.com">Wikipedia</a>)</p>
<hr />
<h2 id="heading-block-level-vs-inline-elements">Block-Level vs Inline Elements</h2>
<p>HTML elements also behave differently visually:</p>
<h3 id="heading-block-level-elements">📏 Block-Level Elements</h3>
<p>Block elements take up the <em>full width</em> available and start on a new line.</p>
<p>Examples:</p>
<ul>
<li><code>&lt;div&gt;</code></li>
<li><code>&lt;p&gt;</code></li>
<li><code>&lt;h1&gt;</code> – <code>&lt;h6&gt;</code></li>
</ul>
<p>Block elements are like paragraphs — clearly separated blocks.</p>
<hr />
<h3 id="heading-inline-elements">📄 Inline Elements</h3>
<p>Inline elements stay <em>within the flow</em> of text.</p>
<p>Examples:</p>
<ul>
<li><code>&lt;span&gt;</code></li>
<li><code>&lt;a&gt;</code></li>
<li><code>&lt;strong&gt;</code></li>
</ul>
<p>Inline elements are like words inside a sentence — they don’t force new lines.</p>
<p>Inline vs block helps you control layout and content flow.</p>
<hr />
<h2 id="heading-semantic-vs-non-semantic-elements">Semantic vs Non-Semantic Elements</h2>
<p>Modern HTML emphasizes <strong>meaningful structure</strong>.</p>
<h3 id="heading-semantic-elements">🔗 Semantic Elements</h3>
<p>Semantic elements give both the browser <em>and developers</em> information about content meaning and role. (<a target="_blank" href="https://www.w3schools.com/html/html5_semantic_elements.asp?utm_source=chatgpt.com">w3schools.com</a>)</p>
<p>Examples of semantic tags:</p>
<ul>
<li><code>&lt;header&gt;</code> – introductory or navigational section</li>
<li><code>&lt;nav&gt;</code> – navigation links</li>
<li><code>&lt;main&gt;</code> – primary page content</li>
<li><code>&lt;article&gt;</code> – standalone content</li>
<li><code>&lt;section&gt;</code> – thematic grouping</li>
<li><code>&lt;footer&gt;</code> – footer information</li>
<li><code>&lt;aside&gt;</code> – related but separate content</li>
<li><code>&lt;figure&gt;</code> / <code>&lt;figcaption&gt;</code> – media with captions</li>
</ul>
<p>Semantic tags help:</p>
<ul>
<li>Improve readability for humans</li>
<li>Make pages more accessible for screen readers</li>
<li>Improve SEO since search engines understand meaning better (<a target="_blank" href="https://www.w3schools.com/html/html5_semantic_elements.asp?utm_source=chatgpt.com">w3schools.com</a>)</li>
</ul>
<hr />
<h3 id="heading-non-semantic-elements">❓ Non-Semantic Elements</h3>
<p>These elements still work — but they don’t tell you <em>what they mean</em>. They are general containers used for layout or wrapping content. (<a target="_blank" href="https://www.dremendo.com/html-tutorial/html-non-semantic-elements?utm_source=chatgpt.com">Dremendo</a>)</p>
<p>Examples include:</p>
<ul>
<li><code>&lt;div&gt;</code> – generic block container</li>
<li><code>&lt;span&gt;</code> – generic inline container</li>
</ul>
<p>For example, <code>&lt;div&gt;</code> doesn’t tell you what is inside — just that it’s a section. This is useful for styling but doesn’t explain purpose.</p>
<hr />
<h2 id="heading-commonly-used-html-tags">Commonly Used HTML Tags</h2>
<p>Here are some HTML tags you’ll see often:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Tag</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td><code>&lt;html&gt;</code></td><td>Root of an HTML document</td></tr>
<tr>
<td><code>&lt;head&gt;</code></td><td>Meta info (title, CSS, meta tags)</td></tr>
<tr>
<td><code>&lt;body&gt;</code></td><td>Visible page content</td></tr>
<tr>
<td><code>&lt;h1&gt;</code>–<code>&lt;h6&gt;</code></td><td>Headings of different levels</td></tr>
<tr>
<td><code>&lt;p&gt;</code></td><td>Paragraph</td></tr>
<tr>
<td><code>&lt;ul&gt;</code>, <code>&lt;ol&gt;</code></td><td>Lists</td></tr>
<tr>
<td><code>&lt;li&gt;</code></td><td>List item</td></tr>
<tr>
<td><code>&lt;a&gt;</code></td><td>Hyperlink</td></tr>
<tr>
<td><code>&lt;img&gt;</code></td><td>Image</td></tr>
<tr>
<td><code>&lt;div&gt;</code></td><td>Non-semantic block container</td></tr>
<tr>
<td><code>&lt;span&gt;</code></td><td>Non-semantic inline container</td></tr>
</tbody>
</table>
</div><p>Semantic tags like <code>&lt;header&gt;</code>, <code>&lt;nav&gt;</code>, <code>&lt;footer&gt;</code> improve clarity, while non-semantic tags like <code>&lt;div&gt;</code> and <code>&lt;span&gt;</code> are flexible for layout and styling. (<a target="_blank" href="https://www.w3schools.com/html/html5_semantic_elements.asp?utm_source=chatgpt.com">w3schools.com</a>)</p>
<hr />
<h2 id="heading-a-simple-example">A Simple Example</h2>
<p>Here’s a tiny HTML page showing different tags:</p>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">title</span>&gt;</span>My First Page<span class="hljs-tag">&lt;/<span class="hljs-name">title</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">header</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Welcome!<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">header</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">main</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">section</span>&gt;</span>
                <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>This page uses semantic tags.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
            <span class="hljs-tag">&lt;/<span class="hljs-name">section</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">main</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">footer</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span><span class="hljs-symbol">&amp;copy;</span> 2025 My Website<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">footer</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<hr />
<h2 id="heading-inspecting-html-in-the-browser">Inspecting HTML in the Browser</h2>
<p>One of the best ways to learn HTML is to explore real pages:</p>
<ol>
<li>Open any webpage</li>
<li>Right-click and choose <strong>Inspect</strong></li>
<li>You’ll see the HTML structure used to build that page</li>
</ol>
<p>This helps you directly connect what you see with actual HTML code.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>HTML is the <strong>foundation of web content</strong>. Once you understand:</p>
<ul>
<li>What tags are</li>
<li>What elements are</li>
<li>The role of semantic vs non-semantic tags</li>
</ul>
<p>…you’ll read, write, and debug web pages with much more confidence.</p>
<p>Using semantic HTML makes your pages easier to maintain, more accessible, and better understood by search engines and assistive technologies. (<a target="_blank" href="https://www.w3schools.com/html/html5_semantic_elements.asp?utm_source=chatgpt.com">w3schools.com</a>)</p>
]]></content:encoded></item><item><title><![CDATA[How a Browser Works: A Beginner-Friendly Guide to Browser Internals]]></title><description><![CDATA[Have you ever wondered what really happens after you type a URL into the address bar and press Enter?
You might think: “The browser just opens a webpage.”
But under the hood, a lot of things happen — and those things are the reason webpages appear fa...]]></description><link>https://blog.subhrangsu.in/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</link><guid isPermaLink="true">https://blog.subhrangsu.in/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals</guid><category><![CDATA[#HowBrowsersWork]]></category><category><![CDATA[internet]]></category><category><![CDATA[browser]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 20:24:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769718033796/ad90b6e2-0c0f-4db2-bd67-f03ba1eefc66.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever wondered what <em>really</em> happens after you type a URL into the address bar and press Enter?</p>
<p>You might think: “The browser just opens a webpage.”
But under the hood, a lot of things happen — and those things are the reason webpages appear fast, correctly styled, and interactive.</p>
<p>In this blog, we’ll break down how a browser works — step by step — using simple explanations and everyday analogies.</p>
<hr />
<h2 id="heading-what-a-browser-actually-is">What a Browser Actually Is</h2>
<p>A <strong>browser</strong> is more than a window that shows websites.</p>
<p>It’s a <strong>software application</strong> that:</p>
<ul>
<li>Talks to servers</li>
<li>Downloads resources</li>
<li>Parses and interprets code</li>
<li>Builds structures like the DOM</li>
<li>Combines styling and layout</li>
<li>Paints pixels on your screen</li>
</ul>
<p>It’s like a <strong>mini operating system for web pages</strong> — where each tab is running its own little world.</p>
<hr />
<h2 id="heading-what-happens-after-you-press-enter">What Happens After You Press Enter?</h2>
<p>Everything begins when you type a URL like:</p>
<pre><code>https:<span class="hljs-comment">//example.com</span>
</code></pre><p>That single action triggers a series of carefully coordinated steps.</p>
<p>Let’s follow them in order.</p>
<hr />
<h2 id="heading-main-parts-of-a-browser">Main Parts of a Browser</h2>
<p>To understand the journey, we need to know the main components inside a browser:</p>
<ol>
<li><strong>User Interface</strong> – address bar, back/forward buttons, tabs, bookmarks</li>
<li><strong>Browser Engine</strong> – manages interactions between UI and core systems</li>
<li><strong>Networking Layer</strong> – fetches data from the internet</li>
<li><strong>Rendering Engine</strong> – parses content and draws it on screen</li>
<li><strong>JavaScript Engine</strong> – executes scripts</li>
<li><strong>Data Storage</strong> – caches, cookies, local storage</li>
</ol>
<p>Think of the browser like a <strong>theatre production</strong>: the UI is the audience’s window, the engine is the stage manager, the rendering engine is the art department, and the networking layer is the courier bringing in scripts and styles.</p>
<hr />
<h2 id="heading-user-interface">User Interface</h2>
<p>This is what you see and interact with:</p>
<ul>
<li>The <strong>address bar</strong> where you enter the URL</li>
<li><strong>Tabs</strong> to open multiple pages</li>
<li>Navigation buttons</li>
<li>Loading indicators</li>
</ul>
<p>This part doesn’t deal with the technical details — it just captures your intent and shows results.</p>
<hr />
<h2 id="heading-browser-engine-vs-rendering-engine">Browser Engine vs Rendering Engine</h2>
<p>You don’t need to remember fancy names like <strong>Gecko</strong> or <strong>Blink</strong>, but you should understand the difference:</p>
<ul>
<li><strong>Browser Engine</strong> – orchestrates everything</li>
<li><strong>Rendering Engine</strong> – takes code (HTML, CSS) and turns it into pixels</li>
</ul>
<p>If the browser were a car:</p>
<ul>
<li>Browser engine = driver</li>
<li>Rendering engine = engine and transmission</li>
</ul>
<p>They work together, but they are not the same.</p>
<hr />
<h2 id="heading-networking-fetching-html-css-and-js">Networking: Fetching HTML, CSS, and JS</h2>
<p>Once the browser knows what URL you want, it uses the networking layer to:</p>
<ol>
<li>Resolve the domain (DNS lookup)</li>
<li>Establish a connection (TCP, TLS)</li>
<li>Send an HTTP request</li>
<li>Receive the server response</li>
</ol>
<p>The response usually contains:</p>
<ul>
<li><strong>HTML</strong> (structure)</li>
<li><strong>CSS</strong> (styles)</li>
<li><strong>JavaScript</strong> (behavior)</li>
</ul>
<p>The browser doesn’t wait for all resources to arrive before it starts working — it begins processing as soon as data arrives.</p>
<hr />
<h2 id="heading-html-parsing-and-dom-creation">HTML Parsing and DOM Creation</h2>
<p>When HTML starts arriving, the rendering engine begins parsing it.</p>
<p>Think of parsing like <strong>reading a sentence and understanding words</strong>.</p>
<p>HTML is broken down into a <strong>tree structure</strong> called the <strong>DOM (Document Object Model)</strong>.</p>
<p>Example:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>Hello<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>Becomes a tree where each tag is a node.</p>
<p>Analogy: DOM is like a <strong>family tree</strong> of all HTML elements.</p>
<hr />
<h2 id="heading-css-parsing-and-cssom-creation">CSS Parsing and CSSOM Creation</h2>
<p>CSS is parsed into another tree called the <strong>CSSOM (CSS Object Model)</strong>.</p>
<p>Where DOM represents structure, CSSOM represents <strong>styling rules</strong> attached to elements.</p>
<p>Example:</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">h1</span> {
    <span class="hljs-attribute">color</span>: blue;
}
</code></pre>
<p>The rendering engine stores this rule so it knows how to style <code>&lt;h1&gt;</code> later.</p>
<hr />
<h2 id="heading-how-dom-and-cssom-come-together">How DOM and CSSOM Come Together</h2>
<p>Once both DOM and CSSOM exist, the browser can combine them into a <strong>Render Tree</strong>.</p>
<p>The render tree contains:</p>
<ul>
<li>Elements that are visible</li>
<li>Their computed styles</li>
<li>Information needed for layout</li>
</ul>
<p>Hidden elements (like <code>&lt;script&gt;</code>, <code>&lt;meta&gt;</code>, or <code>display: none</code>) do not appear here.</p>
<hr />
<h2 id="heading-layout-reflow-painting-and-display">Layout (Reflow), Painting, and Display</h2>
<p>Now the browser asks:</p>
<blockquote>
<p>“Where should everything be on the page?”</p>
</blockquote>
<p>This step is called <strong>Layout</strong> or <strong>Reflow</strong>.</p>
<p>The render tree nodes are given:</p>
<ul>
<li>Coordinates</li>
<li>Dimensions</li>
</ul>
<p>Once layout is done, the final step is <strong>Painting</strong> — drawing pixels on the screen.</p>
<p>The result you see is the web page.</p>
<hr />
<h2 id="heading-a-basic-parsing-analogy">A Basic Parsing Analogy</h2>
<p>Remember the DOM/CSSOM step? It’s similar to learning a language.</p>
<p>Imagine parsing this sentence:</p>
<pre><code><span class="hljs-number">1</span> + <span class="hljs-number">2</span> * <span class="hljs-number">3</span>
</code></pre><p>To understand meaning, you need to:</p>
<ol>
<li>Break tokens</li>
<li>Identify operations</li>
<li>Build a structure representing order of operations.</li>
</ol>
<p>Just like math parsing, HTML/CSS parsing builds structures the browser can work with later.</p>
<hr />
<h2 id="heading-why-this-matters">Why This Matters</h2>
<p>Understanding how a browser works helps you:</p>
<ul>
<li>Write better websites</li>
<li>Debug rendering issues</li>
<li>Optimize performance</li>
<li>Know why JavaScript sometimes blocks rendering</li>
<li>Appreciate what happens between request and display</li>
</ul>
<p>You don’t need to memorize internal names — but knowing the flow lets you think like a browser.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>A browser is not magic — it’s a <strong>complex system</strong> with multiple cooperating parts.</p>
<p>From the moment you press Enter:</p>
<ol>
<li>Networking fetches resources</li>
<li>HTML and CSS are parsed</li>
<li>DOM and CSSOM are created</li>
<li>Render tree is built</li>
<li>Layout and painting happen</li>
<li>Content appears on your screen</li>
</ol>
<p>You don’t have to understand every detail right away — just the flow.</p>
<p>Once that clicks, you’re already thinking like a web engineer.</p>
]]></content:encoded></item><item><title><![CDATA[TCP Working: 3-Way Handshake & Reliable Communication]]></title><description><![CDATA[Imagine you walk into a shop, but before the shopkeeper starts serving you, you first greet each other and agree you’re ready to talk. Networking works in a similar way.
When two computers want to talk reliably over a network, they use a protocol cal...]]></description><link>https://blog.subhrangsu.in/tcp-working-3-way-handshake-and-reliable-communication</link><guid isPermaLink="true">https://blog.subhrangsu.in/tcp-working-3-way-handshake-and-reliable-communication</guid><category><![CDATA[3-way handshake]]></category><category><![CDATA[TCP Handshake]]></category><category><![CDATA[TCP]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 20:08:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769717123107/44241bd0-5e32-4d5d-92be-a4ae0a205d4f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Imagine you walk into a shop, but before the shopkeeper starts serving you, you first <strong>greet each other and agree you’re ready to talk</strong>. Networking works in a similar way.</p>
<p>When two computers want to talk reliably over a network, they use a protocol called <strong>TCP (Transmission Control Protocol)</strong> to make sure both sides are ready and that messages won’t get lost, arrive out of order, or get corrupted along the way. (<a target="_blank" href="https://www.techtarget.com/searchnetworking/definition/TCP?utm_source=chatgpt.com">TechTarget</a>)</p>
<hr />
<h2 id="heading-what-is-tcp-and-why-it-is-needed">What Is TCP and Why It Is Needed</h2>
<p>At a high level, TCP is a protocol that helps two computers communicate <strong>reliably</strong>. It’s used for things like:</p>
<ul>
<li>Browsing websites</li>
<li>Downloading files</li>
<li>Sending emails</li>
<li>Communicating between applications</li>
</ul>
<p>TCP ensures that the data you send:</p>
<ul>
<li><strong>Arrives at the other end</strong></li>
<li><strong>Arrives in the correct order</strong></li>
<li><strong>Is complete</strong></li>
</ul>
<p>Without TCP, data might get lost, duplicated, or arrive scrambled — like talking in a noisy room without confirming you were heard. (<a target="_blank" href="https://www.techtarget.com/searchnetworking/definition/TCP?utm_source=chatgpt.com">TechTarget</a>)</p>
<hr />
<h2 id="heading-problems-tcp-is-designed-to-solve">Problems TCP Is Designed to Solve</h2>
<p>Unreliable networks can cause:</p>
<ul>
<li><strong>Lost packets</strong></li>
<li><strong>Out-of-order packets</strong></li>
<li><strong>Corrupted data</strong></li>
<li><strong>Duplicate packets</strong></li>
</ul>
<p>TCP solves these by:</p>
<ul>
<li>Using <strong>sequence numbers</strong> so data can be reordered correctly</li>
<li>Waiting for <strong>ACKs (acknowledgements)</strong> before moving on</li>
<li>Retransmitting packets if they’re missing</li>
<li>Using <strong>checksums</strong> to detect corruption (<a target="_blank" href="https://www.geeksforgeeks.org/computer-networks/what-is-transmission-control-protocol-tcp/?utm_source=chatgpt.com">GeeksforGeeks</a>)</li>
</ul>
<p>This means the application (like your web browser) can ask for data and trust what it gets.</p>
<hr />
<h2 id="heading-what-is-the-tcp-3-way-handshake">What Is the TCP 3-Way Handshake?</h2>
<p>Before two computers transfer data, they must agree to communicate — just like you and a friend confirm you’re both ready before starting a conversation.</p>
<p>This setup is called the <strong>3-way handshake</strong> because three messages are exchanged:</p>
<ol>
<li><strong>SYN</strong></li>
<li><strong>SYN-ACK</strong></li>
<li><strong>ACK</strong> (<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Glossary/TCP_handshake?utm_source=chatgpt.com">MDN Web Docs</a>)</li>
</ol>
<hr />
<h2 id="heading-step-by-step-syn-syn-ack-and-ack">Step-by-Step: SYN, SYN-ACK, and ACK</h2>
<h3 id="heading-step-1-client-sends-syn">Step 1 — Client Sends SYN</h3>
<p>The <strong>client</strong> (your computer) begins by sending a SYN packet to the server.</p>
<ul>
<li>SYN stands for “synchronize”</li>
<li><p>It tells the server:</p>
<blockquote>
<p>“I want to start a connection, and here’s my initial sequence number.” (<a target="_blank" href="https://networkwalks.com/tcp-3-way-handshake-process/?utm_source=chatgpt.com">Network Walks</a>)</p>
</blockquote>
</li>
</ul>
<p>Think of this as the client saying “Hello! Are you there?”</p>
<hr />
<h3 id="heading-step-2-server-replies-with-syn-ack">Step 2 — Server Replies with SYN-ACK</h3>
<p>The <strong>server</strong> receives the SYN and replies with a <strong>SYN-ACK</strong>:</p>
<ul>
<li>SYN to synchronize with the client</li>
<li>ACK to acknowledge the client’s request</li>
</ul>
<p>This tells the client:</p>
<blockquote>
<p>“Yes, I’m here, and I’m ready. Here’s my sequence number too.” (<a target="_blank" href="https://newsletter.systemdesigncodex.com/p/tcp-3-way-handshake?utm_source=chatgpt.com">System Design Codex</a>)</p>
</blockquote>
<p>It’s like the server saying “Hi, I heard you. Let’s talk!”</p>
<hr />
<h3 id="heading-step-3-client-sends-ack">Step 3 — Client Sends ACK</h3>
<p>Finally, the client sends an <strong>ACK</strong> back to the server.</p>
<p>This confirms:</p>
<ul>
<li>It received the server’s reply</li>
<li>Both sides are ready to start data transfer (<a target="_blank" href="https://networkwalks.com/tcp-3-way-handshake-process/?utm_source=chatgpt.com">Network Walks</a>)</li>
</ul>
<p>Once this last ACK is sent, the connection is established and both ends move to the <strong>ESTABLISHED</strong> state.</p>
<hr />
<h2 id="heading-how-data-transfer-works-in-tcp">How Data Transfer Works in TCP</h2>
<p>Now that the connection is established, TCP ensures reliable, ordered data transfer using:</p>
<h3 id="heading-sequence-numbers">Sequence Numbers</h3>
<p>Every byte of data is assigned a number. This helps both sides:</p>
<ul>
<li>Reassemble data in order</li>
<li>Detect missing or duplicate packets (<a target="_blank" href="https://www.sciencedirect.com/topics/computer-science/transmission-control-protocol?utm_source=chatgpt.com">ScienceDirect</a>)</li>
</ul>
<hr />
<h3 id="heading-acknowledgements-acks">Acknowledgements (ACKs)</h3>
<p>After receiving data, the <strong>receiver sends ACKs</strong> to confirm which bytes arrived correctly.
If the sender does not get an expected ACK in time, it <strong>retransmits</strong> the missing data. (<a target="_blank" href="https://www.sciencedirect.com/topics/computer-science/transmission-control-protocol?utm_source=chatgpt.com">ScienceDirect</a>)</p>
<p>This turns an unreliable network into a <strong>reliable stream of bytes</strong>.</p>
<hr />
<h2 id="heading-how-tcp-ensures-reliability-order-and-correctness">How TCP Ensures Reliability, Order, and Correctness</h2>
<p>TCP incorporates multiple mechanisms to provide reliable communication:</p>
<ul>
<li><strong>Sequencing:</strong> Keeps packets in order</li>
<li><strong>Checksums:</strong> Detects corrupted data</li>
<li><strong>Retransmissions:</strong> Resends lost data</li>
<li><strong>Flow control:</strong> Prevents overwhelming the receiver (<a target="_blank" href="https://www.geeksforgeeks.org/computer-networks/what-is-transmission-control-protocol-tcp/?utm_source=chatgpt.com">GeeksforGeeks</a>)</li>
</ul>
<p>This is why TCP is used by systems that cannot tolerate missing or misordered data — like web pages, APIs, databases, and email.</p>
<hr />
<h2 id="heading-how-tcp-connection-is-closed-fin-and-ack-explained">How TCP Connection Is Closed (FIN and ACK Explained)</h2>
<p>Ending a TCP connection is just as important as starting it.</p>
<p>TCP uses special control flags:</p>
<hr />
<h3 id="heading-fin-finish">FIN (Finish)</h3>
<p>FIN means:</p>
<blockquote>
<p>“I have finished sending data and want to close my side of the connection.”</p>
</blockquote>
<p>It does NOT immediately close everything.</p>
<p>It only signals that one side is done sending.</p>
<hr />
<h3 id="heading-ack-acknowledgment">ACK (Acknowledgment)</h3>
<p>ACK means:</p>
<blockquote>
<p>“I received your message.”</p>
</blockquote>
<p>It is used throughout TCP communication — including during shutdown.</p>
<hr />
<h3 id="heading-fin-ack-together">FIN + ACK Together</h3>
<p>Sometimes a device sends <strong>FIN and ACK together</strong>.</p>
<p>This means:</p>
<ul>
<li>Acknowledging the last received data</li>
<li>Simultaneously requesting to close its side</li>
</ul>
<p>This happens when a device finishes sending data and has nothing more to transmit.</p>
<hr />
<h2 id="heading-tcp-connection-termination-four-way-handshake">TCP Connection Termination: Four-Way Handshake</h2>
<p>Closing a TCP connection happens in <strong>four steps</strong>.</p>
<p>This allows both sides to finish sending remaining data safely.</p>
<hr />
<h3 id="heading-step-1-fin-client-server">Step 1 — FIN (Client → Server)</h3>
<p>Client sends FIN:</p>
<blockquote>
<p>“I am done sending data.”</p>
</blockquote>
<hr />
<h3 id="heading-step-2-ack-server-client">Step 2 — ACK (Server → Client)</h3>
<p>Server replies with ACK:</p>
<blockquote>
<p>“I received your FIN.”</p>
</blockquote>
<p>Now the connection becomes <strong>half-closed</strong>.</p>
<p>The server can still send remaining data.</p>
<hr />
<h3 id="heading-step-3-fin-server-client">Step 3 — FIN (Server → Client)</h3>
<p>When the server finishes sending its data, it sends its own FIN:</p>
<blockquote>
<p>“Now I am also done.”</p>
</blockquote>
<hr />
<h3 id="heading-step-4-ack-client-server">Step 4 — ACK (Client → Server)</h3>
<p>Client acknowledges the server’s FIN with ACK.</p>
<p>Now both sides agree:</p>
<blockquote>
<p>Communication is finished.</p>
</blockquote>
<p>The connection is fully closed.</p>
<hr />
<h3 id="heading-important-real-world-behavior">Important Real-World Behavior</h3>
<p>Often:</p>
<ul>
<li>One side sends FIN</li>
<li>The other side ACKs immediately</li>
<li>But delays sending its own FIN until its data transfer completes</li>
</ul>
<p>This allows graceful shutdown without cutting off data.</p>
<hr />
<h2 id="heading-why-tcp-shutdown-is-designed-this-way">Why TCP Shutdown Is Designed This Way</h2>
<p>TCP does not assume both sides finish at the same time.</p>
<p>One side may finish earlier.</p>
<p>The four-step process ensures:</p>
<ul>
<li>No data loss</li>
<li>Clean resource release</li>
<li>Proper session termination</li>
</ul>
<p>This design makes TCP stable even in long-running connections.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>TCP is much more than just “sending data”.</p>
<p>It is a complete communication system that:</p>
<ul>
<li>Builds connections</li>
<li>Guarantees reliability</li>
<li>Maintains order</li>
<li>Handles packet loss</li>
<li>Closes connections safely</li>
</ul>
<p>Every website you load, every API you call, and every file you download depends on this invisible handshake process working perfectly.</p>
<p>Understanding TCP makes you a stronger backend engineer, system designer, and network-aware developer.</p>
]]></content:encoded></item><item><title><![CDATA[TCP vs UDP: When to Use What, and How TCP Relates to HTTP]]></title><description><![CDATA[Let’s start with something simple.
The internet doesn’t just “send data”.
It follows rules.
Without rules, data packets would get lost, mixed up, duplicated, or arrive in the wrong order.
Two of the most important rule systems for sending data are:

...]]></description><link>https://blog.subhrangsu.in/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</link><guid isPermaLink="true">https://blog.subhrangsu.in/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http</guid><category><![CDATA[TCP]]></category><category><![CDATA[UDP]]></category><category><![CDATA[http]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 29 Jan 2026 20:02:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769715711360/c213ff38-13b0-4815-a220-530ca3019b50.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s start with something simple.</p>
<p>The internet doesn’t just “send data”.</p>
<p>It follows <strong>rules</strong>.</p>
<p>Without rules, data packets would get lost, mixed up, duplicated, or arrive in the wrong order.</p>
<p>Two of the most important rule systems for sending data are:</p>
<ul>
<li>TCP</li>
<li>UDP</li>
</ul>
<p>And many beginners get confused about how HTTP fits into all this.</p>
<p>Let’s clear it step by step.</p>
<hr />
<h2 id="heading-what-are-tcp-and-udp-high-level-view">What Are TCP and UDP (High-Level View)?</h2>
<p>TCP and UDP are <strong>transport protocols</strong>.</p>
<p>That means their job is:</p>
<blockquote>
<p>To move data from one computer to another over the internet.</p>
</blockquote>
<p>They sit between:</p>
<ul>
<li>Your application (browser, app, API)</li>
<li>The network (IP layer)</li>
</ul>
<p>Think of them as <strong>delivery methods</strong> for data.</p>
<hr />
<h2 id="heading-simple-analogy-safe-delivery-vs-fast-delivery">Simple Analogy: Safe Delivery vs Fast Delivery</h2>
<p>Imagine sending something to your friend.</p>
<h3 id="heading-tcp-is-like-a-courier-service">TCP is Like a Courier Service 📦</h3>
<ul>
<li>Confirms delivery</li>
<li>Resends lost packages</li>
<li>Keeps order</li>
<li>Guarantees arrival</li>
</ul>
<p>Reliable but slightly slower.</p>
<hr />
<h3 id="heading-udp-is-like-a-public-announcement">UDP is Like a Public Announcement 📢</h3>
<ul>
<li>Broadcasts information</li>
<li>No confirmation</li>
<li>No retry</li>
<li>No guarantee</li>
</ul>
<p>Fast but risky.</p>
<hr />
<p>Now let’s understand their differences clearly.</p>
<hr />
<h2 id="heading-key-differences-between-tcp-and-udp">Key Differences Between TCP and UDP</h2>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>TCP</td><td>UDP</td></tr>
</thead>
<tbody>
<tr>
<td>Connection setup</td><td>Yes</td><td>No</td></tr>
<tr>
<td>Reliability</td><td>Guaranteed</td><td>Not guaranteed</td></tr>
<tr>
<td>Order of data</td><td>Maintained</td><td>Not maintained</td></tr>
<tr>
<td>Speed</td><td>Slightly slower</td><td>Very fast</td></tr>
<tr>
<td>Error checking</td><td>Strong</td><td>Basic</td></tr>
<tr>
<td>Use case</td><td>Accuracy matters</td><td>Speed matters</td></tr>
</tbody>
</table>
</div><hr />
<h2 id="heading-when-should-you-use-tcp">When Should You Use TCP?</h2>
<p>Use TCP when <strong>data correctness is critical</strong>.</p>
<p>If even one packet is missing, the result becomes useless.</p>
<hr />
<h3 id="heading-common-tcp-use-cases">Common TCP Use Cases</h3>
<ul>
<li>Website loading (HTTP/HTTPS)</li>
<li>API requests</li>
<li>File downloads</li>
<li>Emails</li>
<li>Database connections</li>
</ul>
<p>Example:</p>
<p>When you download a PDF:</p>
<blockquote>
<p>You want the full file — not half.</p>
</blockquote>
<p>So TCP is used.</p>
<hr />
<h2 id="heading-when-should-you-use-udp">When Should You Use UDP?</h2>
<p>Use UDP when <strong>speed matters more than perfection</strong>.</p>
<p>Small data loss is acceptable.</p>
<hr />
<h3 id="heading-common-udp-use-cases">Common UDP Use Cases</h3>
<ul>
<li>Live video streaming</li>
<li>Online gaming</li>
<li>Voice calls (VoIP)</li>
<li>Live broadcasts</li>
<li>DNS queries</li>
</ul>
<p>Example:</p>
<p>In a video call:</p>
<blockquote>
<p>It’s better to skip a frame than freeze the whole call.</p>
</blockquote>
<p>So UDP is preferred.</p>
<hr />
<h2 id="heading-real-world-examples-easy-comparison">Real-World Examples (Easy Comparison)</h2>
<h3 id="heading-watching-youtube-live">Watching YouTube Live</h3>
<p>Uses UDP-based streaming.</p>
<p>Why?</p>
<p>Because real-time delivery matters more than perfect data.</p>
<hr />
<h3 id="heading-loading-a-website">Loading a Website</h3>
<p>Uses TCP.</p>
<p>Why?</p>
<p>Because missing HTML or CSS breaks the page.</p>
<hr />
<h3 id="heading-online-multiplayer-games">Online Multiplayer Games</h3>
<p>Movement updates often use UDP.</p>
<p>Because:</p>
<ul>
<li>Speed matters</li>
<li>Small packet loss is fine</li>
<li>Continuous updates come anyway</li>
</ul>
<hr />
<h3 id="heading-downloading-software">Downloading Software</h3>
<p>Uses TCP.</p>
<p>Because:</p>
<ul>
<li>Every byte must be correct</li>
<li>Corruption is unacceptable</li>
</ul>
<hr />
<h2 id="heading-what-is-http-and-where-does-it-fit">What Is HTTP and Where Does It Fit?</h2>
<p>Now let’s talk about HTTP.</p>
<p>HTTP is NOT a transport protocol.</p>
<p>HTTP is an <strong>application-level protocol</strong>.</p>
<p>Its job is:</p>
<blockquote>
<p>To define how browsers and servers talk in a structured way.</p>
</blockquote>
<p>HTTP decides:</p>
<ul>
<li>Request format</li>
<li>Response format</li>
<li>Status codes</li>
<li>Headers</li>
<li>Methods like GET and POST</li>
</ul>
<p>But HTTP does NOT handle:</p>
<ul>
<li>Packet delivery</li>
<li>Retransmission</li>
<li>Network reliability</li>
</ul>
<p>That’s TCP’s job.</p>
<hr />
<h2 id="heading-relationship-between-http-and-tcp">Relationship Between HTTP and TCP</h2>
<p>Here’s the correct layering:</p>
<pre><code>HTTP (Application Layer)
       ↓
TCP (Transport Layer)
       ↓
IP (Network Layer)
</code></pre><p>This means:</p>
<blockquote>
<p>HTTP runs on top of TCP.</p>
</blockquote>
<p>HTTP uses TCP as its delivery system.</p>
<hr />
<h3 id="heading-simple-explanation">Simple Explanation</h3>
<p>HTTP writes the message:</p>
<blockquote>
<p>“Give me this webpage.”</p>
</blockquote>
<p>TCP delivers that message safely to the server.</p>
<p>Server sends HTTP response back.</p>
<p>TCP delivers it safely to your browser.</p>
<hr />
<h2 id="heading-why-http-does-not-replace-tcp">Why HTTP Does Not Replace TCP</h2>
<p>Many beginners think:</p>
<blockquote>
<p>If HTTP sends data, why do we need TCP?</p>
</blockquote>
<p>Because HTTP and TCP solve <strong>different problems</strong>.</p>
<hr />
<h3 id="heading-http-solves">HTTP Solves</h3>
<ul>
<li>What format should requests use</li>
<li>How responses look</li>
<li>How APIs communicate</li>
</ul>
<hr />
<h3 id="heading-tcp-solves">TCP Solves</h3>
<ul>
<li>Packet ordering</li>
<li>Packet loss recovery</li>
<li>Connection reliability</li>
<li>Data integrity</li>
</ul>
<p>HTTP depends on TCP to work correctly.</p>
<p>Without TCP, HTTP would be unreliable.</p>
<hr />
<h2 id="heading-common-beginner-confusion-is-http-the-same-as-tcp">Common Beginner Confusion: Is HTTP the Same as TCP?</h2>
<p>Short answer:</p>
<p>❌ No.</p>
<p>They live at different layers.</p>
<hr />
<h3 id="heading-easy-memory-trick">Easy Memory Trick</h3>
<ul>
<li>TCP = Delivery truck</li>
<li>HTTP = Package format</li>
</ul>
<p>You need both.</p>
<hr />
<h2 id="heading-why-this-matters-for-developers">Why This Matters for Developers</h2>
<p>Understanding TCP vs UDP helps you:</p>
<ul>
<li>Design better systems</li>
<li>Choose correct protocols</li>
<li>Debug network issues</li>
<li>Build scalable apps</li>
<li>Understand cloud networking</li>
</ul>
<p>Example:</p>
<ul>
<li>API performance tuning</li>
<li>WebSocket behavior</li>
<li>Streaming architecture</li>
<li>Real-time application design</li>
</ul>
<p>All depend on these basics.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>TCP and UDP are the <strong>hidden highways of the internet</strong>.</p>
<p>You don’t see them, but every app depends on them.</p>
<p>Remember:</p>
<ul>
<li>TCP = Safe, reliable, ordered</li>
<li>UDP = Fast, lightweight, real-time</li>
<li>HTTP = Communication rules on top of TCP</li>
</ul>
<p>Once this mental model is clear, networking becomes much easier.</p>
]]></content:encoded></item><item><title><![CDATA[Getting Started with cURL (For Absolute Beginners)]]></title><description><![CDATA[Before we talk about cURL, let’s understand something simple.
What Is a Server and Why Do We Need to Talk to It?
A server is just a computer that waits for requests.
When you:

Open a website
Submit a form
Call an API
Log in to an app

Your device is...]]></description><link>https://blog.subhrangsu.in/getting-started-with-curl-for-absolute-beginners</link><guid isPermaLink="true">https://blog.subhrangsu.in/getting-started-with-curl-for-absolute-beginners</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[curl]]></category><category><![CDATA[dns]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Wed, 28 Jan 2026 20:45:44 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769633021273/65966b8e-ecb1-45c4-8bd2-19946b30c0d9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before we talk about cURL, let’s understand something simple.</p>
<h2 id="heading-what-is-a-server-and-why-do-we-need-to-talk-to-it">What Is a Server and Why Do We Need to Talk to It?</h2>
<p>A <strong>server</strong> is just a computer that waits for requests.</p>
<p>When you:</p>
<ul>
<li>Open a website</li>
<li>Submit a form</li>
<li>Call an API</li>
<li>Log in to an app</li>
</ul>
<p>Your device is sending a message to a server saying:</p>
<blockquote>
<p>“Hey server, give me this data.”</p>
</blockquote>
<p>The server replies with:</p>
<blockquote>
<p>“Here is what you asked for.”</p>
</blockquote>
<p>This request–response conversation is the foundation of the web.</p>
<p>Now the question is…</p>
<p>How do we send these messages without a browser?</p>
<p>That’s where <strong>cURL</strong> comes in.</p>
<hr />
<h2 id="heading-what-is-curl-in-very-simple-terms">What Is cURL (In Very Simple Terms)?</h2>
<p>cURL is a <strong>command-line tool that sends requests to servers</strong>.</p>
<p>Instead of clicking buttons in a browser, you type a command in the terminal and talk directly to a server.</p>
<p>Think of cURL as:</p>
<blockquote>
<p>WhatsApp for servers — but in text commands.</p>
</blockquote>
<p>It lets you:</p>
<ul>
<li>Fetch web pages</li>
<li>Call APIs</li>
<li>Send data</li>
<li>Test endpoints</li>
<li>Debug backend services</li>
</ul>
<p>And the best part?</p>
<p>It works almost everywhere — Linux, Mac, Windows.</p>
<hr />
<h2 id="heading-why-programmers-need-curl">Why Programmers Need cURL</h2>
<p>If you are learning:</p>
<ul>
<li>Backend development</li>
<li>APIs</li>
<li>DevOps</li>
<li>Cloud</li>
<li>System design</li>
</ul>
<p>cURL becomes your daily tool.</p>
<p>You use cURL to:</p>
<ul>
<li>Test APIs without building UI</li>
<li>Check if a server is running</li>
<li>Debug request issues</li>
<li>Understand HTTP behavior</li>
<li>Automate network tasks</li>
</ul>
<p>It gives you <strong>direct control</strong> over network communication.</p>
<hr />
<h2 id="heading-making-your-first-request-using-curl">Making Your First Request Using cURL</h2>
<p>Let’s start simple.</p>
<p>Open your terminal and type:</p>
<pre><code class="lang-bash">curl https://example.com
</code></pre>
<p>Press Enter.</p>
<p>Boom 🎉</p>
<p>You just made your first HTTP request.</p>
<hr />
<h3 id="heading-what-just-happened">What Just Happened?</h3>
<p>You told cURL:</p>
<blockquote>
<p>“Go to example.com and get the content.”</p>
</blockquote>
<p>The server responded with HTML code.</p>
<p>This is the same thing your browser does — just without showing a webpage UI.</p>
<hr />
<h2 id="heading-understanding-request-and-response-simple-version">Understanding Request and Response (Simple Version)</h2>
<p>Every cURL command follows this pattern:</p>
<pre><code>You → Request → Server  
Server → Response → You
</code></pre><hr />
<h3 id="heading-the-request-contains">The Request Contains:</h3>
<ul>
<li>Where to go (URL)</li>
<li>What to do (GET, POST)</li>
<li>Optional data</li>
</ul>
<hr />
<h3 id="heading-the-response-contains">The Response Contains:</h3>
<ul>
<li>Status code</li>
<li>Data</li>
<li>Headers</li>
</ul>
<p>Let’s understand status first.</p>
<hr />
<h2 id="heading-understanding-response-status-quickly">Understanding Response Status (Quickly)</h2>
<p>Sometimes you may see something like:</p>
<pre><code><span class="hljs-number">200</span> OK
</code></pre><p>That means:</p>
<blockquote>
<p>Everything worked fine.</p>
</blockquote>
<p>Common ones you’ll see:</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Code</td><td>Meaning</td></tr>
</thead>
<tbody>
<tr>
<td>200</td><td>Success</td></tr>
<tr>
<td>404</td><td>Not found</td></tr>
<tr>
<td>500</td><td>Server error</td></tr>
</tbody>
</table>
</div><p>You don’t need to memorize everything now — just know:</p>
<blockquote>
<p>Status tells you what happened.</p>
</blockquote>
<hr />
<h2 id="heading-using-curl-to-talk-to-apis">Using cURL to Talk to APIs</h2>
<p>Now let’s talk to a real API.</p>
<p>Try this:</p>
<pre><code class="lang-bash">curl https://api.github.com
</code></pre>
<p>You’ll receive JSON data instead of HTML.</p>
<p>This is how backend developers test APIs.</p>
<hr />
<h3 id="heading-why-this-is-powerful">Why This Is Powerful</h3>
<p>Without writing any frontend code:</p>
<ul>
<li>You can test endpoints</li>
<li>Check responses</li>
<li>See real data</li>
<li>Debug problems</li>
</ul>
<p>This saves hours of development time.</p>
<hr />
<h2 id="heading-understanding-get-and-post-only-the-basics">Understanding GET and POST (Only the Basics)</h2>
<p>Let’s keep it simple.</p>
<hr />
<h3 id="heading-get-request-default">GET Request (Default)</h3>
<p>GET means:</p>
<blockquote>
<p>Give me data.</p>
</blockquote>
<p>Example:</p>
<pre><code class="lang-bash">curl https://api.github.com/users/octocat
</code></pre>
<p>You are asking the server to send information.</p>
<hr />
<h3 id="heading-post-request-sending-data">POST Request (Sending Data)</h3>
<p>POST means:</p>
<blockquote>
<p>Here is some data. Please process it.</p>
</blockquote>
<p>Example:</p>
<pre><code class="lang-bash">curl -X POST https://httpbin.org/post
</code></pre>
<p>This sends a POST request.</p>
<p>For now, just remember:</p>
<ul>
<li>GET → Fetch data</li>
<li>POST → Send data</li>
</ul>
<p>You’ll learn advanced usage later.</p>
<hr />
<h2 id="heading-common-mistakes-beginners-make-with-curl">Common Mistakes Beginners Make With cURL</h2>
<p>Let’s save you some frustration 😄</p>
<hr />
<h3 id="heading-mistake-1-forgetting-https">Mistake 1: Forgetting https</h3>
<p>❌ Wrong:</p>
<pre><code class="lang-bash">curl example.com
</code></pre>
<p>✅ Correct:</p>
<pre><code class="lang-bash">curl https://example.com
</code></pre>
<p>Always include protocol.</p>
<hr />
<h3 id="heading-mistake-2-expecting-browser-ui">Mistake 2: Expecting Browser UI</h3>
<p>cURL shows <strong>raw server response</strong>, not pretty pages.</p>
<p>That’s normal.</p>
<hr />
<h3 id="heading-mistake-3-copying-complex-commands-too-early">Mistake 3: Copying Complex Commands Too Early</h3>
<p>Many tutorials throw 10 flags at beginners.</p>
<p>Avoid that.</p>
<p>Start with:</p>
<ul>
<li>Simple GET</li>
<li>Simple POST</li>
<li>One option at a time</li>
</ul>
<hr />
<h3 id="heading-mistake-4-thinking-curl-is-only-for-apis">Mistake 4: Thinking cURL Is Only for APIs</h3>
<p>cURL works with:</p>
<ul>
<li>Websites</li>
<li>APIs</li>
<li>Files</li>
<li>Authentication</li>
<li>Uploads</li>
<li>Downloads</li>
</ul>
<p>It’s much more than an API tool.</p>
<hr />
<h2 id="heading-why-learning-curl-builds-strong-backend-skills">Why Learning cURL Builds Strong Backend Skills</h2>
<p>When you use cURL, you start to understand:</p>
<ul>
<li>How HTTP really works</li>
<li>What servers actually return</li>
<li>How APIs communicate</li>
<li>How debugging is done in production</li>
</ul>
<p>This knowledge transfers directly to:</p>
<ul>
<li>Postman</li>
<li>Frontend fetch</li>
<li>Axios</li>
<li>Backend frameworks</li>
<li>DevOps pipelines</li>
</ul>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>cURL may look scary at first.</p>
<p>But it’s actually one of the <strong>most empowering tools</strong> for developers.</p>
<p>You don’t need UI.
You don’t need frameworks.
You just talk directly to servers.</p>
<p>If you master the basics of cURL, you’ll never feel blind while working with APIs again.</p>
]]></content:encoded></item><item><title><![CDATA[DNS Record Types Explained]]></title><description><![CDATA[Let’s start with a simple question:

How does your browser know where a website lives?

When you type google.com, your browser doesn’t magically understand where Google’s servers are located.
It asks DNS for help.
And DNS answers using something call...]]></description><link>https://blog.subhrangsu.in/dns-record-types-explained</link><guid isPermaLink="true">https://blog.subhrangsu.in/dns-record-types-explained</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[dns]]></category><category><![CDATA[NsRecords]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Wed, 28 Jan 2026 20:32:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769632048013/2b91ff8b-ebda-43b7-a6cd-bf247d8741c9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Let’s start with a simple question:</p>
<blockquote>
<p>How does your browser know where a website lives?</p>
</blockquote>
<p>When you type <code>google.com</code>, your browser doesn’t magically understand where Google’s servers are located.
It asks DNS for help.</p>
<p>And DNS answers using something called <strong>DNS records</strong>.</p>
<p>In this blog, we’ll understand what DNS records are, why they exist, and what each common record type actually does — without scary technical language.</p>
<hr />
<h2 id="heading-what-is-dns">What Is DNS?</h2>
<p>DNS is the <strong>phonebook of the internet</strong>.</p>
<p>Humans use names like:</p>
<ul>
<li>google.com</li>
<li>amazon.com</li>
<li>mywebsite.dev</li>
</ul>
<p>Computers use numbers like:</p>
<ul>
<li>142.250.183.110</li>
<li>54.239.28.85</li>
</ul>
<p>DNS exists to translate:</p>
<blockquote>
<p>Website name → Server address</p>
</blockquote>
<p>Without DNS, you would need to remember IP addresses to open websites. That would be painful.</p>
<hr />
<h2 id="heading-why-dns-records-are-needed">Why DNS Records Are Needed</h2>
<p>DNS itself is just a system.</p>
<p>The <strong>real information lives inside DNS records</strong>.</p>
<p>DNS records tell the internet:</p>
<ul>
<li>Where your website server is</li>
<li>Who manages your domain</li>
<li>Where emails should be delivered</li>
<li>How domain ownership is verified</li>
<li>Which name points to which service</li>
</ul>
<p>Think of DNS records as <strong>instructions stored for your domain</strong>.</p>
<p>Now let’s understand them one by one.</p>
<hr />
<h2 id="heading-what-is-an-ns-record-who-is-responsible-for-this-domain">What Is an NS Record? (Who Is Responsible for This Domain?)</h2>
<p>NS means <strong>Name Server</strong>.</p>
<p>NS records answer this question:</p>
<blockquote>
<p>Which server is responsible for managing this domain’s DNS?</p>
</blockquote>
<h3 id="heading-real-life-example">Real-Life Example</h3>
<p>Imagine you register a new house.</p>
<p>You must tell the government:</p>
<blockquote>
<p>Which office manages my address record?</p>
</blockquote>
<p>NS records do the same thing for domains.</p>
<hr />
<h3 id="heading-what-ns-records-do">What NS Records Do</h3>
<ul>
<li>Point to authoritative DNS servers</li>
<li>Decide who controls the domain’s DNS settings</li>
<li>Enable delegation</li>
</ul>
<p>Example:</p>
<pre><code>google.com → ns1.google.com
</code></pre><p>It means:</p>
<blockquote>
<p>Google’s DNS servers manage google.com records.</p>
</blockquote>
<hr />
<h2 id="heading-what-is-an-a-record-domain-ipv4-address">What Is an A Record? (Domain → IPv4 Address)</h2>
<p>A record is the <strong>most important DNS record</strong>.</p>
<p>It answers:</p>
<blockquote>
<p>What is the IPv4 address of this domain?</p>
</blockquote>
<p>Example:</p>
<pre><code>google.com → <span class="hljs-number">142.250</span><span class="hljs-number">.183</span><span class="hljs-number">.110</span>
</code></pre><h3 id="heading-real-life-example-1">Real-Life Example</h3>
<p>Your house name: “Blue Villa”
Actual address: “Street 10, Building 25”</p>
<p>A record is that <strong>actual address</strong>.</p>
<p>When users open your website, browsers use A records to find your server.</p>
<hr />
<h2 id="heading-what-is-an-aaaa-record-domain-ipv6-address">What Is an AAAA Record? (Domain → IPv6 Address)</h2>
<p>AAAA record does the same job as A record — but for <strong>IPv6 addresses</strong>.</p>
<p>Why four A’s?</p>
<p>Because IPv6 addresses are much longer.</p>
<p>Example:</p>
<pre><code>google.com → <span class="hljs-number">2607</span>:f8b0:<span class="hljs-number">4009</span>:<span class="hljs-number">80</span>b::<span class="hljs-number">200</span>e
</code></pre><hr />
<h3 id="heading-why-aaaa-records-exist">Why AAAA Records Exist</h3>
<p>The internet is running out of IPv4 addresses.</p>
<p>IPv6 was introduced to solve this.</p>
<p>Modern systems often support both:</p>
<ul>
<li>A record (IPv4)</li>
<li>AAAA record (IPv6)</li>
</ul>
<p>Your browser automatically chooses the best one.</p>
<hr />
<h2 id="heading-what-is-a-cname-record-one-name-pointing-to-another-name">What Is a CNAME Record? (One Name Pointing to Another Name)</h2>
<p>CNAME means <strong>Canonical Name</strong>.</p>
<p>It answers:</p>
<blockquote>
<p>This domain is an alias of another domain.</p>
</blockquote>
<h3 id="heading-example">Example</h3>
<pre><code>www.mywebsite.com → mywebsite.com
</code></pre><p>Here:</p>
<ul>
<li>www is not pointing to an IP</li>
<li>It points to another domain name</li>
</ul>
<p>DNS will then resolve the final IP from that target.</p>
<hr />
<h3 id="heading-real-life-example-2">Real-Life Example</h3>
<p>Your nickname: “Alex”
Official name: “Alexander Smith”</p>
<p>CNAME is like saying:</p>
<blockquote>
<p>Alex is the same person as Alexander.</p>
</blockquote>
<hr />
<h3 id="heading-common-beginner-confusion-a-vs-cname">Common Beginner Confusion: A vs CNAME</h3>
<ul>
<li><strong>A Record</strong> → Points to IP address</li>
<li><strong>CNAME Record</strong> → Points to another domain name</li>
</ul>
<p>Simple rule:</p>
<blockquote>
<p>If you already have an IP, use A.
If you want aliasing, use CNAME.</p>
</blockquote>
<hr />
<h2 id="heading-what-is-an-mx-record-how-emails-find-your-mail-server">What Is an MX Record? (How Emails Find Your Mail Server)</h2>
<p>MX means <strong>Mail Exchange</strong>.</p>
<p>MX records answer:</p>
<blockquote>
<p>Where should emails for this domain be delivered?</p>
</blockquote>
<p>Example:</p>
<pre><code>example.com → mail.google.com
</code></pre><hr />
<h3 id="heading-why-mx-records-are-needed">Why MX Records Are Needed</h3>
<p>Your website server and email server are often different.</p>
<p>MX records allow:</p>
<ul>
<li>Gmail</li>
<li>Outlook</li>
<li>Zoho Mail</li>
</ul>
<p>to handle emails for your domain.</p>
<p>Without MX records:</p>
<blockquote>
<p>Emails sent to your domain will fail.</p>
</blockquote>
<hr />
<h3 id="heading-common-beginner-confusion-ns-vs-mx">Common Beginner Confusion: NS vs MX</h3>
<ul>
<li><strong>NS Record</strong> → Who manages DNS</li>
<li><strong>MX Record</strong> → Who receives emails</li>
</ul>
<p>They solve completely different problems.</p>
<hr />
<h2 id="heading-what-is-a-txt-record-extra-information-amp-verification">What Is a TXT Record? (Extra Information &amp; Verification)</h2>
<p>TXT records store <strong>text-based data</strong>.</p>
<p>They are commonly used for:</p>
<ul>
<li>Domain ownership verification</li>
<li>Email security (SPF, DKIM, DMARC)</li>
<li>Third-party service validation</li>
</ul>
<hr />
<h3 id="heading-example-uses">Example Uses</h3>
<ul>
<li>Google Search Console verification</li>
<li>Cloudflare verification</li>
<li>Email spam protection rules</li>
</ul>
<p>Example:</p>
<pre><code>v=spf1 include:_spf.google.com ~all
</code></pre><p>Looks confusing, but it simply tells:</p>
<blockquote>
<p>Which mail servers are allowed to send emails for this domain.</p>
</blockquote>
<hr />
<h2 id="heading-how-all-dns-records-work-together-real-website-example">How All DNS Records Work Together (Real Website Example)</h2>
<p>Let’s say you own:</p>
<pre><code>mywebsite.com
</code></pre><p>Here’s how DNS records work together:</p>
<hr />
<h3 id="heading-step-1-ns-record">Step 1 — NS Record</h3>
<p>Tells the internet:</p>
<blockquote>
<p>Cloudflare manages this domain.</p>
</blockquote>
<hr />
<h3 id="heading-step-2-a-record">Step 2 — A Record</h3>
<p>Maps domain to server:</p>
<pre><code>mywebsite.com → <span class="hljs-number">103.21</span><span class="hljs-number">.59</span><span class="hljs-number">.22</span>
</code></pre><p>Your website loads using this.</p>
<hr />
<h3 id="heading-step-3-cname-record">Step 3 — CNAME Record</h3>
<p>Maps subdomain:</p>
<pre><code>www.mywebsite.com → mywebsite.com
</code></pre><p>Both URLs work.</p>
<hr />
<h3 id="heading-step-4-mx-record">Step 4 — MX Record</h3>
<p>Handles email:</p>
<pre><code>mywebsite.com → Gmail mail servers
</code></pre><p>Your email works.</p>
<hr />
<h3 id="heading-step-5-txt-record">Step 5 — TXT Record</h3>
<p>Adds security and verification:</p>
<ul>
<li>Email protection</li>
<li>Domain ownership</li>
<li>Platform verification</li>
</ul>
<hr />
<p>All these records together make your website:</p>
<ul>
<li>Accessible</li>
<li>Secure</li>
<li>Email enabled</li>
<li>Globally reachable</li>
</ul>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>DNS records may look confusing at first.</p>
<p>But when you see them as <strong>problem solvers</strong>, everything becomes simpler:</p>
<ul>
<li>NS → Who manages domain</li>
<li>A → Where website lives</li>
<li>AAAA → IPv6 version</li>
<li>CNAME → Alias mapping</li>
<li>MX → Email delivery</li>
<li>TXT → Verification &amp; security</li>
</ul>
<p>If you are learning backend, DevOps, cloud, or system design — DNS is not optional knowledge.</p>
<p>It is foundational.</p>
]]></content:encoded></item><item><title><![CDATA[How DNS Resolution Works: From Domain Name to IP Address]]></title><description><![CDATA[Every time you open a website like google.com, your browser magically knows where to send the request.
But behind this “magic” is a system called DNS (Domain Name System) — one of the most important pillars of the internet.
In this blog, we’ll break ...]]></description><link>https://blog.subhrangsu.in/how-dns-resolution-works-from-domain-name-to-ip-address</link><guid isPermaLink="true">https://blog.subhrangsu.in/how-dns-resolution-works-from-domain-name-to-ip-address</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[dns]]></category><category><![CDATA[dns-records]]></category><category><![CDATA[#TLD]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Wed, 28 Jan 2026 18:58:51 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769626573294/f86a9a9e-9cea-48c9-8065-149ef854076e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every time you open a website like <code>google.com</code>, your browser magically knows where to send the request.</p>
<p>But behind this “magic” is a system called <strong>DNS (Domain Name System)</strong> — one of the most important pillars of the internet.</p>
<p>In this blog, we’ll break down how DNS resolution works, what the <code>dig</code> command shows us, and how requests move through root servers, TLD servers, and authoritative servers before reaching the final IP address.</p>
<p>Let’s start with the basics.</p>
<hr />
<h2 id="heading-what-is-dns-and-why-name-resolution-exists">What Is DNS and Why Name Resolution Exists?</h2>
<p>DNS is often called the <strong>internet’s phonebook</strong>.</p>
<p>Humans prefer names like:</p>
<ul>
<li>google.com</li>
<li>github.com</li>
<li>api.myapp.com</li>
</ul>
<p>But computers only understand <strong>IP addresses</strong>, such as:</p>
<ul>
<li>142.250.183.110</li>
<li>20.207.73.82</li>
</ul>
<p>DNS exists to solve this problem.</p>
<blockquote>
<p>DNS converts human-readable domain names into machine-readable IP addresses.</p>
</blockquote>
<p>Without DNS, you would need to remember numeric IP addresses for every website — not very practical.</p>
<hr />
<h2 id="heading-where-dns-fits-in-a-real-request-flow">Where DNS Fits in a Real Request Flow</h2>
<p>When you type <code>google.com</code> in your browser:</p>
<ol>
<li>Browser asks OS for IP</li>
<li>OS checks local cache</li>
<li>If not found → asks DNS resolver</li>
<li>Resolver talks to multiple DNS servers</li>
<li>Final IP is returned</li>
<li>Browser connects to server</li>
</ol>
<p>This lookup happens in milliseconds.</p>
<p>Now let’s see how we can observe this process ourselves.</p>
<hr />
<h2 id="heading-what-is-the-dig-command-and-when-is-it-used">What Is the <code>dig</code> Command and When Is It Used?</h2>
<p><code>dig</code> stands for <strong>Domain Information Groper</strong>.</p>
<p>It is a command-line tool used to:</p>
<ul>
<li>Inspect DNS records</li>
<li>Debug DNS issues</li>
<li>Understand resolution paths</li>
<li>Check authoritative servers</li>
<li>Analyze TTL and response details</li>
</ul>
<h3 id="heading-example">Example:</h3>
<pre><code class="lang-bash">dig google.com
</code></pre>
<p>This command shows:</p>
<ul>
<li>Which IP address is returned</li>
<li>Which server answered</li>
<li>Query time</li>
<li>Record type (A, AAAA, NS, etc.)</li>
</ul>
<p>For backend engineers and DevOps teams, <code>dig</code> is a daily troubleshooting tool.</p>
<hr />
<h2 id="heading-understanding-dns-resolution-layers">Understanding DNS Resolution Layers</h2>
<p>DNS does not work with a single server.</p>
<p>It works in <strong>layers</strong>, like asking directions step by step.</p>
<p>The resolution flow looks like this:</p>
<pre><code>Root Server → TLD Server → Authoritative Server → IP Address
</code></pre><p>Let’s explore each layer using <code>dig</code>.</p>
<hr />
<h2 id="heading-understanding-dig-ns-root-name-servers">Understanding <code>dig . NS</code> (Root Name Servers)</h2>
<p>Let’s query the root of DNS:</p>
<pre><code class="lang-bash">dig . NS
</code></pre>
<p>This asks:</p>
<blockquote>
<p>Who manages the top-level DNS system?</p>
</blockquote>
<h3 id="heading-what-youll-see">What You’ll See</h3>
<p>You’ll get a list like:</p>
<ul>
<li>a.root-servers.net</li>
<li>b.root-servers.net</li>
<li>c.root-servers.net
...</li>
</ul>
<p>These are called <strong>root name servers</strong>.</p>
<hr />
<h3 id="heading-what-do-root-servers-do">What Do Root Servers Do?</h3>
<p>Root servers:</p>
<ul>
<li>Do NOT store IP addresses of websites</li>
<li>Only tell you where to find TLD servers</li>
</ul>
<p>Think of root servers as:</p>
<blockquote>
<p>The receptionist of the internet.</p>
</blockquote>
<p>They don’t know your final destination — but they know <strong>who can help you next</strong>.</p>
<hr />
<h2 id="heading-understanding-dig-com-ns-tld-name-servers">Understanding <code>dig com NS</code> (TLD Name Servers)</h2>
<p>Now let’s ask about <code>.com</code>:</p>
<pre><code class="lang-bash">dig com NS
</code></pre>
<p>This queries:</p>
<blockquote>
<p>Who manages all .com domains?</p>
</blockquote>
<h3 id="heading-what-youll-see-1">What You’ll See</h3>
<p>You’ll get servers like:</p>
<ul>
<li>a.gtld-servers.net</li>
<li>b.gtld-servers.net
...</li>
</ul>
<p>These are <strong>TLD (Top-Level Domain) servers</strong>.</p>
<hr />
<h3 id="heading-what-do-tld-servers-do">What Do TLD Servers Do?</h3>
<p>TLD servers:</p>
<ul>
<li>Know which authoritative servers manage specific domains</li>
<li>Handle domains like:<ul>
<li>.com</li>
<li>.org</li>
<li>.net</li>
<li>.in</li>
</ul>
</li>
</ul>
<p>They don’t know Google’s IP — but they know:</p>
<blockquote>
<p>Which name server is responsible for google.com.</p>
</blockquote>
<hr />
<h2 id="heading-understanding-dig-googlecom-ns-authoritative-name-servers">Understanding <code>dig google.com NS</code> (Authoritative Name Servers)</h2>
<p>Now let’s ask:</p>
<pre><code class="lang-bash">dig google.com NS
</code></pre>
<p>This tells us:</p>
<blockquote>
<p>Which servers are authoritative for google.com?</p>
</blockquote>
<h3 id="heading-example-output">Example Output</h3>
<p>You’ll see something like:</p>
<ul>
<li>ns1.google.com</li>
<li>ns2.google.com</li>
<li>ns3.google.com</li>
</ul>
<p>These are <strong>authoritative name servers</strong>.</p>
<hr />
<h3 id="heading-what-are-authoritative-servers">What Are Authoritative Servers?</h3>
<p>Authoritative servers:</p>
<ul>
<li>Store the actual DNS records</li>
<li>Return final IP addresses</li>
<li>Are controlled by domain owners</li>
</ul>
<p>This is the final authority.</p>
<p>If Google changes its IP, the authoritative server is updated first.</p>
<hr />
<h2 id="heading-understanding-dig-googlecom-full-dns-resolution">Understanding <code>dig google.com</code> (Full DNS Resolution)</h2>
<p>Now the main command:</p>
<pre><code class="lang-bash">dig google.com
</code></pre>
<p>This returns:</p>
<ul>
<li>A record (IPv4 address)</li>
<li>AAAA record (IPv6 address)</li>
<li>TTL values</li>
<li>Response flags</li>
</ul>
<p>Example:</p>
<pre><code>google.com.  <span class="hljs-number">300</span>  IN  A  <span class="hljs-number">142.250</span><span class="hljs-number">.183</span><span class="hljs-number">.110</span>
</code></pre><p>This means:</p>
<ul>
<li>Domain: google.com</li>
<li>Record type: A</li>
<li>IP address: 142.250.183.110</li>
<li>Cache duration: 300 seconds</li>
</ul>
<hr />
<h2 id="heading-what-actually-happens-behind-the-scenes">What Actually Happens Behind the Scenes?</h2>
<p>When you run <code>dig google.com</code>, your system’s <strong>recursive resolver</strong> does the heavy lifting.</p>
<p>Here’s what it does internally:</p>
<ol>
<li>Ask root server → where is .com?</li>
<li>Ask TLD server → where is google.com?</li>
<li>Ask authoritative server → give IP</li>
<li>Cache result</li>
<li>Return IP to client</li>
</ol>
<p>This avoids repeating work for future queries.</p>
<hr />
<h2 id="heading-why-ns-records-matter">Why NS Records Matter</h2>
<p>NS (Name Server) records tell DNS:</p>
<blockquote>
<p>Who is responsible for this domain?</p>
</blockquote>
<p>They enable:</p>
<ul>
<li>Delegation of control</li>
<li>High availability</li>
<li>Load distribution</li>
<li>Fault tolerance</li>
</ul>
<p>Without NS records, DNS hierarchy would break.</p>
<hr />
<h2 id="heading-how-browsers-use-this-information">How Browsers Use This Information</h2>
<p>When your browser requests:</p>
<pre><code>https:<span class="hljs-comment">//google.com</span>
</code></pre><p>DNS resolution happens first.</p>
<p>Only after IP is resolved:</p>
<ul>
<li>TCP handshake starts</li>
<li>TLS handshake happens</li>
<li>HTTP request is sent</li>
</ul>
<p>If DNS fails:</p>
<ul>
<li>Website never loads</li>
<li>Server is never contacted</li>
</ul>
<p>This is why DNS is considered <strong>critical infrastructure</strong>.</p>
<hr />
<h2 id="heading-dns-and-system-design-perspective">DNS and System Design Perspective</h2>
<p>For backend and system designers, DNS is not just theory.</p>
<p>It impacts:</p>
<ul>
<li>API latency</li>
<li>Global traffic routing</li>
<li>Failover strategies</li>
<li>Multi-region deployments</li>
</ul>
<p>Examples:</p>
<ul>
<li>Using geo-based DNS routing</li>
<li>Load balancing via DNS</li>
<li>Blue-green deployments using DNS switching</li>
<li>Zero-downtime migrations</li>
</ul>
<p>Big systems rely heavily on DNS strategies.</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>DNS is not magic.</p>
<p>It is a <strong>layered, distributed, fault-tolerant system</strong> that quietly works every time you open a website.</p>
<p>Understanding:</p>
<ul>
<li>Root servers</li>
<li>TLD servers</li>
<li>Authoritative servers</li>
<li>dig command</li>
<li>Resolution flow</li>
</ul>
<p>makes you a stronger engineer — especially when working with production systems.</p>
<p>Next time your website loads instantly, remember:</p>
<p>DNS made the first move.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding Network Devices: How the Internet Actually Reaches Your Application]]></title><description><![CDATA[When you open a website, watch a YouTube video, or call an API, data travels through multiple invisible roads before reaching you.
Behind this “simple click” experience are several network devices working together — each with a specific responsibilit...]]></description><link>https://blog.subhrangsu.in/understanding-network-devices-how-the-internet-actually-reaches-your-application</link><guid isPermaLink="true">https://blog.subhrangsu.in/understanding-network-devices-how-the-internet-actually-reaches-your-application</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[networking]]></category><category><![CDATA[dns]]></category><category><![CDATA[network]]></category><category><![CDATA[router]]></category><category><![CDATA[SWITCH]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Wed, 28 Jan 2026 18:45:31 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769625674200/8e1d5839-cace-4616-8baf-01d1b12b366b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When you open a website, watch a YouTube video, or call an API, data travels through multiple invisible roads before reaching you.</p>
<p>Behind this “simple click” experience are several <strong>network devices working together</strong> — each with a specific responsibility.</p>
<p>In this blog, we’ll understand how the internet reaches your home or office, what each network device does, and why software engineers should care about them.</p>
<p>Let’s start from the outside world.</p>
<hr />
<h2 id="heading-high-level-view-how-internet-reaches-your-home-or-office">High-Level View: How Internet Reaches Your Home or Office</h2>
<p>Imagine the internet as a <strong>global highway system</strong>.</p>
<p>Your data starts from a server (maybe in another country), travels through ISP infrastructure, fiber cables, data centers, and finally reaches your building.</p>
<p>Inside your home or office, the data usually flows like this:</p>
<pre><code>Internet → Modem → Router → Switch → Your Devices
                          ↓
                      Firewall
                          ↓
                     Load Balancer (<span class="hljs-keyword">in</span> large systems)
</code></pre><p>Each device has a <strong>specific job</strong>, just like workers in a logistics company.</p>
<p>Now let’s understand them one by one.</p>
<hr />
<h2 id="heading-what-is-a-modem-and-how-it-connects-you-to-the-internet">What Is a Modem and How It Connects You to the Internet?</h2>
<p>Think of a <strong>modem as a language translator</strong>.</p>
<p>Your Internet Service Provider (ISP) sends data using signals over fiber, cable, or telephone lines.
Your computer understands digital Ethernet signals.</p>
<p>The modem’s job is simple:</p>
<blockquote>
<p>Convert ISP signals into internet data your local network can use.</p>
</blockquote>
<h3 id="heading-what-a-modem-does">What a Modem Does</h3>
<ul>
<li>Talks directly to your ISP</li>
<li>Converts signal formats</li>
<li>Brings internet into your building</li>
</ul>
<p>Without a modem, your router would have nothing to connect to.</p>
<h3 id="heading-real-world-example">Real-World Example</h3>
<p>Imagine receiving a package from another country written in a foreign language.
The modem translates it so your local team can read it.</p>
<hr />
<h2 id="heading-what-is-a-router-and-how-it-directs-traffic">What Is a Router and How It Directs Traffic?</h2>
<p>If the modem brings internet inside, the <strong>router decides where the data goes</strong>.</p>
<p>A router is like a <strong>traffic police officer</strong>.</p>
<h3 id="heading-router-responsibilities">Router Responsibilities</h3>
<ul>
<li>Assigns IP addresses to devices</li>
<li>Sends data packets to the correct device</li>
<li>Connects local network to the internet</li>
<li>Handles Wi-Fi connections</li>
</ul>
<p>When your phone, laptop, and TV all use the internet at the same time, the router ensures everyone gets the right data.</p>
<h3 id="heading-simple-example">Simple Example</h3>
<p>You request Google.com on your laptop.
Your router says:</p>
<blockquote>
<p>“This request came from Laptop A, so the response should go back to Laptop A.”</p>
</blockquote>
<p>That’s routing.</p>
<hr />
<h2 id="heading-switch-vs-hub-how-local-networks-actually-work">Switch vs Hub: How Local Networks Actually Work</h2>
<p>This is where confusion usually happens.</p>
<p>Let’s clear it up simply.</p>
<hr />
<h3 id="heading-what-is-a-hub">What Is a Hub?</h3>
<p>A hub is like a <strong>loudspeaker</strong>.</p>
<p>When one device sends data:</p>
<blockquote>
<p>The hub broadcasts it to ALL connected devices.</p>
</blockquote>
<h3 id="heading-problems-with-hubs">Problems With Hubs</h3>
<ul>
<li>Wastes bandwidth</li>
<li>Causes collisions</li>
<li>No security</li>
<li>Almost obsolete today</li>
</ul>
<p>Example:</p>
<p>If PC1 sends data to PC2, every other device also receives it — even if it’s not meant for them.</p>
<hr />
<h3 id="heading-what-is-a-switch">What Is a Switch?</h3>
<p>A switch is smart.</p>
<p>It’s like a <strong>postal delivery system</strong>.</p>
<h3 id="heading-what-a-switch-does">What a Switch Does</h3>
<ul>
<li>Sends data only to the intended device</li>
<li>Uses MAC addresses to identify devices</li>
<li>Improves network speed</li>
<li>Reduces traffic congestion</li>
</ul>
<p>Example:</p>
<p>If PC1 sends data to PC2, only PC2 receives it.</p>
<hr />
<h3 id="heading-hub-vs-switch-summary">Hub vs Switch Summary</h3>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Hub</td><td>Switch</td></tr>
</thead>
<tbody>
<tr>
<td>Broadcasts data</td><td>Yes</td><td>No</td></tr>
<tr>
<td>Security</td><td>Low</td><td>High</td></tr>
<tr>
<td>Speed</td><td>Slow</td><td>Fast</td></tr>
<tr>
<td>Used today</td><td>Rare</td><td>Standard</td></tr>
</tbody>
</table>
</div><p>In modern networks, <strong>switches have replaced hubs</strong>.</p>
<hr />
<h2 id="heading-what-is-a-firewall-and-why-security-lives-here">What Is a Firewall and Why Security Lives Here?</h2>
<p>A firewall is your <strong>network security gate</strong>.</p>
<p>Imagine a security guard checking everyone entering a building.</p>
<h3 id="heading-firewall-responsibilities">Firewall Responsibilities</h3>
<ul>
<li>Blocks unauthorized traffic</li>
<li>Allows trusted connections</li>
<li>Prevents attacks</li>
<li>Filters ports and protocols</li>
</ul>
<p>It works using rules like:</p>
<ul>
<li>Allow HTTPS (443)</li>
<li>Block unknown IPs</li>
<li>Deny suspicious traffic</li>
</ul>
<h3 id="heading-why-firewalls-matter-to-developers">Why Firewalls Matter to Developers</h3>
<p>If your backend API is deployed on cloud servers:</p>
<ul>
<li>Firewall rules protect your database</li>
<li>Only allowed ports stay open</li>
<li>Prevent random scanning attacks</li>
</ul>
<p>This is why DevOps teams always configure firewall rules before deployment.</p>
<hr />
<h2 id="heading-what-is-a-load-balancer-and-why-scalable-systems-need-it">What Is a Load Balancer and Why Scalable Systems Need It?</h2>
<p>Now let’s move to production systems.</p>
<p>When your application grows, <strong>one server is not enough</strong>.</p>
<p>This is where load balancers come in.</p>
<p>Think of a load balancer as a <strong>toll booth manager</strong> on a busy highway.</p>
<hr />
<h3 id="heading-load-balancer-responsibilities">Load Balancer Responsibilities</h3>
<ul>
<li>Distributes traffic across multiple servers</li>
<li>Prevents server overload</li>
<li>Improves uptime</li>
<li>Enables horizontal scaling</li>
</ul>
<h3 id="heading-example-scenario">Example Scenario</h3>
<p>Suppose you have:</p>
<ul>
<li>3 backend servers</li>
<li>1 million users</li>
</ul>
<p>The load balancer decides:</p>
<ul>
<li>Request 1 → Server A</li>
<li>Request 2 → Server B</li>
<li>Request 3 → Server C</li>
</ul>
<p>This keeps your app fast and reliable.</p>
<hr />
<h2 id="heading-how-all-these-devices-work-together-real-world-flow">How All These Devices Work Together (Real-World Flow)</h2>
<p>Let’s see the full journey when a user opens your website.</p>
<h3 id="heading-step-by-step-flow">Step-by-Step Flow</h3>
<ol>
<li>User enters website URL</li>
<li>Request reaches ISP</li>
<li>Modem converts ISP signal</li>
<li>Router routes traffic inside network</li>
<li>Firewall checks security rules</li>
<li>Load balancer distributes request</li>
<li>Backend server responds</li>
<li>Response goes back through same path</li>
</ol>
<p>All of this happens in milliseconds.</p>
<p>Invisible. Automatic. Powerful.</p>
<hr />
<h2 id="heading-where-these-devices-sit-in-system-architecture">Where These Devices Sit in System Architecture</h2>
<p>Here’s a simple architecture view:</p>
<pre><code>Internet
   |
 Modem
   |
 Router
   |
 Firewall
   |
 Load Balancer
   |
 Backend Servers
   |
 Database
</code></pre><p>In cloud platforms like AWS, Azure, and GCP:</p>
<ul>
<li>Modems and routers are virtual</li>
<li>Firewalls become security groups</li>
<li>Load balancers are managed services</li>
</ul>
<p>But the <strong>core concepts remain the same</strong>.</p>
<hr />
<h2 id="heading-why-software-engineers-should-care-about-network-devices">Why Software Engineers Should Care About Network Devices</h2>
<p>You may think:</p>
<blockquote>
<p>“I write code. Why should I learn networking?”</p>
</blockquote>
<p>Because real-world production issues are not always code bugs.</p>
<p>Examples:</p>
<ul>
<li>API not accessible due to firewall rules</li>
<li>Server overload without load balancer</li>
<li>Network latency issues</li>
<li>Wrong routing configurations</li>
</ul>
<p>Understanding these basics makes you:</p>
<ul>
<li>Better backend developer</li>
<li>Better DevOps engineer</li>
<li>More production-ready</li>
</ul>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>Network devices are not just hardware boxes sitting in server rooms.</p>
<p>They are the <strong>invisible backbone of every application you build</strong>.</p>
<p>From a simple website to large-scale cloud systems:</p>
<ul>
<li>Modems connect you to the world</li>
<li>Routers guide traffic</li>
<li>Switches manage local communication</li>
<li>Firewalls protect your system</li>
<li>Load balancers enable scale</li>
</ul>
<p>If you want to become a serious engineer, learning how data moves is just as important as learning how to code.</p>
]]></content:encoded></item><item><title><![CDATA[Git for Beginners: From “What Is This?” to Your First Commit]]></title><description><![CDATA[Have you ever worked on a project, made a mistake, and wished you could just “Control + Z” your entire life back to two hours ago?
Or collaborated on a group project where everyone emailed files named:
final_v2_REALLY_FINAL.docx
That frustration is e...]]></description><link>https://blog.subhrangsu.in/git-for-beginners-from-what-is-this-to-your-first-commit</link><guid isPermaLink="true">https://blog.subhrangsu.in/git-for-beginners-from-what-is-this-to-your-first-commit</guid><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[version control]]></category><category><![CDATA[Git Commands]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Mon, 12 Jan 2026 18:45:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768243390331/a1aeef22-189f-42b5-b0bb-b1bf7f9cc9a3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Have you ever worked on a project, made a mistake, and wished you could just <strong>“Control + Z” your entire life</strong> back to two hours ago?
Or collaborated on a group project where everyone emailed files named:</p>
<pre><code>final_v2_REALLY_FINAL.docx
</code></pre><p>That frustration is exactly why <strong>Git</strong> exists.</p>
<h2 id="heading-what-is-git">What Is Git?</h2>
<p>Git is a <strong>Version Control System (VCS)</strong>.</p>
<p>Think of it as a <strong>high-tech “Save Game” system for your code</strong>.
Instead of overwriting files, Git records <strong>snapshots</strong> of your project over time.</p>
<p>This allows you to:</p>
<ul>
<li>Go back in time</li>
<li>Experiment safely</li>
<li>Work with others without breaking each other’s code</li>
</ul>
<blockquote>
<p>📌 Git is the tool.
GitHub / GitLab are places where Git repositories are stored remotely.</p>
</blockquote>
<hr />
<h2 id="heading-why-do-we-use-git">Why Do We Use Git?</h2>
<p>Git solves real developer problems:</p>
<ul>
<li><strong>History</strong> – See what changed, when, and why</li>
<li><strong>Safety</strong> – Broke something? Revert instantly</li>
<li><strong>Collaboration</strong> – Multiple developers, zero chaos</li>
</ul>
<hr />
<h2 id="heading-core-git-terminologies-very-important">Core Git Terminologies (Very Important)</h2>
<p>Before touching commands, you need Git’s mental model.</p>
<hr />
<h3 id="heading-1-repository-repo">1. Repository (Repo)</h3>
<p>A <strong>repository</strong> is a project tracked by Git.</p>
<ul>
<li><strong>Local repository</strong> → on your computer</li>
<li><strong>Remote repository</strong> → on GitHub / GitLab / Bitbucket</li>
</ul>
<p>When you run:</p>
<pre><code class="lang-bash">git init
</code></pre>
<p>Git creates a hidden folder:</p>
<pre><code>.git/
</code></pre><p>📌 This <code>.git</code> folder is the <strong>brain of Git</strong>
Everything lives here: commits, branches, history, and HEAD.</p>
<hr />
<h3 id="heading-2-working-directory">2. Working Directory</h3>
<p>This is where you:</p>
<ul>
<li>Write code</li>
<li>Edit files</li>
<li>Delete files</li>
</ul>
<p>Example:</p>
<pre><code>index.html
app.js
style.css
</code></pre><p>⚠️ These files are <strong>not tracked automatically</strong>.</p>
<hr />
<h3 id="heading-3-staging-area-the-most-important-concept">3. Staging Area (The Most Important Concept)</h3>
<p>Git does <strong>not</strong> commit directly from your files.</p>
<p>Instead, it uses a middle layer:</p>
<pre><code>Working Directory
       ↓ git add
Staging Area
       ↓ git commit
Repository (.git)
</code></pre><p>Why does the staging area exist?</p>
<ul>
<li>Lets you choose <strong>what to save</strong></li>
<li>Prevents accidental commits</li>
<li>Gives fine-grained control</li>
</ul>
<hr />
<h3 id="heading-4-commit">4. Commit</h3>
<p>A <strong>commit</strong> is a <strong>snapshot of your project at a moment in time</strong>.</p>
<p>Each commit:</p>
<ul>
<li>Has a <strong>unique hash</strong></li>
<li>Stores file snapshots</li>
<li>Points to the previous commit</li>
</ul>
<p>Think of it as:</p>
<blockquote>
<p>🎮 “Save checkpoint with a message”</p>
</blockquote>
<hr />
<h3 id="heading-5-commit-hash">5. Commit Hash</h3>
<p>Example history:</p>
<pre><code>commit <span class="hljs-number">1</span> → hash<span class="hljs-number">-01</span>
commit <span class="hljs-number">2</span> → hash<span class="hljs-number">-02</span>
commit <span class="hljs-number">3</span> → hash<span class="hljs-number">-03</span>
</code></pre><p>A <strong>hash</strong> is used to:</p>
<ul>
<li>Compare changes</li>
<li>Revert versions</li>
<li>Reset history</li>
</ul>
<hr />
<h3 id="heading-6-head-internal-but-critical">6. HEAD (Internal but Critical)</h3>
<p><strong>HEAD points to the current branch, which points to the latest commit.</strong></p>
<pre><code>commit<span class="hljs-number">-01</span> ← commit<span class="hljs-number">-02</span> ← commit<span class="hljs-number">-03</span>
                              ↑
                             HEAD
</code></pre><ul>
<li>New commit → HEAD moves forward</li>
<li>Reset → HEAD moves backward</li>
</ul>
<hr />
<h2 id="heading-the-git-workflow-how-it-works-inside">The Git Workflow: How It Works Inside</h2>
<p>Every Git workflow follows this exact path:</p>
<ol>
<li>Modify files in the <strong>Working Directory</strong></li>
<li>Add selected changes to the <strong>Staging Area</strong></li>
<li>Commit them to the <strong>Repository</strong></li>
</ol>
<p>Once this clicks, Git becomes easy.</p>
<hr />
<h2 id="heading-essential-git-commands-90-daily-use">Essential Git Commands (90% Daily Use)</h2>
<hr />
<h3 id="heading-1-start-a-project">1. Start a Project</h3>
<pre><code class="lang-bash">git init
</code></pre>
<p>Initializes a Git repository.</p>
<p>To see the hidden folder:</p>
<pre><code class="lang-bash">ls -a
</code></pre>
<hr />
<h3 id="heading-2-track-changes">2. Track Changes</h3>
<pre><code class="lang-bash">git status
</code></pre>
<p>Shows:</p>
<ul>
<li>Untracked files (<strong>U</strong>)</li>
<li>Modified files (<strong>M</strong>)</li>
<li>Staged files</li>
</ul>
<pre><code class="lang-bash">git add filename
</code></pre>
<p>Or add everything:</p>
<pre><code class="lang-bash">git add .
</code></pre>
<p>Moves files:</p>
<pre><code>Working Directory → Staging Area
</code></pre><hr />
<h3 id="heading-3-commit-changes">3. Commit Changes</h3>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"Initial commit"</span>
</code></pre>
<p>This:</p>
<ul>
<li>Saves staged changes</li>
<li>Creates a new commit</li>
<li>Moves HEAD forward</li>
</ul>
<hr />
<h3 id="heading-4-inspect-history">4. Inspect History</h3>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span>
</code></pre>
<p>Short version:</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<p>Example:</p>
<pre><code>a1b2c3d Added feature
b2c3d4e Fixed bug
c3d4e5f Initial commit
</code></pre><hr />
<h3 id="heading-5-see-what-changed">5. See What Changed</h3>
<pre><code class="lang-bash">git diff
</code></pre>
<p>Compare commits:</p>
<pre><code class="lang-bash">git diff &lt;hash1&gt; &lt;hash2&gt;
</code></pre>
<hr />
<h2 id="heading-understanding-git-internals">Understanding Git Internals</h2>
<h3 id="heading-commit-chain-linked-list">Commit Chain (Linked List)</h3>
<pre><code>Commit<span class="hljs-number">-01</span> ← Commit<span class="hljs-number">-02</span> ← Commit<span class="hljs-number">-03</span> ← Commit<span class="hljs-number">-04</span>
                                         ↑
                                        HEAD
</code></pre><p>Each commit stores:</p>
<ul>
<li>Snapshot of files</li>
<li>Reference to the previous commit</li>
</ul>
<p>This is why Git is <strong>fast and reliable</strong>.</p>
<hr />
<h2 id="heading-peeking-inside-git-objects-with-git-cat-file">Peeking Inside Git Objects with <code>git cat-file</code></h2>
<p>Git stores everything (commits, files, folders) as <strong>objects</strong> inside the <code>.git</code> directory.</p>
<p>The command that lets us inspect these objects is:</p>
<pre><code class="lang-bash">git cat-file -p &lt;commit-hash&gt;
</code></pre>
<h3 id="heading-example-inspect-a-commit-object">Example: Inspect a Commit Object</h3>
<pre><code class="lang-bash">git cat-file -p 2b3f9a
</code></pre>
<p>(Git allows <strong>short hashes</strong> as long as they uniquely identify the object.)</p>
<p>Output looks like:</p>
<pre><code>tree a3f5c9...
parent <span class="hljs-number">91</span>ab2d...
author John Doe &lt;john@email.com&gt;
committer John Doe &lt;john@email.com&gt;

Initial project setup
</code></pre><h3 id="heading-what-youre-seeing">What You’re Seeing</h3>
<ul>
<li><strong>tree</strong> → snapshot of files</li>
<li><strong>parent</strong> → previous commit</li>
<li><strong>author / committer</strong> → who made the change</li>
<li><strong>message</strong> → commit message</li>
</ul>
<p>📌 Git commits don’t store diffs — they store <strong>snapshots + references</strong>.</p>
<hr />
<h2 id="heading-branching-visualized">Branching (Visualized)</h2>
<p>A <strong>branch is just a pointer to a commit</strong>.</p>
<pre><code>main:     A → B → C → D
                 \
<span class="hljs-attr">feature</span>:           E → F
</code></pre><p>HEAD switches between branches.</p>
<pre><code class="lang-bash">git branch
</code></pre>
<p>Check HEAD directly:</p>
<pre><code class="lang-bash">cat .git/HEAD
</code></pre>
<hr />
<h2 id="heading-undoing-changes">Undoing Changes</h2>
<h3 id="heading-safe-undo-recommended">Safe Undo (Recommended)</h3>
<pre><code class="lang-bash">git revert &lt;<span class="hljs-built_in">hash</span>&gt;
</code></pre>
<p>Creates a <strong>new commit</strong> that undoes a previous one
(best for shared projects).</p>
<hr />
<h3 id="heading-dangerous-undo">⚠️ Dangerous Undo</h3>
<pre><code class="lang-bash">git reset --hard &lt;<span class="hljs-built_in">hash</span>&gt;
</code></pre>
<p>What it does:</p>
<ul>
<li>Moves HEAD backward</li>
<li>Deletes commits after it</li>
<li>Resets files completely</li>
</ul>
<p>Use <strong>only when you know what you’re doing</strong>.</p>
<hr />
<h2 id="heading-a-typical-beginner-workflow">A Typical Beginner Workflow</h2>
<ol>
<li>Initialize → <code>git init</code></li>
<li>Create file → <code>index.html</code></li>
<li>Check → <code>git status</code></li>
<li>Stage → <code>git add index.html</code></li>
<li>Commit → <code>git commit -m "Initial project setup"</code></li>
<li>Review → <code>git log --oneline</code></li>
</ol>
<hr />
<h2 id="heading-git-working-areas-final-summary">Git Working Areas (Final Summary)</h2>
<pre><code>[ Working Directory ]
        ↓ git add
[ Staging Area ]
        ↓ git commit
[ Repository (.git) ]
</code></pre><p>This is <strong>the heart of Git</strong>.</p>
<hr />
<h2 id="heading-git-cheatsheet-everything-we-learned">Git Cheatsheet (Everything We Learned)</h2>
<h3 id="heading-repository-amp-setup">Repository &amp; Setup</h3>
<pre><code class="lang-bash">git init
ls -a
</code></pre>
<h3 id="heading-checking-state">Checking State</h3>
<pre><code class="lang-bash">git status
</code></pre>
<h3 id="heading-staging">Staging</h3>
<pre><code class="lang-bash">git add &lt;file&gt;
git add .
</code></pre>
<h3 id="heading-committing">Committing</h3>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"message"</span>
</code></pre>
<h3 id="heading-history">History</h3>
<pre><code class="lang-bash">git <span class="hljs-built_in">log</span>
git <span class="hljs-built_in">log</span> --oneline
</code></pre>
<h3 id="heading-differences">Differences</h3>
<pre><code class="lang-bash">git diff
git diff &lt;hash1&gt; &lt;hash2&gt;
</code></pre>
<h3 id="heading-internals">Internals</h3>
<pre><code class="lang-bash">git cat-file -p &lt;<span class="hljs-built_in">hash</span>&gt;
cat .git/HEAD
</code></pre>
<h3 id="heading-branching">Branching</h3>
<pre><code class="lang-bash">git branch
</code></pre>
<h3 id="heading-undo">Undo</h3>
<pre><code class="lang-bash">git revert &lt;<span class="hljs-built_in">hash</span>&gt;
git reset --hard &lt;<span class="hljs-built_in">hash</span>&gt;
</code></pre>
<p>If this cheatsheet makes sense —
you understand <strong>real Git</strong>, not just commands.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Git feels intimidating at first because of:</p>
<ul>
<li>Hashes</li>
<li>Commands</li>
<li>Terminal usage</li>
</ul>
<p>But once you understand:</p>
<blockquote>
<p><strong>Working Directory → Staging Area → Repository → HEAD</strong></p>
</blockquote>
<p>Git stops being scary and starts feeling powerful.</p>
<p>You’re no longer afraid of mistakes —
because <strong>Git remembers everything</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Inside Git: How It Really Works (With the `.git` Folder Explained)]]></title><description><![CDATA[Git is not magic.
Git is just a very smart storage system.

Most beginners learn Git by memorizing commands.
But the moment you visualize what Git is storing and where, everything starts to click.
In this article, we’ll understand Git using real code...]]></description><link>https://blog.subhrangsu.in/inside-git-how-it-really-works-with-the-git-folder-explained</link><guid isPermaLink="true">https://blog.subhrangsu.in/inside-git-how-it-really-works-with-the-git-folder-explained</guid><category><![CDATA[Git]]></category><category><![CDATA[version control]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[ChaiCohort]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Sun, 11 Jan 2026 09:54:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1768125050066/4afa3155-769f-4379-89cc-150adb69092e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p>Git is not magic.
Git is just a <strong>very smart storage system</strong>.</p>
</blockquote>
<p>Most beginners learn Git by memorizing commands.
But the moment you <strong>visualize what Git is storing and where</strong>, everything starts to click.</p>
<p>In this article, we’ll understand Git using <strong>real code changes</strong>, <strong>human instincts</strong>, <strong>staging</strong>, and <strong>internal storage</strong> — the same way Git actually thinks.</p>
<hr />
<h2 id="heading-the-core-problem-code-keeps-changing">The Core Problem: Code Keeps Changing</h2>
<p>Look at a simple change like this:</p>
<pre><code class="lang-diff"><span class="hljs-addition">+ const fname = 'Subhrangsu';</span>
<span class="hljs-addition">+ const lname = 'Bera';</span>
<span class="hljs-deletion">- const lname = 'Bera';</span>
const lname = '';
<span class="hljs-addition">+ // Kuch bi karoge</span>
</code></pre>
<p>In real life, code changes constantly:</p>
<ul>
<li>lines are added</li>
<li>values are removed</li>
<li>comments appear</li>
<li>logic evolves</li>
</ul>
<h3 id="heading-and-then-a-very-natural-question-comes-up">And then a very natural question comes up:</h3>
<p>👉 <strong>Where should these changes be stored safely?</strong></p>
<ul>
<li>MongoDB?</li>
<li>MySQL?</li>
<li>Postgres?</li>
<li>Text file?</li>
</ul>
<p>Before Git existed, developers genuinely struggled with this question.</p>
<hr />
<h2 id="heading-a-very-human-idea-changestxt">A Very Human Idea: <code>changes.txt</code></h2>
<p>Let’s imagine Git does <strong>not</strong> exist.</p>
<p>You decide to do something simple and logical.</p>
<p>Inside your project:</p>
<pre><code>project/
├── hello.js
└── changes.txt
</code></pre><p>Every time you change code, you <strong>imagine</strong> that this file records what changed.</p>
<h3 id="heading-example">Example</h3>
<p><code>hello.js</code></p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> fname = <span class="hljs-string">"Subhrangsu"</span>;
<span class="hljs-keyword">const</span> lname = <span class="hljs-string">""</span>;
</code></pre>
<p>You <em>imagine</em> <code>changes.txt</code> contains:</p>
<pre><code class="lang-diff"><span class="hljs-addition">+ const fname = 'Subhrangsu';</span>
<span class="hljs-addition">+ const lname = 'Bera';</span>
<span class="hljs-deletion">- const lname = 'Bera';</span>
const lname = '';
<span class="hljs-addition">+ // Kuch bi karoge</span>
</code></pre>
<p>Honestly?
This idea is <strong>very interesting</strong> — and very human.</p>
<p>Now that we have a human-style solution, let’s test it against real-world development needs.</p>
<hr />
<h2 id="heading-but-does-changestxt-work-in-real-projects">But Does <code>changes.txt</code> Work in Real Projects?</h2>
<h3 id="heading-problem-1-only-diffs-not-a-complete-snapshot">❌ Problem 1: Only Diffs, Not a Complete Snapshot</h3>
<p><code>changes.txt</code> may contain <strong>some code</strong>, but it only records <strong>differences</strong>.</p>
<p>It never stores the <strong>entire project state</strong> at a specific moment in time.</p>
<p>Tomorrow, if someone asks:</p>
<blockquote>
<p>“What did <code>hello.js</code> look like yesterday — exactly?”</p>
</blockquote>
<p>You don’t really know.</p>
<p>You would need to:</p>
<ul>
<li>find a correct base version</li>
<li>apply diffs in the right order</li>
<li>hope nothing is missing</li>
</ul>
<p>There is:</p>
<ul>
<li>no guaranteed restore</li>
<li>no reliable rollback</li>
<li>no safe comparison</li>
</ul>
<hr />
<h3 id="heading-problem-2-history-becomes-unreliable">❌ Problem 2: History Becomes Unreliable</h3>
<p>After a few days, entries become vague:</p>
<pre><code class="lang-txt">Fixed bug
Updated logic
Minor changes
</code></pre>
<p>Now the history exists…
but it no longer has <strong>clear meaning</strong>.</p>
<hr />
<h3 id="heading-problem-3-multiple-files-chaos">❌ Problem 3: Multiple Files = Chaos</h3>
<p>Now imagine this:</p>
<pre><code>hello.js
feature.js
config.json
</code></pre><p>All files change together.</p>
<p>How do you describe <strong>relationships between changes</strong> using one text file?</p>
<p>You can’t.</p>
<hr />
<h3 id="heading-problem-4-team-work-is-impossible">❌ Problem 4: Team Work Is Impossible</h3>
<p>Two developers editing:</p>
<pre><code>changes.txt
</code></pre><p>at the same time?</p>
<p>💥 conflicts
💥 confusion
💥 broken trust</p>
<hr />
<h2 id="heading-this-is-exactly-why-git-exists">This Is Exactly Why Git Exists</h2>
<p>Git is essentially:</p>
<blockquote>
<p><strong>An automated, perfect, unbreakable version of <code>changes.txt</code></strong></p>
</blockquote>
<p>But instead of storing <strong>descriptions or diffs</strong>, Git stores <strong>exact snapshots of your project</strong>.</p>
<p>And it stores everything inside one place 👇</p>
<pre><code>.git/
</code></pre><hr />
<h2 id="heading-what-is-the-git-folder">What Is the <code>.git</code> Folder?</h2>
<p>When you run:</p>
<pre><code class="lang-bash">git init
</code></pre>
<p>Git creates a hidden, <strong>database-like folder</strong> called <code>.git</code>.</p>
<p>📌 Important truth:</p>
<blockquote>
<p><strong><code>.git</code> is the repository.</strong>
Your project folder is just the working area.</p>
</blockquote>
<p>Delete <code>.git</code> → Git history is gone.</p>
<hr />
<h2 id="heading-git-is-a-version-control-system-vcs">Git Is a Version Control System (VCS)</h2>
<p>Conceptually:</p>
<pre><code>VCS (Version Control System) → Git
Git → Server Host (GitHub)
</code></pre><h3 id="heading-git-works-in-two-layers">Git works in two layers:</h3>
<h4 id="heading-1-local-git">1. Local Git</h4>
<ul>
<li>Runs on your system</li>
<li>Stores everything in <code>.git</code></li>
<li>Works offline</li>
</ul>
<h4 id="heading-2-remote-git-github">2. Remote Git (GitHub)</h4>
<ul>
<li>Just a server</li>
<li>Stores a copy of your Git data</li>
</ul>
<p>👉 <strong>GitHub is not Git</strong>
GitHub is only a <strong>host</strong></p>
<hr />
<h2 id="heading-git-tracks-content-not-files">Git Tracks Content, Not Files</h2>
<p>This is the biggest mindset shift.</p>
<p>Git does <strong>NOT</strong> think:</p>
<blockquote>
<p>“hello.js changed”</p>
</blockquote>
<p>Git thinks:</p>
<blockquote>
<p><strong>“The content inside this file changed”</strong></p>
</blockquote>
<p>That’s why Git can:</p>
<ul>
<li>show <code>+</code> and <code>-</code></li>
<li>reuse unchanged content</li>
<li>track exact history</li>
</ul>
<hr />
<h2 id="heading-the-staging-area-gits-smart-filter">The Staging Area (Git’s Smart Filter)</h2>
<p>This is where Git becomes smarter than <code>changes.txt</code>.</p>
<h3 id="heading-files-in-your-project">Files in your project:</h3>
<pre><code>hello.txt
feature.txt
</code></pre><p>You run:</p>
<pre><code class="lang-bash">git add hello.txt
</code></pre>
<h3 id="heading-what-happens-internally">What happens internally?</h3>
<ol>
<li>Git reads file content</li>
<li>Converts it into a Git object</li>
<li>Stores it inside <code>.git</code></li>
<li>Marks it in the <strong>staging area (index)</strong></li>
</ol>
<p>📌 Result:</p>
<ul>
<li>✔️ tracked</li>
<li>✔️ ready for commit</li>
<li>❌ not yet in history</li>
</ul>
<hr />
<h2 id="heading-why-staging-exists">Why Staging Exists</h2>
<p>Staging allows <strong>selective snapshots</strong>.</p>
<pre><code class="lang-bash">git add hello.txt
git add feature.txt
</code></pre>
<p>You decide:</p>
<ul>
<li>what goes into the next snapshot</li>
<li>what stays unfinished</li>
</ul>
<p>👉 Dropbox / Google Drive <strong>cannot do this</strong></p>
<hr />
<h2 id="heading-what-happens-during-git-commit">What Happens During <code>git commit</code></h2>
<pre><code class="lang-bash">git commit -m <span class="hljs-string">"updated name variables"</span>
</code></pre>
<p>Git does <strong>not</strong> store differences.</p>
<p>Git stores a <strong>snapshot</strong>.</p>
<p>Internally Git:</p>
<ol>
<li>Takes staged content</li>
<li>Creates <strong>Blob objects</strong> (file content)</li>
<li>Groups them into <strong>Tree objects</strong> (folders)</li>
<li>Creates a <strong>Commit object</strong></li>
<li>Stores everything in <code>.git/objects</code></li>
</ol>
<p>📌 A commit is a <strong>snapshot</strong>, not a patch.</p>
<hr />
<h2 id="heading-git-objects-the-hidden-heroes">Git Objects: The Hidden Heroes</h2>
<p>Git internally stores only <strong>three core object types</strong>.</p>
<h3 id="heading-1-blob-file-content">1️⃣ Blob → File Content</h3>
<pre><code><span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello"</span>);
</code></pre><p>No filename. Only content.</p>
<hr />
<h3 id="heading-2-tree-folder-structure">2️⃣ Tree → Folder Structure</h3>
<pre><code>hello.js → blob
src/ → tree
</code></pre><hr />
<h3 id="heading-3-commit-snapshot">3️⃣ Commit → Snapshot</h3>
<p>Stores:</p>
<ul>
<li>tree reference</li>
<li>parent commit</li>
<li>author</li>
<li>message</li>
</ul>
<p>Relationship:</p>
<pre><code>Commit → Tree → Blob
</code></pre><hr />
<h2 id="heading-why-git-is-so-reliable-hashes">Why Git Is So Reliable (Hashes)</h2>
<p>Every Git object is stored using a <strong>hash</strong>:</p>
<pre><code>e83c5163316f89bfbde7d9ab23ca2e25604af290
</code></pre><p>Hashes guarantee:</p>
<ul>
<li>data integrity</li>
<li>no silent corruption</li>
<li>perfect history chain</li>
</ul>
<p>Change content → hash changes → Git immediately knows.</p>
<hr />
<h2 id="heading-visualizing-git-as-a-system">Visualizing Git as a System</h2>
<pre><code>Working Directory
   ↓ git add
Staging Area
   ↓ git commit
.git (<span class="hljs-built_in">Object</span> Store)
   ↓ git push
GitHub Server
</code></pre><p>This is <strong>Git in one picture</strong>.</p>
<hr />
<h2 id="heading-the-mental-model-you-should-remember">The Mental Model You Should Remember</h2>
<blockquote>
<p>Git is a <strong>content-addressed database with a time machine UI</strong></p>
</blockquote>
<ul>
<li><code>.git</code> → database</li>
<li><code>git add</code> → prepare snapshot</li>
<li><code>git commit</code> → save snapshot</li>
<li><code>git push</code> → share snapshot</li>
</ul>
<p>Once this clicks:
❌ no command fear
❌ no confusion
✅ full confidence</p>
<hr />
<h2 id="heading-final-thoughts">Final Thoughts</h2>
<p>You don’t need to memorize Git commands.</p>
<p>You need to understand:</p>
<ul>
<li><strong>what Git stores</strong></li>
<li><strong>where it stores</strong></li>
<li><strong>why it stores snapshots</strong></li>
</ul>
<p>The idea of <code>changes.txt</code> was never wrong.
It just needed a machine to do it <strong>perfectly</strong>.</p>
<p>And that machine is <strong>Git</strong>.</p>
]]></content:encoded></item><item><title><![CDATA[Why Version Control Exists: The Pendrive Problem]]></title><description><![CDATA[When I first started learning software development, I didn’t want to just memorize Git commands. I wanted to understand the why behind them.
To find that answer, I went back to the basics — and that’s when I realized something important:

The biggest...]]></description><link>https://blog.subhrangsu.in/why-version-control-exists-the-pendrive-problem</link><guid isPermaLink="true">https://blog.subhrangsu.in/why-version-control-exists-the-pendrive-problem</guid><category><![CDATA[version control]]></category><category><![CDATA[version control systems]]></category><category><![CDATA[Code Tracking]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Subhrangsu Bera]]></dc:creator><pubDate>Thu, 01 Jan 2026 20:45:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1767298955864/8e89064e-c6bf-475e-a3c9-b987b2edf205.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>When I first started learning software development, I didn’t want to just memorize Git commands. I wanted to understand the <strong>why</strong> behind them.</p>
<p>To find that answer, I went back to the basics — and that’s when I realized something important:</p>
<blockquote>
<p>The biggest enemy of a developer isn’t a bug. It’s the <strong>pendrive</strong>.</p>
</blockquote>
<p>This is the story of how software development moved from manual chaos to a <strong>Single Source of Truth</strong>.</p>
<h2 id="heading-phase-1-the-manual-sharing-problem"><strong>Phase 1: The Manual Sharing Problem</strong></h2>
<p>Imagine you are working on a project as <strong>Developer 1</strong>. You write some code and everything works fine.</p>
<p>As the project grows, you need help with a feature or a bug, so <strong>Developer 2</strong> joins in. Later, the scope increases even more, and <strong>Developer 3</strong> becomes part of the team.</p>
<p>In the early days, the solution was simple — and dangerous.</p>
<p>You would copy the entire project onto a <strong>pendrive</strong> and hand it over.</p>
<p>Developer 2 would make changes, then pass the same pendrive forward. That was collaboration.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767299258069/d6cf7def-5e3d-40cc-b51a-30e9c65a5cee.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-the-problems"><strong>The Problems</strong></h3>
<ul>
<li><p><strong>Loss of Control</strong> The moment the pendrive leaves your hand, you lose control over the codebase.</p>
</li>
<li><p><strong>The “What Changed?” Question</strong> When the pendrive comes back, you have no idea:</p>
<ul>
<li><p>What files were changed</p>
</li>
<li><p>What lines were modified</p>
</li>
<li><p>Why those changes were made</p>
</li>
</ul>
</li>
<li><p><strong>The Overwrite Trap</strong> While the pendrive is away, you might continue working locally. Now there are two versions of the same file. When you try to combine them, one version overwrites the other.</p>
</li>
<li><p><strong>The Folder Mess</strong> To stay “safe,” you create folders like:</p>
<pre><code class="lang-markdown">  final/
  final<span class="hljs-emphasis">_v2/
  final_</span>latest/
  latest<span class="hljs-emphasis">_final_</span>fixed/
</code></pre>
<p>  Nobody knows which one is correct.</p>
</li>
</ul>
<p>There is no <strong>source of truth</strong> — only confusion.</p>
<h2 id="heading-phase-2-installing-a-tracker-a-local-source-of-truth"><strong>Phase 2: Installing a Tracker (A Local Source of Truth)</strong></h2>
<p>To escape the pendrive chaos, one thing becomes clear: I needed a <strong>source of truth</strong>.</p>
<p>So I introduced a <strong>code tracker</strong>. Let’s call it <strong>CCT — ChaiCode Tracker</strong>.</p>
<p>This wasn’t about collaboration yet. This was about <strong>clarity</strong>.</p>
<p>CCT watches every change you make and records it permanently.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767299327488/752f0a6a-e012-479b-a906-c85bcb492ac1.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-what-this-solves"><strong>What This Solves</strong></h3>
<p>With CCT, your local machine finally becomes a <strong>single source of truth</strong> — at least for you.</p>
<p>Now, if you need help from another developer, you can hand over the pendrive <strong>with CCT installed and the code tracked</strong>. When another developer modifies the code, those changes are also recorded.</p>
<p>Suddenly, you can answer critical questions instantly:</p>
<ul>
<li><p><strong>Who</strong> wrote this code?</p>
</li>
<li><p><strong>What</strong> exactly was changed?</p>
</li>
<li><p><strong>When</strong> and <strong>why</strong> did the change happen?</p>
</li>
</ul>
<p>If a bug appears, you don’t guess anymore. You can trace the exact change that introduced it and fix the problem properly.</p>
<p>This is the moment development shifts from:</p>
<blockquote>
<p>“I think this change broke something.”</p>
</blockquote>
<p>To:</p>
<blockquote>
<p>“This commit introduced the issue.”</p>
</blockquote>
<h3 id="heading-the-limitation"><strong>The Limitation</strong></h3>
<p>There’s still a major limitation.</p>
<p>This source of truth is <strong>local</strong>. True collaboration still doesn’t exist.</p>
<p>Developers can’t work <strong>in parallel</strong>, because the pendrive is still the bottleneck. Only one person can have the code at a time.</p>
<p>CCT gives control — but not a collaboration.</p>
<h3 id="heading-why-this-forces-phase-3"><strong>Why This Forces Phase 3</strong></h3>
<p>At this point, one realization becomes unavoidable:</p>
<blockquote>
<p>A source of truth is only useful if everyone agrees on it.</p>
</blockquote>
<p>That leads directly to the next step — moving this local source of truth to a <strong>central location</strong> where the entire team can rely on the same history.</p>
<h2 id="heading-phase-3-the-single-source-of-truth"><strong>Phase 3: The Single Source of Truth</strong></h2>
<p>The real breakthrough happens when the tracker is no longer local.</p>
<p>Instead of tracking changes on individual machines, the tracker is moved to a <strong>central server</strong> — the <strong>CCT Server</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1767299364550/50fa47ef-bb01-48d2-b4f1-88259ed8c04c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-what-changes-now"><strong>What Changes Now</strong></h3>
<p>This server becomes the <strong>Single Source of Truth</strong> for the entire team.</p>
<ul>
<li><p>Every developer connects to the same repository</p>
</li>
<li><p>Everyone can work in parallel</p>
</li>
<li><p>Every change is recorded in one shared history</p>
</li>
</ul>
<p>No more pendrives. No more emailing ZIP files.</p>
<p>The physical transfer of code disappears — replaced by a digital <strong>remote server</strong>.</p>
<p>This is the moment collaboration truly begins.</p>
<h2 id="heading-phase-4-the-tools-we-use-today"><strong>Phase 4: The Tools We Use Today</strong></h2>
<p>In modern development, this system is clearly split into two parts.</p>
<h3 id="heading-1-version-control-system-the-engine"><strong>1. Version Control System (The Engine)</strong></h3>
<ul>
<li><p>Git</p>
</li>
<li><p>Mercurial</p>
</li>
<li><p>Subversion (SVN)</p>
</li>
<li><p>TFS</p>
</li>
</ul>
<p>These tools handle:</p>
<ul>
<li><p>Change tracking</p>
</li>
<li><p>History</p>
</li>
<li><p>Accountability</p>
</li>
<li><p>Rollbacks</p>
</li>
</ul>
<h3 id="heading-2-vcs-remote-the-server"><strong>2. VCS Remote (The Server)</strong></h3>
<ul>
<li><p>GitHub</p>
</li>
<li><p>GitLab</p>
</li>
<li><p>Bitbucket</p>
</li>
<li><p>AWS CodeCommit</p>
</li>
<li><p>Gitea</p>
</li>
</ul>
<p>These platforms provide:</p>
<ul>
<li><p>A shared repository</p>
</li>
<li><p>Team collaboration</p>
</li>
<li><p>Access control</p>
</li>
<li><p>A true single source of truth</p>
</li>
</ul>
<p>Even the most popular tools were born from real pain.</p>
<p><strong>Linus Torvalds</strong> created <strong>Git</strong> to manage the Linux kernel — because massive collaboration simply could not survive with manual file sharing.</p>
<h2 id="heading-final-thoughts"><strong>Final Thoughts</strong></h2>
<p>Version control is not just a technical tool. It’s a <strong>collaboration contract</strong>.</p>
<p>The shift from pendrives to a <strong>Single Source of Truth</strong> is the moment a developer moves from working alone to working as part of a professional team.</p>
<p>If you’ve ever wondered why Git feels mandatory — this is why.</p>
]]></content:encoded></item></channel></rss>