<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vijay Thopate</title>
    <description>The latest articles on DEV Community by Vijay Thopate (@thopatevijay).</description>
    <link>https://dev.to/thopatevijay</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F859683%2F6b13cd14-1b2d-46fe-92e1-bec3ae717ccc.jpeg</url>
      <title>DEV Community: Vijay Thopate</title>
      <link>https://dev.to/thopatevijay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thopatevijay"/>
    <language>en</language>
    <item>
      <title>🧠 JavaScript Hoisting</title>
      <dc:creator>Vijay Thopate</dc:creator>
      <pubDate>Mon, 29 Dec 2025 08:09:29 +0000</pubDate>
      <link>https://dev.to/thopatevijay/-3di9</link>
      <guid>https://dev.to/thopatevijay/-3di9</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/thopatevijay" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F859683%2F6b13cd14-1b2d-46fe-92e1-bec3ae717ccc.jpeg" alt="thopatevijay"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/thopatevijay/javascript-hoisting-3i7f" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;🧠 JavaScript Hoisting&lt;/h2&gt;
      &lt;h3&gt;Vijay Thopate ・ Dec 29&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>javascript</category>
    </item>
    <item>
      <title>🧠 JavaScript Hoisting</title>
      <dc:creator>Vijay Thopate</dc:creator>
      <pubDate>Mon, 29 Dec 2025 05:52:01 +0000</pubDate>
      <link>https://dev.to/thopatevijay/javascript-hoisting-3i7f</link>
      <guid>https://dev.to/thopatevijay/javascript-hoisting-3i7f</guid>
      <description>&lt;p&gt;Most developers hear “hoisting” and think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Variables get moved to the top.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But that’s not what really happens.&lt;/p&gt;

&lt;p&gt;Hoisting is about how JavaScript &lt;strong&gt;allocates memory before execution&lt;/strong&gt;, and how variables and functions behave differently during that phase.&lt;/p&gt;

&lt;p&gt;Let’s break it down in a simple, intuitive, story-driven way — and then connect it to how the JavaScript engine actually works.&lt;/p&gt;




&lt;h2&gt;
  
  
  🎯 What is Hoisting?
&lt;/h2&gt;

&lt;p&gt;Hoisting is the process where JavaScript:&lt;/p&gt;

&lt;p&gt;1️⃣ scans your code before execution&lt;br&gt;
2️⃣ allocates memory for variables &amp;amp; functions&lt;br&gt;
3️⃣ sets initial values (depending on keyword)&lt;/p&gt;

&lt;p&gt;Execution happens only after this.&lt;/p&gt;

&lt;p&gt;Nothing is physically “moved”.&lt;/p&gt;

&lt;p&gt;It only &lt;em&gt;appears&lt;/em&gt; that way.&lt;/p&gt;


&lt;h2&gt;
  
  
  🏫 Real-Life Analogy #1 — Classroom Attendance Register
&lt;/h2&gt;

&lt;p&gt;Before teaching begins, a teacher:&lt;/p&gt;

&lt;p&gt;✔ writes all students’ names in the attendance register&lt;br&gt;
❌ but attendance is not yet marked&lt;/p&gt;

&lt;p&gt;Names exist — but values are empty.&lt;/p&gt;

&lt;p&gt;Later during class:&lt;/p&gt;

&lt;p&gt;✔ attendance is marked&lt;br&gt;
✔ details are filled in&lt;/p&gt;

&lt;p&gt;That is exactly how hoisting works.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;Classroom&lt;/th&gt;
&lt;th&gt;JavaScript&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Before class&lt;/td&gt;
&lt;td&gt;write names&lt;/td&gt;
&lt;td&gt;store variables &amp;amp; functions in memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;During class&lt;/td&gt;
&lt;td&gt;mark attendance&lt;/td&gt;
&lt;td&gt;assign values during execution&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So when a name is called early,&lt;br&gt;
it exists — but may not have a value yet.&lt;/p&gt;

