<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adarsh Kashyap on Medium]]></title>
        <description><![CDATA[Stories by Adarsh Kashyap on Medium]]></description>
        <link>https://medium.com/@akadarshkashyap?source=rss-d4f4c3d783e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EaYeEDnhuqGEm8WXTSqkhA.jpeg</url>
            <title>Stories by Adarsh Kashyap on Medium</title>
            <link>https://medium.com/@akadarshkashyap?source=rss-d4f4c3d783e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 21:33:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akadarshkashyap/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Cutting LLM Token Costs: The Big Lesson from RTK, Headroom, and Caveman]]></title>
            <link>https://medium.com/@akadarshkashyap/cutting-llm-token-costs-the-big-lesson-from-rtk-headroom-and-caveman-591660dea61e?source=rss-d4f4c3d783e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/591660dea61e</guid>
            <dc:creator><![CDATA[Adarsh Kashyap]]></dc:creator>
            <pubDate>Tue, 30 Jun 2026 16:04:04 GMT</pubDate>
            <atom:updated>2026-06-30T16:04:04.796Z</atom:updated>
            <content:encoded><![CDATA[<p>AI coding agents are becoming part of everyday engineering work. Tools like Claude Code, Cursor, Aider, and Codex can inspect codebases, run commands, read logs, generate patches, and explain architecture.</p><p>But there is a practical problem: tokens cost money.</p><p>Every file read, terminal output, grep result, test log, and model response adds to the bill. As engineering teams start using AI agents more seriously, token efficiency becomes less of a nice-to-have and more of an operational concern.</p><p>A recent article by Code Pointer, <a href="https://codepointer.substack.com/p/cutting-llm-token-costs-with-rtk">“Cutting LLM Token Costs with rtk, headroom, and caveman”</a>, looks at three open-source tools trying to solve this problem:</p><ul><li>rtk</li><li>headroom</li><li>caveman</li></ul><p>All three promise large token reductions. Some benchmark numbers show 60% to 90% savings.</p><p>But the real-world result is more nuanced.</p><h3>The Big Picture</h3><p>The main finding is simple:</p><p>These tools work, but they do not magically cut your total LLM bill in half.</p><p>The author tested them against 500 real Claude Code sessions, covering 614 million tokens and roughly $926 of baseline spend.</p><p>The actual savings were:</p><ul><li>headroom: 2.8%</li><li>rtk: 0.5%</li><li>caveman: 0.4%</li><li>Combined: 3.7%</li></ul><p>That is very different from the headline benchmark claims.</p><p>But this does not mean the tools are useless. It means we need to understand what exactly they optimize.</p><h3>Why the Savings Look Big in Benchmarks</h3><p>Most benchmark claims measure one narrow stream.</p><p>For example:</p><ul><li>A huge grep result</li><li>A large git diff</li><li>A repetitive log file</li><li>A verbose model answer</li></ul><p>On those specific inputs, compression can be dramatic. If a command prints thousands of repetitive lines, a tool like rtk can collapse that output into a much smaller summary.</p><p>That is real value.</p><p>The problem is that your actual LLM bill is not made of one giant grep result. It is made of many things:</p><ul><li>System prompts</li><li>User messages</li><li>Tool calls</li><li>File reads</li><li>Terminal output</li><li>Cached context</li><li>Model responses</li><li>Code blocks</li><li>Reasoning and output tokens</li></ul><p>So even if one command output is reduced by 90%, that command may represent only a small slice of the total session cost.</p><p>This is the denominator problem.</p><p>A tool can save 90% on one payload, but only 1% to 3% on the total bill.</p><h3>What RTK Does</h3><p>rtk, or Rust Token Killer, is a command-line wrapper that compresses terminal output before it reaches the model.</p><p>Instead of sending raw command output to the AI agent, it tries to send a smaller, cleaner version.</p><p>For example, instead of giving the model a full noisy ls -la output with permissions, owners, timestamps, and file metadata, rtk can provide a compact directory summary.</p><p>It can also reduce noisy outputs from commands like:</p><ul><li>grep</li><li>rg</li><li>git diff</li><li>git log</li><li>ls</li><li>test runners</li></ul><p>The best use case is repetitive terminal output.</p><p>If a search command returns thousands of similar lines, the model usually does not need every line. It needs the pattern, the file locations, and a clear indication that more matches exist.</p><p>That is where rtk is useful.</p><h3>Where RTK Helps</h3><p>RTK is most useful when your AI agent frequently runs shell commands that produce large outputs.</p><p>Good examples:</p><ul><li>Searching large monorepos</li><li>Running noisy test suites</li><li>Inspecting large diffs</li><li>Listing big directories</li><li>Reading repetitive logs</li><li>Debugging build output</li></ul><p>In those cases, RTK can prevent context pollution.</p><p>That is important because token cost is not the only issue. Large noisy outputs also reduce model focus. The model may waste attention on irrelevant lines instead of the actual failure or design issue.</p><p>So the better mental model is:</p><p>RTK is not only a cost-saving tool. It is a context-quality tool.</p><h3>Where RTK Helps Less</h3><p>RTK has limits.</p><p>Many coding agents do not perform all reads through shell commands. Some use native tools for reading files, grepping, globbing, or browsing project structure.</p><p>If the agent uses a native file-read tool instead of running cat or rg through the shell, RTK may never see that output.</p><p>The article found that 78% of tool-output tokens bypassed RTK because they flowed through native tools rather than shell hooks.</p><p>That is the key limitation.</p><p>RTK can only compress what passes through it.</p><h3>Why Prompt Caching Changes the Economics</h3><p>Modern LLM APIs often use prompt caching.</p><p>That means repeated context may be billed at a much cheaper rate than fresh input or output tokens.</p><p>This changes the economics of compression.</p><p>If a tool mostly compresses tokens that are later billed as cheap cache reads, the dollar savings may be small even if the token savings look large.</p><p>In the article’s sample, a large part of the bill came from cache creation and model output. Tools like RTK and headroom mostly affect tool-result input, not expensive model output.</p><p>That is why fewer tokens does not always mean a dramatically lower bill.</p><h3>Security Trade-Off</h3><p>There is another important point: these tools sit in sensitive places.</p><p>They may see:</p><ul><li>Source code</li><li>Terminal output</li><li>Prompts</li><li>Logs</li><li>Environment-related text</li><li>In some cases, API traffic or credentials</li></ul><p>Even if the tool is local-first today, a compromised release could become a serious supply-chain risk.</p><p>This is especially important for companies working with private repositories, customer data, credentials, legal data, healthcare data, or production infrastructure.</p><p>The practical takeaway:</p><p>Do not install token-saving tools blindly. Treat them like developer infrastructure with real trust implications.</p><h3>How I Would Use This in Practice</h3><p>I would not adopt RTK, headroom, or caveman expecting a 50% monthly bill reduction.</p><p>That is the wrong expectation.</p><p>I would use them selectively where they fit the workload.</p><p>For example:</p><p>Use RTK when:</p><ul><li>The agent runs many shell commands</li><li>The repo is large</li><li>Test output is noisy</li><li>Search output is repetitive</li><li>Large diffs frequently enter context</li></ul><p>Use headroom when:</p><ul><li>You control the API proxy path</li><li>You want compression across tool-result payloads</li><li>You are comfortable with the proxy trust model</li></ul><p>Use caveman-style prompting when:</p><ul><li>You want shorter model responses</li><li>Your workflow does not need verbose explanations</li><li>You care about reducing output tokens</li><li>You can preserve clarity for security, deployment, and multi-step operations</li></ul><p>But I would avoid these tools in high-risk environments unless I had reviewed the code, pinned versions, and understood exactly what data they can access.</p><h3>The Practical Lesson for Engineering Teams</h3><p>The bigger lesson is not “use RTK” or “don’t use RTK.”</p><p>The bigger lesson is that AI cost optimization needs measurement.</p><p>Before adopting any token-saving tool, teams should ask:</p><ul><li>Which token stream does this tool affect?</li><li>Does that stream represent a meaningful part of our bill?</li><li>Are those tokens expensive fresh/input/output tokens or cheap cached tokens?</li><li>Does compression risk hiding important information from the agent?</li><li>What code, prompts, or credentials can this tool access?</li><li>Can we measure before and after on real sessions?</li></ul><p>Without that analysis, teams may optimize the wrong layer.</p><h3>Final Takeaway</h3><p>RTK, headroom, and caveman are useful tools, but they are not magic.</p><p>They can significantly compress specific types of content, especially repetitive terminal output, search results, diffs, and verbose prose.</p><p>But real-world LLM bills are broader than those isolated payloads. Prompt caching, native tool usage, output tokens, and workload shape all affect the final savings.</p><p>The right conclusion is pragmatic:</p><p>Use compression tools where they improve context quality and reduce obvious waste.<br>Do not expect benchmark-level savings across your full AI engineering bill.<br>And always weigh token savings against security and correctness risk.</p><p>For AI engineering teams, the path forward is measurement, not hype.</p><p>Source: <a href="https://codepointer.substack.com/p/cutting-llm-token-costs-with-rtk">Code Pointer — Cutting LLM Token Costs with rtk, headroom, and caveman</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=591660dea61e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Reliable Event Deduplication Layer with Redis]]></title>
            <link>https://medium.com/@akadarshkashyap/building-a-reliable-event-deduplication-layer-with-redis-45c7bf7e050c?source=rss-d4f4c3d783e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/45c7bf7e050c</guid>
            <dc:creator><![CDATA[Adarsh Kashyap]]></dc:creator>
            <pubDate>Sun, 21 Sep 2025 19:12:24 GMT</pubDate>
            <atom:updated>2025-09-21T19:12:24.232Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern distributed systems, <em>events</em> form the backbone of communication. Whether it’s a clickstream, a user action, or an IoT signal, events are fired continuously from the frontend or edge devices and processed by backend services.</p><p>Without careful design, these scenarios can lead to <strong>duplicate event processing</strong> — corrupting data, inflating counts, or causing inconsistent system behavior.</p><p>This post explores how we designed and implemented a <strong>Redis-based deduplication layer</strong> to ensure <strong>event-level idempotency</strong></p><h3>Why Events Get Duplicated</h3><p>Events may seem like atomic actions, but in reality they’re prone to duplication:</p><ol><li><strong>Retries on unreliable networks</strong> — A client fires an event, goes offline, and retries without knowing the first attempt succeeded.</li><li><strong>UI double-submission</strong> — A user clicks “Submit” twice, firing two identical events.</li><li><strong>Multiple servers</strong> — In a load-balanced cluster, two servers may receive and process the same event.</li><li><strong>Batch processing retries</strong> — If part of a batch succeeds and part fails, retries can reprocess already-handled events.</li></ol><p>Relying solely on <strong>database unique constraints</strong> is not sufficient — they add latency, don’t scale well under high throughput, and don’t cover in-flight duplicate requests.</p><p>We need a <strong>fast, distributed, fault-tolerant deduplication mechanism</strong>.</p><h3>The Deduplication Strategy</h3><p>At a high level, we want to guarantee that:</p><ol><li>Each event has a <strong>unique request ID</strong>.</li><li>The system processes each request <strong>at most once</strong>.</li><li>Retries are absorbed without triggering reprocessing.</li></ol><h3>Step 1. Generating Unique Request IDs</h3><p>Each frontend request attaches a unique identifier. A simple format is:</p><pre>clientId_timestampMillis</pre><p>This works in most cases, though clients firing multiple requests in the same millisecond could still clash. To reduce collisions:</p><ul><li>Append a sequence counter.</li><li>Or use UUIDs.</li></ul><p>The important part is that the <strong>same retry carries the same request ID</strong>.</p><h3>Step 2. Redis as a Deduplication Cache</h3><p>Redis is ideal for high-throughput deduplication:</p><ul><li><strong>Low latency</strong> lookups.</li><li><strong>Atomic operations</strong> via Lua scripts.</li><li><strong>TTL (time-to-live)</strong> for auto-expiry of processed IDs.</li></ul><p>A simple approach:</p><ol><li><strong>Check cache</strong> for requestId.</li></ol><ul><li>If COMPLETED → drop event (duplicate).</li><li>If IN_PROGRESS → drop event (duplicate in flight).</li><li>If not found → continue.</li></ul><ol><li><strong>Insert into cache</strong> → requestId = IN_PROGRESS.</li><li>Run <strong>business logic</strong> and persist to DB.</li><li>Update cache → requestId = COMPLETED.</li></ol><h3>Two-Phase Commit for Deduplication</h3><p>The naive approach works, but failures can still cause trouble.</p><p>To make deduplication <strong>fault-tolerant</strong>, we extend the design into a <strong>two-phase commit model</strong> with Redis:</p><ol><li><strong>IN_PROGRESS Phase</strong> → Event picked up, being processed.</li><li><strong>TERMINATED Phase</strong> → Event successfully written to DB.</li></ol><h3>Event Lifecycle</h3><ol><li><strong>Event arrives</strong></li></ol><ul><li>Check Redis for eventId.</li><li>If not found → insert eventId = IN_PROGRESS @ t1 with TTL = 10 minutes.</li><li>If already present → drop as duplicate.</li></ul><ol><li><strong>DB write (transactional)</strong></li></ol><ul><li>Insert/update records with a <strong>unique constraint on eventId</strong>.</li></ul><p><strong>2. Mark completion</strong></p><ul><li>Update Redis → eventId = TERMINATED @ t2 with TTL = 24 hours.</li></ul><h3>Handling Failures</h3><p><strong>Crash before DB write</strong></p><ul><li>Redis still shows IN_PROGRESS.</li><li>TTL ensures lock expires.</li><li>Retry after 10 minutes → safe reprocessing.</li></ul><p><strong>Crash after DB write, before TERMINATED</strong></p><ul><li>DB contains the event, Redis doesn’t.</li><li>Retry may reprocess.</li><li>Unique constraint in DB ensures retry fails safely.</li></ul><h3>Example Redis States</h3><p>EventIdStatusTimestampTTLMeaningevt123IN_PROGRESSt110 minEvent picked, waiting for DB commitevt123TERMINATEDt224 hrEvent processed, retry should be ignored</p><h3>Why Two TTLs?</h3><ul><li><strong>Short TTL for IN_PROGRESS</strong> → prevents zombie events after crashes.</li><li><strong>Long TTL for TERMINATED</strong> → prevents duplicates for at least a day.</li></ul><p>This combination balances <strong>fault tolerance</strong> (safe retries) and <strong>memory efficiency</strong> (old events eventually expire).</p><h3>Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FNIIxOs9BKcSg1q8cnHttw.png" /></figure><p>Here’s the simplified flow:</p><h3>Lessons Learned</h3><ol><li><strong>Idempotency is not optional</strong> — retries are inevitable.</li><li><strong>Cache-first deduplication</strong> keeps latency low.</li><li><strong>Two-phase commit</strong> protects against partial failures.</li><li><strong>DB unique constraints</strong> remain the final safety net.</li><li><strong>TTL tuning</strong> is critical for balancing retries and memory usage.</li></ol><h3>Final Thoughts</h3><p>By implementing a Redis-based deduplication layer with two-phase commit semantics, we ensured:</p><ul><li><strong>Event-level idempotency</strong></li><li><strong>Fault tolerance against crashes and retries</strong></li><li><strong>Low-latency event processing at scale (5M+ events/day)</strong></li></ul><p>This approach isn’t limited to a single industry — it’s a <strong>generic pattern for any event-driven distributed system</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45c7bf7e050c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Concurrency, Async & Parallelism]]></title>
            <link>https://medium.com/@akadarshkashyap/concurrency-async-parallelism-ef5b44719ca1?source=rss-d4f4c3d783e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef5b44719ca1</guid>
            <dc:creator><![CDATA[Adarsh Kashyap]]></dc:creator>
            <pubDate>Sun, 21 Sep 2025 18:41:22 GMT</pubDate>
            <atom:updated>2025-09-21T18:41:22.284Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern software development, terms like <strong>concurrency</strong>, <strong>asynchronous programming</strong>, and <strong>parallelism</strong> are often used interchangeably. But they’re not the same. Understanding these concepts is key to writing performant, scalable applications — especially in languages like JavaScript and Scala.</p><p>This article walks through the differences, explains how JavaScript’s event loop enables asynchronous behavior, and contrasts it with Scala’s multi-threaded Futures.</p><h3>🔹 Concurrency vs. Parallelism vs. Async</h3><ul><li><strong>Concurrency</strong><br> Multiple tasks are <em>in progress</em> at the same time, but not necessarily executing simultaneously. In a single-threaded system, tasks are interleaved — giving the illusion of simultaneous work.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1JHla9g5G8Atx3cDoez4DQ.png" /></figure><p>So in this example with points A, B, and C:</p><ul><li>They’re not literally executing at the same time.</li><li>The scheduler gives each small slices of CPU time, so you see progress on all tasks “together.”</li><li>This is how JavaScript’s event loop works — one main thread, tasks interleaved</li></ul><p>On a <strong>single thread</strong>, only <strong>one operation</strong> can <em>actually execute at a time</em>. The CPU switches between tasks so fast (context switching / time slicing) that it <strong>appears</strong> multiple things are happening simultaneously, but at any instant only one instruction is running.<br>This is the essence of <strong>concurrency</strong> on a single thread</p><p><strong>Parallelism</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nwuaf3Lm9ZBy4hs6NFXOgA.png" /></figure><p><strong>Parallelism</strong><br>Tasks are actually executing <em>at the same time</em> on different threads or cores. True parallelism requires hardware support for multiple execution contexts.</p><p><strong>Parallelism</strong> involves multiple threads (or cores) working simultaneously. At any given moment, all processes are genuinely running at the same time.</p><ul><li><strong>Concurrency</strong> = Dealing with lots of things at once (interleaving).</li></ul><blockquote><strong>Concurrency: </strong>Dealing with lots of things at once (interleaving).<br><strong>Parallelism: </strong>Doing lots of things at once (simultaneous execution).</blockquote><p><strong>Asynchronous Programming</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dpLpqI5lNiVxx8c7gBnqiA.png" /></figure><p>A task is deferred to complete later, freeing up the main thread to keep working. Async does <strong>not</strong> automatically mean parallel execution.</p><p>In the <strong>Async diagram</strong>:</p><ol><li><strong>Request 1 is sent</strong> — The program initiates Request 1 but <strong>does not wait</strong> for the response to come back immediately.</li><li><strong>Request 2 is sent</strong> — Right after sending Request 1, the program can start Request 2 <strong>without waiting</strong> for Request 1’s response.</li><li><strong>Response 1 arrives</strong> — Once the server or external system finishes processing Request 1, Response 1 comes back and is handled.</li><li><strong>Response 2 arrives</strong> — Similarly, Response 2 is handled when Request 2 finishes.</li></ol><p>✅ Key point: <strong>No request blocks the execution of the next one.</strong> Each request is independent, and the program can continue running other tasks while waiting for responses. This is why JavaScript (JS) often uses async calls with Promises, async/await, or callbacks for non-blocking operations.</p><p>In one line:</p><blockquote><em>One task does </em><strong><em>not wait</em></strong><em> for another to finish; results are handled whenever they arrive.</em></blockquote><p>⚠ <strong>Key takeaway:</strong> Async ≠ Parallelism. They’re separate concepts.</p><h3>🔹 JavaScript’s Event Loop — Async Without Threads</h3><p>JavaScript is single-threaded, but it can still perform non-blocking I/O thanks to the <strong>event loop</strong>.</p><ul><li><strong>Call Stack:</strong> Where the main execution happens.</li><li><strong>Task Queue:</strong> Where async callbacks (like setTimeout) are queued.</li><li><strong>Event Loop:</strong> The heartbeat that moves tasks from the queue to the stack when the stack is empty.</li></ul><p>This mechanism lets JS perform non-blocking operations even though it only has one main thread.</p><h3>🔹 Microtasks vs. Macrotasks</h3><p>In JavaScript, async tasks are divided into two queues:</p><ul><li><strong>Macrotasks:</strong> setTimeout, setInterval</li><li><strong>Microtasks:</strong> Promise.then, queueMicrotask</li></ul><p>Example:</p><pre>console.log(&#39;A&#39;);<br>setTimeout(() =&gt; console.log(&#39;B&#39;), 0); // Macro<br>Promise.resolve().then(() =&gt; console.log(&#39;C&#39;)); // Micro<br>console.log(&#39;D&#39;);</pre><p>Output:</p><pre>A<br>D<br>C<br>B</pre><p>Why? Because microtasks run <strong>after the current JS code and before macrotasks</strong>.</p><h3>🔹 How fetch() Works With the Event Loop</h3><p>When you call fetch():</p><ol><li>Browser handles the HTTP request in the background (non-blocking)</li><li>.then() callback is queued as a <strong>microtask</strong> once the response is ready.</li><li>JavaScript continues execution without waiting.</li></ol><p>Example:</p><pre>fetch(&#39;/api&#39;)<br>  .then(res =&gt; res.json())<br>  .then(data =&gt; console.log(data));</pre><p>The HTTP request happens in the background, and your JS code keeps running.</p><h3>🔹 Scala Futures — Async with Threads</h3><p>Scala’s Future runs on a <strong>thread pool</strong>, which allows true parallelism.</p><pre>import scala.concurrent._<br>import ExecutionContext.Implicits.global<br>import scala.util._</pre><pre>val f = Future {<br>  &quot;Hello&quot;<br>}</pre><pre>f.onComplete {<br>  case Success(value) =&gt; println(value)<br>  case Failure(e) =&gt; println(&quot;Error: &quot; + e)<br>}</pre><p>Here, the Future runs asynchronously using a thread pool. This is <strong>parallel execution</strong>, unlike JavaScript’s single-threaded event loop.</p><h3>JavaScript vs Scala Futures at a Glance</h3><p>FeatureJavaScriptJVM (Scala)ModelEvent LoopThread PoolAsync APIsPromises / async–awaitFuture / onCompleteQueue TypeMicro/Macrotask queuesExecutionContext queueThreadsSingle thread + I/O offloadMulti-threadedBlockingNot allowedAllowed (but discouraged)</p><h3>🔹 RxJS: subscribe() and Schedulers</h3><p>In JavaScript, <strong>Observables</strong> are lazy — nothing happens until you call .subscribe(). When you subscribe:</p><ul><li>Async logic (like HTTP requests) starts</li><li>Browser handles the request in the background.</li><li>Response is queued via the event loop.</li><li>Your callback runs when the event loop dequeues it.</li></ul><p>Example:</p><pre>console.log(&#39;A&#39;);<br>this.http.get(&#39;/api&#39;).subscribe(() =&gt; console.log(&#39;B&#39;));<br>console.log(&#39;C&#39;);</pre><p>Output:</p><pre>A<br>C<br>B</pre><p>RxJS also gives you <strong>Schedulers</strong> to control <em>when</em> and <em>where</em> Observable code runs:</p><ul><li>queueScheduler – synchronous</li><li>asapScheduler – microtask</li><li>asyncScheduler – macrotask</li></ul><p>Example:</p><pre>import { of, asapScheduler } from &#39;rxjs&#39;;</pre><pre>console.log(&#39;Start&#39;);</pre><pre>of(&#39;Stream&#39;, asapScheduler).subscribe(console.log);</pre><pre>console.log(&#39;End&#39;);</pre><h3>🔹 Key Takeaways</h3><ul><li><strong>JavaScript’s event loop</strong> enables async behavior without threads.</li><li><strong>Microtasks run before macrotasks</strong> in JS execution order.</li><li><strong>Scala’s Futures</strong> use a thread pool for true parallelism.</li><li><strong>Async ≠ threading</strong> — it’s about timing and non-blocking behavior.</li><li><strong>Concurrency ≠ Parallelism ≠ Async</strong> — learn the differences to design better systems</li></ul><h3>Final Thoughts</h3><p>Mastering the differences between concurrency, async programming, and parallelism helps you design systems that are more efficient, responsive, and scalable. Whether you’re working with JavaScript’s event loop or Scala’s multi-threaded Futures, understanding these concepts will make you a better engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef5b44719ca1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>