<?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: aarthirs</title>
    <description>The latest articles on DEV Community by aarthirs (@aarthirs).</description>
    <link>https://dev.to/aarthirs</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%2F1015238%2Fc025455d-255f-45ec-8261-584f71601b8d.jpeg</url>
      <title>DEV Community: aarthirs</title>
      <link>https://dev.to/aarthirs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aarthirs"/>
    <language>en</language>
    <item>
      <title># JavaScript Async Explained Like a Grocery Store 🛒</title>
      <dc:creator>aarthirs</dc:creator>
      <pubDate>Sat, 13 Jun 2026 07:32:12 +0000</pubDate>
      <link>https://dev.to/aarthirs/-javascript-async-explained-like-a-grocery-store-4men</link>
      <guid>https://dev.to/aarthirs/-javascript-async-explained-like-a-grocery-store-4men</guid>
      <description>&lt;p&gt;When I first learned JavaScript's Event Loop, I kept reading explanations like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Asynchronous tasks are offloaded to Web APIs and their callbacks are placed into the Microtask Queue or Macrotask Queue."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I memorized the words.&lt;/p&gt;

&lt;p&gt;But I didn't actually understand what was happening.&lt;/p&gt;

&lt;p&gt;Then I started thinking about JavaScript like a grocery store.&lt;/p&gt;

&lt;h2&gt;
  
  
  JavaScript = One Cashier
&lt;/h2&gt;

&lt;p&gt;Imagine a store with only one cashier.&lt;/p&gt;

&lt;p&gt;The cashier can only serve one customer at a time.&lt;/p&gt;

&lt;p&gt;That's JavaScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="s2"&gt;`console.log("A");
console.log("B");
console.log("C");`&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;A
B
C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simple. One task after another.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Now imagine a customer says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Wait 5 seconds before helping the next customer."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If the cashier literally waited 5 seconds, the entire store would stop moving.&lt;/p&gt;

&lt;p&gt;That's exactly what would happen if JavaScript handled timers itself.&lt;/p&gt;




&lt;h2&gt;
  
  
  Browser Web APIs = Helpers
&lt;/h2&gt;

&lt;p&gt;Instead, JavaScript asks a helper:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="s2"&gt;`setTimeout(() =&amp;gt; {
  console.log("Hello");
}, 5000);`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;JavaScript says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Hey Browser, can you watch this timer for me?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The browser helper takes the job.&lt;/p&gt;

&lt;p&gt;JavaScript immediately continues working.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;After 5 seconds, the helper comes back and says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"The timer finished."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Callback Queue = Waiting Line
&lt;/h2&gt;

&lt;p&gt;The browser cannot interrupt JavaScript directly.&lt;/p&gt;

&lt;p&gt;So it places the callback into a waiting line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser Helper
      ↓
Callback Queue
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The callback waits until JavaScript is free.&lt;/p&gt;




&lt;p&gt;&lt;a href="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%2Farticles%2Flsousoazh9iw7uffqq40.png" class="article-body-image-wrapper"&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%2Farticles%2Flsousoazh9iw7uffqq40.png" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Event Loop = Store Manager
&lt;/h2&gt;

&lt;p&gt;The Event Loop is like a manager constantly checking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Is the cashier busy?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If yes:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If no:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Take the next customer from the waiting line
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's all the Event Loop does.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Does Promise Run Before setTimeout?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="s2"&gt;`console.log("Start");

setTimeout(() =&amp;gt; {
  console.log("Timeout");
}, 0);

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