&lt;p&gt;That’s why &lt;code&gt;var&lt;/code&gt; becomes &lt;strong&gt;undefined&lt;/strong&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  🍽 Real-Life Analogy #2 — Restaurant Kitchen Plates
&lt;/h2&gt;

&lt;p&gt;Before customers arrive:&lt;/p&gt;

&lt;p&gt;✔ plates are kept on tables&lt;br&gt;
✔ table numbers are assigned&lt;br&gt;
❌ food is not yet served&lt;/p&gt;

&lt;p&gt;Plates exist — but are empty.&lt;/p&gt;

&lt;p&gt;Same with &lt;code&gt;var&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Variable exists → but value is undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;let&lt;/code&gt; and &lt;code&gt;const&lt;/code&gt; are like plates that are:&lt;/p&gt;

&lt;p&gt;🔒 covered until the right time (TDZ)&lt;/p&gt;

&lt;p&gt;We’ll come back to this.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ How JavaScript Executes Code (2-Phase Model)
&lt;/h2&gt;

&lt;p&gt;Whenever JS runs your code, it creates:&lt;/p&gt;

&lt;h3&gt;
  
  
  1️⃣ Memory Creation Phase (Hoisting Phase)
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;function declarations stored fully&lt;/li&gt;
&lt;li&gt;variables allocated in memory&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2️⃣ Execution Phase
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;code runs line-by-line&lt;/li&gt;
&lt;li&gt;values get assigned&lt;/li&gt;
&lt;li&gt;functions get executed&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧩 What Actually Gets Hoisted?
&lt;/h2&gt;

&lt;p&gt;Let’s see behavior for each keyword.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Function Declarations — Fully Hoisted
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;sayHi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sayHi&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because:&lt;/p&gt;

&lt;p&gt;✔ function body is stored in memory&lt;br&gt;
✔ can be called before declaration&lt;/p&gt;

&lt;p&gt;This is the &lt;em&gt;useful&lt;/em&gt; side of hoisting.&lt;/p&gt;


&lt;h2&gt;
  
  
  ⚠️ &lt;code&gt;var&lt;/code&gt; — Hoisted but Initialized as &lt;code&gt;undefined&lt;/code&gt;
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Memory phase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Execution phase:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This often leads to subtle bugs.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔒 &lt;code&gt;let&lt;/code&gt; &amp;amp; &lt;code&gt;const&lt;/code&gt; — Hoisted but NOT initialized (TDZ)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Throws:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReferenceError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because variable is in&lt;/p&gt;

&lt;p&gt;🟡 Temporal Dead Zone (TDZ)&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;variable exists in memory&lt;br&gt;
but cannot be accessed until declared&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This behavior makes code safer.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧱 Function-Scoped vs Block-Scoped (Why &lt;code&gt;var&lt;/code&gt; Causes Bugs)
&lt;/h2&gt;




&lt;h2&gt;
  
  
  🟡 &lt;code&gt;var&lt;/code&gt; is Function-Scoped
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;x&lt;/code&gt; escaped the block 😬&lt;/p&gt;

&lt;p&gt;Because:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;var&lt;/code&gt; ignores &lt;code&gt;{ }&lt;/code&gt; blocks and lives across the function&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🟢 &lt;code&gt;let&lt;/code&gt; &amp;amp; &lt;code&gt;const&lt;/code&gt; are Block-Scoped
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ReferenceError
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behavior is predictable &amp;amp; safer.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧨 Real-World Bug — Why &lt;code&gt;var&lt;/code&gt; is Discouraged
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3
3
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;var&lt;/code&gt; creates one shared &lt;code&gt;i&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;loop finishes&lt;/li&gt;
&lt;li&gt;async callbacks run later&lt;/li&gt;
&lt;li&gt;&lt;code&gt;i = 3&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  &lt;code&gt;let&lt;/code&gt; Fixes It
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0
1
2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because:&lt;/p&gt;

&lt;p&gt;✔ new &lt;code&gt;i&lt;/code&gt; is created per iteration&lt;br&gt;
✔ each callback receives correct value&lt;/p&gt;


&lt;h2&gt;
  
  
  🧠 Why &lt;code&gt;let&lt;/code&gt; &amp;amp; &lt;code&gt;const&lt;/code&gt; Were Introduced
&lt;/h2&gt;

&lt;p&gt;They were added to:&lt;/p&gt;

&lt;p&gt;✔ prevent hidden hoisting bugs&lt;br&gt;
✔ avoid accidental redeclaration&lt;br&gt;
✔ provide predictable block scope&lt;br&gt;
✔ fix async &amp;amp; loop bugs&lt;/p&gt;


&lt;h2&gt;
  
  
  🟡 Why TDZ Was Introduced
&lt;/h2&gt;

&lt;p&gt;TDZ forces:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Declare variable before using it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This prevents:&lt;/p&gt;

&lt;p&gt;❌ silent undefined behavior&lt;br&gt;
❌ accidental access before initialization&lt;br&gt;
❌ hard-to-debug runtime errors&lt;/p&gt;

&lt;p&gt;Instead — JavaScript loudly warns you 👍&lt;/p&gt;


&lt;h2&gt;
  
  
  🧪 Function Declarations vs Function Expressions
&lt;/h2&gt;


&lt;h3&gt;
  
  
  Function Declaration (Hoisted)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Works.&lt;/p&gt;


&lt;h3&gt;
  
  
  Function Expression (NOT hoisted as function)
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;greet&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;greet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: greet is not a function
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;greet&lt;/code&gt; is hoisted as &lt;code&gt;undefined&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;function assigned later&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Arrow Functions behave the same
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;sayHi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sayHi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ReferenceError (TDZ)&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 Summary Table — What Gets Hoisted?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Hoisted?&lt;/th&gt;
&lt;th&gt;Initial Value&lt;/th&gt;
&lt;th&gt;Safe?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;function declaration&lt;/td&gt;
&lt;td&gt;✅ yes&lt;/td&gt;
&lt;td&gt;full function&lt;/td&gt;
&lt;td&gt;👍 useful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;var&lt;/td&gt;
&lt;td&gt;✅ yes&lt;/td&gt;
&lt;td&gt;undefined&lt;/td&gt;
&lt;td&gt;⚠️ risky&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;let&lt;/td&gt;
&lt;td&gt;✅ yes&lt;/td&gt;
&lt;td&gt;TDZ (not initialized)&lt;/td&gt;
&lt;td&gt;✅ safe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;const&lt;/td&gt;
&lt;td&gt;✅ yes&lt;/td&gt;
&lt;td&gt;TDZ + must assign&lt;/td&gt;
&lt;td&gt;✅ safe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;function expression&lt;/td&gt;
&lt;td&gt;⚠️ variable only&lt;/td&gt;
&lt;td&gt;undefined&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;arrow function&lt;/td&gt;
&lt;td&gt;⚠️ variable only&lt;/td&gt;
&lt;td&gt;TDZ&lt;/td&gt;
&lt;td&gt;❌&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧠 Key Takeaways
&lt;/h2&gt;

&lt;p&gt;Hoisting exists because JS engine:&lt;/p&gt;

&lt;p&gt;✔ prepares memory before execution&lt;br&gt;
✔ stores declarations first&lt;br&gt;
✔ executes later&lt;/p&gt;

&lt;p&gt;Function hoisting is useful.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var&lt;/code&gt; hoisting is confusing.&lt;/p&gt;

&lt;p&gt;Modern JavaScript prefers:&lt;/p&gt;

&lt;p&gt;✔ &lt;code&gt;let&lt;/code&gt; for variables&lt;br&gt;
✔ &lt;code&gt;const&lt;/code&gt; for constants&lt;br&gt;
✔ declare before using&lt;/p&gt;

&lt;p&gt;Because clean code &amp;gt; clever tricks.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✍️ Closing Thought
&lt;/h2&gt;

&lt;p&gt;Hoisting is not a magical behavior.&lt;/p&gt;