console.log("End");`&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;Start
End
Promise
Timeout
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because JavaScript has two waiting lines:&lt;/p&gt;

&lt;h3&gt;
  
  
  High Priority Line
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Promise.then()&lt;/li&gt;
&lt;li&gt;queueMicrotask()&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Normal Line
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;setTimeout()&lt;/li&gt;
&lt;li&gt;setInterval()&lt;/li&gt;
&lt;li&gt;DOM events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Event Loop always clears the high-priority line first.&lt;/p&gt;

&lt;p&gt;That's why Promise executes before setTimeout.&lt;/p&gt;




&lt;h2&gt;
  
  
  What About fetch()?
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="s2"&gt;`fetch("/users")
  .then(res =&amp;gt; res.json())
  .then(data =&amp;gt; console.log(data));`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser handles the network request.&lt;/p&gt;

&lt;p&gt;JavaScript doesn't sit around waiting for the server.&lt;/p&gt;

&lt;p&gt;Once the response arrives, the callback gets added to the queue and runs when JavaScript is ready.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why Do Web Workers Exist?
&lt;/h2&gt;

&lt;p&gt;Imagine the cashier receives a task that takes 10 minutes.&lt;/p&gt;

&lt;p&gt;Nobody else gets served.&lt;/p&gt;

&lt;p&gt;The store freezes.&lt;/p&gt;

&lt;p&gt;That's what happens when JavaScript performs heavy calculations on the main thread.&lt;/p&gt;

&lt;p&gt;Web Workers solve this by hiring another cashier.&lt;/p&gt;

&lt;p&gt;Heavy work runs on a separate thread while the main UI remains responsive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Final Mental Model
&lt;/h2&gt;

&lt;p&gt;Whenever you see async JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JavaScript = Cashier

Browser Web APIs = Helpers

Callback Queue = Waiting Line

Event Loop = Manager

Web Workers = Extra Cashiers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this model clicks, the Event Loop becomes much easier to understand than memorizing definitions.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title># The Turing Dial: A Solstice Cryptography Protocol</title>
      <dc:creator>aarthirs</dc:creator>
      <pubDate>Sun, 07 Jun 2026 15:19:26 +0000</pubDate>
      <link>https://dev.to/aarthirs/-the-turing-dial-a-solstice-cryptography-protocol-4na3</link>
      <guid>https://dev.to/aarthirs/-the-turing-dial-a-solstice-cryptography-protocol-4na3</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/june-game-jam-2026-06-03"&gt;June Solstice Game Jam&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="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%2Farticles%2Fznimz7q8l3fn2lxj1kp1.png" class="article-body-image-wrapper"&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%2Farticles%2Fznimz7q8l3fn2lxj1kp1.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;How It Works (The Theme Connection)&lt;br&gt;
The game maps the physical passage of time during the Solstice to computational logic constraints. As the game clock cycles from day to night, your processing framework degrades across three environmental phases:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sunrise (Unary):&lt;/strong&gt; Pure binary processing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High Noon (Boolean):&lt;/strong&gt; Advanced algebraic logic gates (&lt;code&gt;AND&lt;/code&gt;, &lt;code&gt;OR&lt;/code&gt;, &lt;code&gt;NOT&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Midnight (Enigma):&lt;/strong&gt; Hard cryptographic bit-parity challenges that honor Turing's codebreaking at Bletchley Park.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Behind the Curtain: Best Google AI Usage
&lt;/h2&gt;

&lt;p&gt;Instead of using the Gemini API as a simple chat box, &lt;strong&gt;Gemini 2.5 Flash acts as our automated Procedural Level Designer&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;Every time the environment transitions, the system fires a background request to Google AI Studio. Gemini dynamically parses the current game state and feeds back:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A unique, context-aware matrix puzzle directive (&lt;code&gt;puzzleHint&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;The dynamic numeric or parity solution ruleset (&lt;code&gt;solutionKey&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;A curated, inspiring quote reflecting Alan Turing's legacy, Juneteenth, or Pride Month (&lt;code&gt;historyQuote&lt;/code&gt;).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the network connection ever fails, a native hardware fallback loop steps in to ensure seamless offline gameplay.&lt;/p&gt;

&lt;h2&gt;
  
  
  Built With
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pure HTML5 / CSS Grid (with a custom CRT scanline terminal effect)&lt;/li&gt;
&lt;li&gt;Modular Vanilla JavaScript&lt;/li&gt;
&lt;li&gt;Official &lt;code&gt;@google/genai&lt;/code&gt; SDK via CDN&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Play the Game
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Repository:&lt;/strong&gt; &lt;a href="https://github.com/aarthirs/TuningGame/tree/main" rel="noopener noreferrer"&gt;github&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Live Demo:&lt;/strong&gt;&lt;a href="https://drive.google.com/file/d/1SFsWIch1x5SUnw9MUWEV2DISnNCjnZUs/view?usp=sharing" rel="noopener noreferrer"&gt;vid demo&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>devchallenge</category>
      <category>gamechallenge</category>
      <category>gamedev</category>
    </item>
  </channel>
</rss>