&lt;p&gt;It is simply how JavaScript:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;builds memory first&lt;br&gt;
and runs code afterward&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Once you understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;execution context&lt;/li&gt;
&lt;li&gt;scope&lt;/li&gt;
&lt;li&gt;TDZ&lt;/li&gt;
&lt;li&gt;call stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript stops feeling surprising —&lt;br&gt;
and starts feeling logical.&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Solana Networking Unpacked: From TCP to QUIC, Quinn, and Transaction Flow</title>
      <dc:creator>Vijay Thopate</dc:creator>
      <pubDate>Thu, 27 Nov 2025 13:34:22 +0000</pubDate>
      <link>https://dev.to/thopatevijay/solana-networking-unpacked-from-tcp-to-quic-quinn-and-transaction-flow-2pgn</link>
      <guid>https://dev.to/thopatevijay/solana-networking-unpacked-from-tcp-to-quic-quinn-and-transaction-flow-2pgn</guid>
      <description>&lt;h2&gt;
  
  
  1. From cars and roads to packets and streams
&lt;/h2&gt;

&lt;p&gt;A good way to think about the internet is as a road system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;road&lt;/strong&gt; is the network.
&lt;/li&gt;
&lt;li&gt;Your &lt;strong&gt;messages&lt;/strong&gt; (web pages, transactions, videos) are like groups of cars.
&lt;/li&gt;
&lt;li&gt;Each &lt;strong&gt;car&lt;/strong&gt; is a small chunk of data called a &lt;strong&gt;packet&lt;/strong&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Big messages are split into many packets, sent across the network, and then put back together on the other side. Some cars may take slightly different routes, get delayed, or even get lost and re‑sent.&lt;/p&gt;

&lt;p&gt;On top of these packets, we build &lt;strong&gt;streams&lt;/strong&gt;: ordered flows of bytes between two endpoints. A stream is like a dedicated lane between two cities where cars go in order. Protocols like TCP and QUIC manage these streams.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Application vs transport: who does what?
&lt;/h2&gt;

&lt;p&gt;Networking is usually described in layers. Two important ones for Solana and QUIC are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;application layer&lt;/strong&gt;: this is where the &lt;em&gt;meaning&lt;/em&gt; of the data lives. Examples: HTTP, gRPC, your custom Solana bot protocol. It defines things like URLs, JSON payloads, “GET /price”, etc.
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;transport layer&lt;/strong&gt;: this is the delivery service. It decides &lt;em&gt;how&lt;/em&gt; to move bytes reliably from one process on machine A to one process on machine B (using ports, congestion control, retransmissions, etc.). This is where &lt;strong&gt;TCP&lt;/strong&gt;, &lt;strong&gt;UDP&lt;/strong&gt;, and &lt;strong&gt;QUIC&lt;/strong&gt; live.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In simple terms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Application layer = “What are we saying?”
&lt;/li&gt;
&lt;li&gt;Transport layer = “How do we get the message there in one piece (or fast enough)?”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you send an HTTP request from a browser, HTTP builds the message at the application layer, then hands it to TCP or QUIC at the transport layer, which chops it into packets and sends them on the wire.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. TCP, UDP, QUIC
&lt;/h2&gt;

&lt;p&gt;Using the road analogy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;TCP&lt;/strong&gt; is like a careful shipping company. It guarantees that every box arrives, in order, and will re‑ship anything that gets lost. You pay with extra time and overhead.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UDP&lt;/strong&gt; is like dropping flyers from a plane. It’s very fast and simple, but if some get lost, nobody re‑sends them for you.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;QUIC&lt;/strong&gt; is like a modern shipping company built on top of the same road as UDP, but it adds its own smarts: encryption, multiple lanes (streams), congestion control, and fast setup — all in user space.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All three are &lt;strong&gt;transport protocols&lt;/strong&gt;. Applications (like browsers or Solana clients) choose which one they use.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Head‑of‑line blocking: cars stuck in a single lane
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Head‑of‑line (HOL) blocking&lt;/strong&gt; happens when everything behind the front car in a single lane is forced to wait, even though the road ahead might be free.&lt;/p&gt;

&lt;p&gt;With TCP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Packets must be delivered to the application &lt;strong&gt;in order&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;If packet 3 is lost but packets 4, 5, 6 arrive, TCP holds 4–6 until 3 is retransmitted. One missing packet at the “head of the line” blocks everything behind it.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With HTTP/2 over TCP, many logical HTTP streams share that &lt;strong&gt;one&lt;/strong&gt; TCP stream, so a lost TCP packet can stall &lt;em&gt;all&lt;/em&gt; HTTP streams temporarily.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;QUIC&lt;/strong&gt; fixes this by making &lt;strong&gt;streams visible at the transport layer&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each request/response can be its own QUIC stream.
&lt;/li&gt;
&lt;li&gt;If packets for stream A are lost, packets for stream B can still be delivered immediately. Loss on one stream does not block others.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a big reason HTTP/3 (HTTP over QUIC) performs better on lossy or mobile networks.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. HTTP/1, HTTP/2, HTTP/3 in one picture
&lt;/h2&gt;

&lt;p&gt;Very briefly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;HTTP/1.1 + TCP&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One request per connection (or fragile pipelining).
&lt;/li&gt;
&lt;li&gt;Browsers open many TCP connections to the same host to parallelize.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;HTTP/2 + TCP&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiplexes many HTTP streams over &lt;strong&gt;one&lt;/strong&gt; TCP connection.
&lt;/li&gt;
&lt;li&gt;Fixes head‑of‑line at HTTP level, but still suffers from TCP HOL blocking underneath.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;&lt;strong&gt;HTTP/3 + QUIC&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs HTTP on top of QUIC streams.
&lt;/li&gt;
&lt;li&gt;Reduces HOL blocking and speeds up connection setup (0‑RTT in many cases).
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;HTTP/3 is the application protocol; QUIC is the transport it runs on. They are not the same thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. QUIC and Quinn
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;QUIC&lt;/strong&gt; started as a Google experiment around 2012 and was later standardized by the IETF in 2021 (RFC 9000 and friends).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It runs over UDP but implements its own reliability, encryption (TLS 1.3), congestion control, and multiplexed streams.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Quinn&lt;/strong&gt; is an &lt;strong&gt;async Rust implementation of QUIC&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It’s a Rust library that lets you open QUIC connections, create streams, and send/receive data without implementing QUIC yourself.
&lt;/li&gt;
&lt;li&gt;Conceptually, it fills the same role as a TCP library, but for QUIC. Your Rust app uses Quinn at the transport layer and builds higher‑level protocols (like HTTP/3, custom Solana bots, etc.) on top.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Solana basics: who does what?
&lt;/h2&gt;

&lt;p&gt;Solana is a high‑throughput blockchain that leans heavily on fast networking. Some core concepts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leader&lt;/strong&gt;: The validator currently responsible for producing a block in a given slot. It collects transactions, executes them, and broadcasts the resulting block.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TPU (Transaction Processing Unit)&lt;/strong&gt;: The internal pipeline inside a validator that ingests, verifies, and executes transactions, then packages them into entries and shreds.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turbine&lt;/strong&gt;: The block propagation protocol. It splits blocks into small pieces (shreds) and spreads them through a tree of validators, inspired by BitTorrent. This makes block distribution scalable.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gulf Stream&lt;/strong&gt;: Solana’s mempool‑less transaction forwarding. Rather than a big global mempool, transactions are rapidly pushed toward current and &lt;strong&gt;future&lt;/strong&gt; leaders so they’re ready to go when a leader’s slot starts.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RPC nodes&lt;/strong&gt;: Nodes that expose JSON‑RPC to wallets, apps, bots. They receive user transactions (&lt;code&gt;sendTransaction&lt;/code&gt;), forward them into the network, and answer read queries (&lt;code&gt;getBalance&lt;/code&gt;, &lt;code&gt;getProgramAccounts&lt;/code&gt;, etc.).
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trading bots / bots&lt;/strong&gt;: Programs that monitor state and send transactions automatically, often latency‑sensitive (arbitrage, sniping, liquidations). They care deeply about network path and congestion.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Indexers&lt;/strong&gt;: Off‑chain services that read blocks and account changes, then store them in databases or search systems so dapps can query complex views quickly.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Under the hood, Solana historically used &lt;strong&gt;UDP&lt;/strong&gt; heavily for both transaction ingestion and block propagation because it’s low‑overhead and fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. How QUIC enters Solana
&lt;/h2&gt;

&lt;p&gt;Raw UDP is like throwing millions of letters at a post office with no queue or capacity limit. It’s fast, but the receiver has no natural way to slow you down or prioritize traffic.&lt;/p&gt;

&lt;p&gt;Solana hit limits with this model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Leaders could be flooded with more packets than they can realistically process.
&lt;/li&gt;
&lt;li&gt;There was no built‑in backpressure or fairness across senders.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So Solana introduced &lt;strong&gt;QUIC for transaction ingestion&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Instead of sending transactions as one‑shot UDP packets, RPC nodes and serious bots open &lt;strong&gt;QUIC connections&lt;/strong&gt; to the leader’s TPU.
&lt;/li&gt;
&lt;li&gt;Transactions are sent over these QUIC connections, gaining:

&lt;ul&gt;
&lt;li&gt;Per‑connection flow control and congestion control,
&lt;/li&gt;
&lt;li&gt;Some accountability per sender,
&lt;/li&gt;
&lt;li&gt;Better handling of packet loss and reordering.
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Internally, Solana’s QUIC stack is similar in spirit to Quinn: it’s an implementation of the QUIC protocol, tuned for Solana’s traffic patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. One Solana transaction’s journey (with QUIC)
&lt;/h2&gt;

&lt;p&gt;Here’s a simple end‑to‑end story for a single transaction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Wallet or bot → RPC
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;You click “Send” in a wallet or your bot decides to trade.
&lt;/li&gt;
&lt;li&gt;The client builds and signs a Solana transaction and sends it to an RPC endpoint via HTTP or WebSocket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The RPC node is the gateway between regular web traffic and Solana’s validator network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: RPC / bot → leader over QUIC
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The RPC node (or a latency‑sensitive trading bot) knows who the current or upcoming leader is, using Solana’s leader schedule and cluster info.
&lt;/li&gt;
&lt;li&gt;It opens (or reuses) a &lt;strong&gt;QUIC connection&lt;/strong&gt; to the leader’s TPU QUIC port. Over this connection, it streams many transactions.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of this as a high‑speed, controlled lane from the RPC/bot to the leader, instead of spamming one‑off UDP packets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Leader’s TPU pipeline
&lt;/h3&gt;

&lt;p&gt;Inside the leader:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Ingress stage&lt;/strong&gt;: QUIC packets arrive, transactions are extracted, signatures are checked (often on GPUs), duplicates are removed, and priority rules (stake‑weighted QoS, fees) decide what moves forward.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Banking/execution stage&lt;/strong&gt;: Valid transactions are executed in parallel (Sealevel) against the current state, producing a sequence of entries that will form the block.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If your transaction passes all checks and wins the priority game, it’s now part of the block being built for that slot.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Gulf Stream and forwarding
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Gulf Stream constantly pushes transactions toward current and &lt;strong&gt;future&lt;/strong&gt; leaders, so when a validator becomes leader, it already has a queue of pending transactions ready to process.
&lt;/li&gt;
&lt;li&gt;This design removes the classic global mempool bottleneck and reduces confirmation latency.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In practice, your transaction may hop via several validators before it reaches the right leader, but Gulf Stream ensures it gets pushed in the right direction quickly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Turbine block propagation
&lt;/h3&gt;

&lt;p&gt;Once the leader finalizes a block that includes your transaction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The block is broken into &lt;strong&gt;shreds&lt;/strong&gt; and encoded with erasure coding.
&lt;/li&gt;
&lt;li&gt;Turbine organizes validators into a tree. The leader sends different shreds to its direct neighbors; they forward to their neighbors, and so on, until everyone can reconstruct the full block.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This works a bit like a torrent swarm for each block: no single node needs to talk to every other node.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6: Other validators verify and vote
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Non‑leader validators reassemble the block, re‑execute its transactions to verify state, and then cast votes (as vote transactions) if everything checks out.
&lt;/li&gt;
&lt;li&gt;As enough stake‑weighted votes land on that block and its descendants, the network gains confidence and finality. Indexers record the change, and bots and users see the updated state.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, your transaction is effectively final on Solana.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Why this matters for builders
&lt;/h2&gt;

&lt;p&gt;For a Solana builder, understanding this stack gives you levers to build better systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Networking choices&lt;/strong&gt; (TCP vs UDP vs QUIC) change how fair and robust the chain is under heavy bot traffic.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;QUIC and Quinn&lt;/strong&gt; give you tools to build high‑performance bots, relayers, or custom infra in Rust that speak the same language as Solana’s validators.
&lt;/li&gt;
&lt;li&gt;Concepts like &lt;strong&gt;leaders, Gulf Stream, Turbine, and the TPU&lt;/strong&gt; explain where latency comes from and where optimizations or MEV strategies live.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of the whole system as many lanes of cars (packets and streams) feeding an extremely fast toll booth (the leader’s TPU), which then fans out receipts of what happened (blocks via Turbine) to the rest of the network.&lt;/p&gt;




&lt;h2&gt;
  
  
  References and Further Reading
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Networking Basics
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.cloudflare.com/learning/network-layer/what-is-a-packet/" rel="noopener noreferrer"&gt;What is a packet? | Network packet definition - Cloudflare&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Network_packet" rel="noopener noreferrer"&gt;Network packet - Wikipedia&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/Head-of-line_blocking" rel="noopener noreferrer"&gt;Head-of-line blocking - Wikipedia&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Glossary/Head_of_line_blocking" rel="noopener noreferrer"&gt;Head-of-line blocking - MDN Web Docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.pubnub.com/blog/http-vs-http-2-vs-http-3-whats-the-difference/" rel="noopener noreferrer"&gt;HTTP vs. HTTP/2 vs. HTTP/3 - PubNub Blog&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/pieter/tcp-udp-or-quic-read-this-before-you-choose-432e"&gt;TCP, UDP or QUIC? Read this before you choose. - Dev.to&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  QUIC and Quinn
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://en.wikipedia.org/wiki/QUIC" rel="noopener noreferrer"&gt;QUIC - Wikipedia&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://blog.cloudflare.com/the-road-to-quic/" rel="noopener noreferrer"&gt;The Road to QUIC - Cloudflare Blog&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/quinn-rs/quinn" rel="noopener noreferrer"&gt;quinn-rs/quinn: Async-friendly QUIC implementation in Rust - GitHub&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Solana Core Concepts and Networking
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://solana.com/docs/references/terminology" rel="noopener noreferrer"&gt;Solana Terminology - Solana Docs&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://solana.com/news/pipelining-in-solana-the-transaction-processing-unit" rel="noopener noreferrer"&gt;Pipelining in Solana: The Transaction Processing Unit&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://solana.com/news/gulf-stream--solana-s-mempool-less-transaction-forwarding-protocol" rel="noopener noreferrer"&gt;Gulf Stream: Solana's Mempool-less Transaction Forwarding Protocol&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://solana.com/news/turbine---solana-s-block-propagation-protocol-solves-the-scalability-trilemma" rel="noopener noreferrer"&gt;Turbine — Solana's Block Propagation Protocol Solves Scalability Trilemma&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://allenhark.com/blog/solana-quic-networking-protocol-docs" rel="noopener noreferrer"&gt;Deep Dive into Solana's QUIC Networking Protocol - Allen Hark&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>solana</category>
      <category>quic</category>
      <category>web3</category>
      <category>turbine</category>
    </item>
  </channel>
</rss>
