<?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 Islam Hafez on Medium]]></title>
        <description><![CDATA[Stories by Islam Hafez on Medium]]></description>
        <link>https://medium.com/@islamhafez0?source=rss-e1fdebe6da8e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LCdp8A6mZ49ll7muL517LA.jpeg</url>
            <title>Stories by Islam Hafez on Medium</title>
            <link>https://medium.com/@islamhafez0?source=rss-e1fdebe6da8e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:19:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@islamhafez0/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The React Compiler Just Made Your Memoization Knowledge Obsolete. Here’s What to Learn Instead.]]></title>
            <link>https://medium.com/@islamhafez0/the-react-compiler-just-made-your-memoization-knowledge-obsolete-heres-what-to-learn-instead-def4b0578da0?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/def4b0578da0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-performance]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Sat, 25 Jul 2026 00:13:25 GMT</pubDate>
            <atom:updated>2026-07-25T00:16:37.169Z</atom:updated>
            <content:encoded><![CDATA[<h3>The React Compiler Just Made Your Memoization Knowledge Obsolete. Here’s What to Learn Instead.</h3><h3>React Compiler v1.0 didn’t just automate a task. It deprecated a decade of hard-won React expertise — and replaced it with a different set of questions entirely.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8L1hixH0PnBbcSYfBdxeA.png" /></figure><p>Let me describe a type of React developer you’ve definitely met.</p><p>They know the render cycle cold. They can look at a component tree and tell you exactly which renders are unnecessary, which callbacks are being recreated on every tick, which derived values are being recomputed when they don’t need to be. They reach for useMemo, useCallback, and React.memo with the confidence of someone who learned the hard way — through sluggish UIs, through profiler sessions, through the specific frustration of watching a list re-render 60 times per second because a parent component passed a new object reference on every render.</p><p>That knowledge took years to build. It was legitimate expertise.</p><p>React Compiler v1.0, which shipped stable in October 2025, is more precise at memoization than they are. It catches cases they’d miss. It memoizes at a granularity that useMemo literally cannot reach — including values computed <em>after</em> an early conditional return, which a hook can&#39;t even touch. It does all of this at build time, with no runtime cost, and it has been running in production at Meta — including the Quest Store — for years before most developers heard of it.</p><p>The question isn’t whether to use the compiler. The answer to that is yes, immediately, for every new project. The question is: what does React expertise actually mean now? What’s left to know when the compiler handles the part that used to separate good React developers from great ones?</p><p>That’s a more interesting question than “how do I set it up” — and it’s the one nobody is answering.</p><h3>What the Compiler Actually Does (Precisely, Not Vaguely)</h3><p>Every tutorial says “it automatically memoizes your components.” That’s true but undersells the mechanism.</p><p>Before the compiler, React’s rendering model was pull-based and pessimistic: re-render everything, and it’s your job to opt out of unnecessary work. Every time a parent re-rendered, all its children re-rendered too — unless you’d manually wrapped values in useMemo, functions in useCallback, and components in React.memo. The API told you <em>how</em> to opt out, but not <em>where</em>. Finding the right places required profiling, intuition, and enough experience to recognize the patterns.</p><p>The compiler flips this at the source level. It reads your component as static code, tracks every variable, traces which values can change between renders and which cannot, and inserts memoization exactly where it’s needed — not where you <em>think</em> it’s needed. The result in your compiled output looks roughly like this:</p><pre>// What you write<br>function ProductCard({ product, onAddToCart }) {<br>  const discountedPrice = product.price * (1 - product.discount);<br>  const handleClick = () =&gt; onAddToCart(product.id);</pre><pre>  return (<br>    &lt;div onClick={handleClick}&gt;<br>      &lt;h2&gt;{product.name}&lt;/h2&gt;<br>      &lt;span&gt;${discountedPrice.toFixed(2)}&lt;/span&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><pre>// What the compiler produces (conceptually)<br>function ProductCard({ product, onAddToCart }) {<br>  const $ = _cache(4);<br>  <br>  let discountedPrice;<br>  if ($[0] !== product.price || $[1] !== product.discount) {<br>    discountedPrice = product.price * (1 - product.discount);<br>    $[0] = product.price;<br>    $[1] = product.discount;<br>    $[2] = discountedPrice;<br>  } else {<br>    discountedPrice = $[2];<br>  }</pre><pre>  // handleClick, JSX — same granular caching<br>}</pre><p>You write plain JavaScript. The compiler produces precisely memoized JavaScript. No dependency arrays. No referential equality juggling. No useMemo that wraps too much or too little.</p><p>The Meta Quest Store saw initial load improvements up to 12% and certain interactions become 2.5× faster — on a codebase that already had experienced engineers manually optimizing for years. The compiler found things they didn’t.</p><h3>The Three Hooks That Just Became Escape Hatches</h3><p>useMemo, useCallback, and React.memo still exist. They still work. The compiler doesn&#39;t remove them — it works <em>around</em> them, though with a catch worth knowing: if your manual memoization doesn&#39;t match what the compiler would have inferred, it bails out of optimizing that component entirely. Your manual hook becomes a ceiling, not a floor.</p><p>The mental model that needs to change: these hooks were defaults. Now they’re exceptions.</p><p><strong>Every </strong><strong>useMemo in your codebase in 2026 should have a documented reason.</strong> Not &quot;this is expensive&quot; — specific. Here are the three cases where the compiler genuinely can&#39;t help and manual memoization still earns its place:</p><p><strong>1. Third-party libraries that depend on referential equality.</strong> The classic example is TanStack Table V8, where internal comparison logic assumes stable function references. The compiler can’t know what an external library does with a value — it only sees your code. If a chart library, canvas system, or any callback-by-reference API needs a stable reference that the compiler might not preserve, keep the hook. Document why.</p><pre>// Keep this — TanStack Table V8 compares column defs by reference<br>const columns = useMemo(() =&gt; [<br>  { header: &#39;Name&#39;, accessorKey: &#39;name&#39; },<br>  // ...<br>], []); // Explicitly stable — compiler won&#39;t catch cross-library expectations</pre><p><strong>2. Values inside </strong><strong>try/catch blocks.</strong> The compiler can&#39;t analyze control flow that might throw. If your useMemo lives inside a try/catch — common in error-boundary-heavy code — the compiler skips it. Keep the hook there. This is a known limitation the React team has flagged for future work.</p><pre>// Compiler skips this — keep useMemo<br>try {<br>  const processed = useMemo(() =&gt; riskyTransform(data), [data]);<br>} catch (e) {<br>  // ...<br>}</pre><p><strong>3. Explicit </strong><strong>useEffect dependency control.</strong> If a memoized value feeds into a useEffect dependency array and you need precise control over when the effect fires — not just when the value changes, but <em>which</em> change triggers it — manual memoization gives you that control. The compiler is more granular than you, but it&#39;s also automatic. When you need to reason explicitly about effect timing, own that explicitly.</p><p>Everything outside these three cases: let the compiler handle it. If you’re reaching for useMemo on derived state, formatted values, filtered arrays, or inline callbacks — that&#39;s habit, not necessity. Remove it and let the compiler do it more precisely than you would have.</p><h3>The Migration You Should Actually Do</h3><p>Don’t delete all your memoization in one PR. That’s how you create regressions nobody can diagnose on a Tuesday morning.</p><p><strong>Step 1 — Enable the compiler first, ship nothing else.</strong></p><pre>npm install babel-plugin-react-compiler@latest eslint-plugin-react-hooks@7</pre><p><strong>For Next.js 16:</strong></p><pre>// next.config.js<br>const nextConfig = {<br>  reactCompiler: true,<br>};</pre><p><strong>For Vite:</strong></p><pre>// vite.config.js<br>import { defineConfig } from &#39;vite&#39;;<br>import react from &#39;@vitejs/plugin-react&#39;;</pre><pre>export default defineConfig({<br>  plugins: [<br>    react({<br>      babel: {<br>        plugins: [&#39;babel-plugin-react-compiler&#39;],<br>      },<br>    }),<br>  ],<br>});</pre><p>Ship this. Verify in production. Check your performance metrics — Lighthouse, Core Web Vitals, whatever you track. If something breaks, use &quot;use no memo&quot; to exclude that component temporarily and file an issue:</p><pre>function ProblematicComponent({ data }) {<br>  &quot;use no memo&quot;; // TODO: investigate compiler interaction with ExternalLib<br>  // ...<br>}</pre><p><strong>Step 2 — Remove manual memoization incrementally, starting with the obvious.</strong></p><p>Derived state — useMemo on filtered lists, sorted arrays, formatted values, calculations. These are the compiler&#39;s home turf. Remove them first. The compiler handles them more granularly than your hook did.</p><pre>// Remove this<br>const sortedItems = useMemo(<br>  () =&gt; [...items].sort((a, b) =&gt; a.name.localeCompare(b.name)),<br>  [items]<br>);</pre><pre>// Just write this<br>const sortedItems = [...items].sort((a, b) =&gt; a.name.localeCompare(b.name));</pre><p><strong>Step 3 — Audit what remains.</strong></p><p>After the compiler is enabled and the easy memoization is gone, look at what’s left. Every surviving useMemo and useCallback should be in one of the three categories above. If it isn&#39;t, it&#39;s noise — remove it. If it is, add a comment explaining why. That comment is now load-bearing documentation.</p><h3>What React Expertise Actually Looks Like Now</h3><p>Here’s the honest answer to the question that matters.</p><p>The compiler took one specific skill off the table: the ability to manually optimize React’s render cycle through memoization. That skill was real. It mattered. For a decade it separated developers who understood React’s internals from those who didn’t.</p><p>What it didn’t take is everything else.</p><p>Understanding <em>why</em> components re-render — the fundamental model of React’s reactivity — still matters. The compiler optimizes inside that model; it doesn’t replace the model. A developer who doesn’t understand the render cycle can’t reason about the three cases where the compiler fails. They can’t diagnose the &quot;use no memo&quot; situations. They can&#39;t tell when an effect is firing too often because the compiler&#39;s memoization changed the reference the effect was watching.</p><p>Understanding the server/client boundary is now the harder problem. With React Server Components, the question isn’t “did this value memoize correctly?” — it’s “should this data even reach the client, or should it stay on the server?” The compiler has nothing to say about that. That’s architectural judgment, and no compiler replaces it.</p><p>Understanding composition — how to structure components so the compiler can see what it needs to see — is now an explicit skill. The compiler works best on components that follow the Rules of React cleanly: pure render functions, no mutations during render, no reading from mutable external state without proper subscriptions. Write messy components and the compiler bails out on them. Write clean ones and it makes them fast for free.</p><p>The developers who understood React deeply enough to optimize it manually will adapt faster than the ones who learned the patterns without the principles. The patterns are gone. The principles are what’s left.</p><h3>The Broader Signal</h3><p>React started as a UI library that made you think explicitly about when things render. That was the deal — you got predictability in exchange for writing your own optimization layer.</p><p>The compiler ends that deal. You no longer have to think about when things render, because the compiler thinks about it for you, more precisely than you could.</p><p>That’s not a loss of control. It’s a shift in <em>what</em> you control. You still decide what components exist, what data they receive, where the server boundary sits, how the state flows, which effects fire and when. The compiler handles the mechanical work of making those decisions fast.</p><p>A decade ago, a good React developer was someone who understood the render cycle well enough to optimize it. That’s still worth understanding — but it’s no longer the ceiling. The ceiling is now architecture: how you structure data flow, where you place boundaries, what you put on the server versus the client, how you design components that are easy for both humans and compilers to reason about.</p><p>The compiler didn’t make React easier. It made the easy problems automatic and surfaced the hard ones.</p><h3>Setup in 60 Seconds</h3><pre># Install<br>npm install babel-plugin-react-compiler@latest eslint-plugin-react-compiler</pre><pre># Verify it&#39;s working — look for the &quot;Memo ✨&quot; badge in React DevTools<br># on components the compiler successfully optimized</pre><p>Compatible with React 17 and up. Works with Next.js 16 (reactCompiler: true), Vite, Remix, and React Router v7. Expo SDK 54 ships with it enabled by default.</p><p>The ESLint plugin (eslint-plugin-react-compiler) catches Rules of React violations that would cause the compiler to bail out — run it before enabling the compiler in production so you know what you&#39;re working with.</p><p><em>React Compiler v1.0 release notes: react.dev/blog/2025/10/07/react-compiler-1. All performance figures from Meta’s production deployment of the Quest Store. Compiler behavior verified against React docs as of July 2026.</em></p><p>Happy Coding !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=def4b0578da0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You’re Not Writing Code Anymore. You’re Reviewing It. Are You Any Good at That?]]></title>
            <link>https://medium.com/@islamhafez0/youre-not-writing-code-anymore-you-re-reviewing-it-are-you-any-good-at-that-21666c2fb6f3?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/21666c2fb6f3</guid>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[developer-productivity]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[engineering-culture]]></category>
            <category><![CDATA[ai-tools]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Mon, 13 Jul 2026 20:38:33 GMT</pubDate>
            <atom:updated>2026-07-13T20:38:33.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="You’re Not Writing Code Anymore. You’re Reviewing It. Are You Any Good at That? — by Islam Hafez" src="https://cdn-images-1.medium.com/max/1024/1*fwHSff4-enp2V9XAMk0Xbw.png" /></figure><h3>AI flipped the ratio overnight. Most developers are now spending more time reviewing than writing — using skills they never trained for, on code they didn’t write, that looks correct until it isn’t.</h3><p>Here’s a number that should change how you think about your job: <strong>42%.</strong></p><p>That’s the share of committed code that is now AI-generated, according to Sonar’s 2026 State of Code survey of 1,149 professional developers. Not prototypes. Not throwaway scripts. Committed code. In production codebases. Owned by teams.</p><p>The other number that belongs next to it: <strong>48%.</strong></p><p>That’s the share of developers who <em>always</em> check AI-generated code before committing it. Which means more than half are committing code they haven’t fully verified, into systems other people have to maintain, with bugs they haven’t found yet.</p><p>This isn’t a story about AI being bad. It’s a story about a skill gap that the industry created in about eighteen months and hasn’t addressed yet. The tools changed the job. The training didn’t follow.</p><h3>The Job Changed. The Job Description Didn’t.</h3><p>Writing code and reviewing code feel like the same activity. They’re not.</p><p>Writing is <strong>generative</strong>. You start with intent — “I need a function that paginates a database query” — and you produce something that didn’t exist. Your brain is in construction mode. You make decisions constantly: naming, structure, edge cases, abstractions. The cognitive load is creative.</p><p>Reviewing is <strong>forensic</strong>. You start with something that already exists and interrogate it. Your brain needs to be in adversarial mode — not “what does this do?” but “what does this do that it <em>shouldn’t</em>?” and “what is it supposed to do that it <em>doesn’t</em>?” That’s a fundamentally different cognitive posture. It requires active skepticism toward something that, at first glance, appears to work.</p><p>The problem with AI-generated code is that it’s extraordinarily good at <em>appearing to work</em>. It is syntactically correct. It follows the patterns in the codebase. It handles the happy path cleanly. It looks, at a quick scan, like code a competent developer wrote on a focused afternoon.</p><p>CodeRabbit’s analysis of 470 open-source pull requests found that AI-generated code carries 1.7 times more defects than human-written code. Not 1.7 times more <em>obvious</em> defects — 1.7 times more <em>total</em> defects. The bugs aren’t the kind that jump out. They’re the kind that hide.</p><p>If you review AI-generated code the same way you review a colleague’s pull request — skimming for obvious problems, checking naming, making sure the tests pass — you are not actually reviewing it. You’re approving it.</p><h3>The “Almost Right” Problem</h3><p>The top developer frustration with AI tools, cited by 66% of respondents, is “AI solutions that are almost right, but not quite.”</p><p>“Almost right” is the most dangerous category of code that exists. Wrong code fails fast — you see the error, you fix it. <em>Almost</em> right code passes your tests, passes review, ships to production, and surfaces at 2am six months later as an incident with no obvious cause.</p><p>AI is a precision manufacturer of almost-right code. It understands patterns deeply enough to produce code that fits every surface-level check. What it doesn’t have is understanding of your <em>specific system</em> — the edge case that exists because of a decision made two years ago, the external dependency that behaves unexpectedly under load, the invariant that every senior developer on the team knows about and nobody documented.</p><p>This is exactly why 96% of developers say they don’t fully trust the functional accuracy of AI-generated code. They’ve seen what “almost right” looks like in production. The trust isn’t just low — it’s been earned through experience.</p><p>The correct response to that distrust is not to use AI less. It’s to review differently.</p><h3>What “Reviewing Differently” Actually Means</h3><p>Most code review advice is about <em>what to look for</em>. Check for security vulnerabilities. Check edge cases. Check error handling. That advice is correct, but it misses the more fundamental problem: <strong>you have to change what you’re optimizing for before you can change what you’re looking for.</strong></p><p>When you review a colleague’s code, you’re primarily answering: <em>Is this correct?</em></p><p>When you review AI-generated code, you need to answer something harder: <em>Is this the right solution to the right problem?</em></p><p>The distinction matters because AI is very good at solving the problem you described and very bad at noticing that you described the wrong problem. If you ask it to implement a caching layer, it will implement a caching layer — efficiently, cleanly, with appropriate error handling. It will not tell you that your caching strategy doesn’t match your eviction requirements, or that you’re caching at the wrong layer of the stack, or that the abstraction you asked for creates a maintenance burden that outweighs the performance gain.</p><p>That judgment call is yours. Always was. The difference now is that the code <em>looks done</em> before you’ve made it.</p><p>You’re no longer primarily validating correctness. You’re judging necessity. Does this abstraction earn its weight? Is this edge case worth the complexity? Would the team want to maintain this code six months from now?</p><p>Those questions require understanding the system, not just reading the diff.</p><h3>The Fragile Expert Problem</h3><p>An experimental study found that unrestricted AI users could build features faster — but when AI was taken away for a 30-minute maintenance task, 77% failed, versus 39% in a scaffolded group. The researchers call these “fragile experts” — developers whose high output masks critically low understanding.</p><p>That’s the real stakes of getting review wrong. It’s not just bugs in the current sprint. It’s the compounding effect on the person doing the reviewing.</p><p>If you approve AI-generated code without understanding it, you haven’t reviewed it — you’ve outsourced your understanding of your own codebase to a model that will not be available when something breaks at 2am. The code is now in production. You are responsible for it. And you don’t know how it works.</p><p>GitClear and GitKraken analyzed 623 million real-world code changes from 2023 to 2026 and found AI-assisted commits make up one quarter of all commits, alongside rising technical debt across eight maintainability metrics. The clearest signal in the data: duplicate code. AI repeats patterns instead of reusing components, because it doesn’t have the full map of your codebase that a developer who’s worked in it for two years has internalized. Approve that code without catching the duplication, and you’ve just made the next refactor harder for everyone.</p><p>Bugs per developer are up 54% in the latest AI engineering data. Daily PR contexts per developer are up 67.4%. Work restarts are up 13.8%. Twenty-six percent more in-progress tasks show no activity for seven or more days.</p><p>Individual developers feel more productive. The workflow data tells a different story: more threads opened, more work abandoned, more bugs reaching customers. The speed was real. The quality wasn’t.</p><h3>The Review Process That Actually Works</h3><p>The forensic mindset needs a framework. Here’s one that works — not because it’s clever, but because it forces the right questions in the right order.</p><p><strong>Step 1 — Understand the intent before reading the code.</strong></p><p>Before you look at a single line, write one sentence describing what this code is supposed to do. Not what the PR description says — what <em>you</em> understand it to do. If you can’t write that sentence, you’re not ready to review the code. Go back to the ticket, the design doc, the conversation with the author. Understand the goal first.</p><p>This sounds obvious. It is almost never done.</p><p><strong>Step 2 — Read the tests before the implementation.</strong></p><p>Tests describe behavior. If the tests are comprehensive, they tell you what edge cases the author considered. If the tests are thin, they tell you something important about the author’s confidence in the implementation.</p><p>For AI-generated code specifically: AI tends to generate fragile tests that validate specific implementation details rather than behavior, breaking whenever code is refactored. Tests that test <em>how</em> code works rather than <em>what</em> it does are tests that protect the wrong thing. They catch refactors but miss regressions. Spotting this pattern in a review is a skill — and it’s one of the clearest signals that the AI wrote the tests alongside the implementation without a human in the loop.</p><p><strong>Step 3 — Find the path the code doesn’t cover.</strong></p><p>AI-generated code handles the happy path well. Your job is to find the other paths. Not by reading line by line, but by asking: what’s the worst input this function could receive? What happens when the external dependency is down? What happens when this runs concurrently? What happens at the boundary — empty input, maximum input, malformed input?</p><p>Pick two or three of these. Trace through the code manually. Not in your head — on paper, or in a scratch file, with actual example values. If the code handles them correctly, it probably handles the others. If it doesn’t, you’ve found the bug that would have shipped.</p><p><strong>Step 4 — Ask if it belongs.</strong></p><p>This is the question nobody asks in traditional code review because the author wrote the code and presumably knows why it exists. With AI-generated code, the relationship between author and code is different — the developer described what they wanted, accepted what came back, and is now submitting it.</p><p>So ask: Does this abstraction need to exist? Does this helper function duplicate something we already have? Does this new dependency solve a problem that wasn’t worth solving yet? AI has no opinion on whether a feature should be built. It will build whatever you describe. The question of whether you described the right thing is entirely yours.</p><p><strong>Step 5 — Own what you approve.</strong></p><p>This is behavioral, not technical. If you approve a PR, you are taking co-ownership of everything in it. Not liability in a legal sense — ownership in the engineering sense. You understand it well enough to debug it, extend it, explain it to a colleague at 2am when it’s failing.</p><p>If you can’t do that, you haven’t finished reviewing it.</p><h3>The Time Problem</h3><p>The diffs are getting larger, but we are still reviewing code in platforms that were meant for human-generated code, not AI-generated code.</p><p>Review times are up. AI-assisted developers show a 91% increase in review time. The volume of code being produced has increased faster than anyone’s capacity to review it carefully. The result is exactly what the data shows: more code shipped, more bugs reaching production, more incidents.</p><p>The instinct is to review faster to keep pace. That’s backwards. The right response is to review <em>less</em> — to be more selective about what gets AI-generated versus hand-written, and to treat AI-generated PRs with a higher bar, not a lower one, because the surface area of potential problems is larger.</p><p>IEEE Spectrum’s reporting describes coding tasks that took roughly five hours with AI assistance in 2024 now taking seven to eight hours once 2026-era debugging time gets added in. The speed advantage has partly reversed. Not because AI got worse — because the downstream costs of moving fast without reviewing carefully have accumulated.</p><h3>The Real Question</h3><p>When developers were asked which skill will be most important in the AI era, 47% ranked “reviewing and validating AI-generated code for quality and security” as number one — ahead of even “efficiently prompting AI tools” at 42%.</p><p>Developers already know this. The gap isn’t awareness — it’s that “review better” isn’t a skill you develop by being told to. It’s a skill you develop by reviewing deliberately, by being wrong about what you approved and tracing it back, by building a mental model of what AI-generated bugs look like before they surface in production.</p><p>The tools got very good very fast. The human layer that validates their output didn’t keep pace.</p><p>That’s not a criticism of AI tools. It’s a description of where the real work is now.</p><p>You’re not writing code anymore. You’re reviewing it. The question is whether you’re reviewing it like a forensic auditor who owns the outcome — or like someone skimming a diff before the standup.</p><p>The codebase knows the difference. So does production.</p><p><strong><em>Data referenced:</em></strong><em> Sonar 2026 State of Code Developer Survey (1,149 developers), CodeRabbit pull request analysis (470 PRs), Faros AI Engineering Report 2026, GitClear/GitKraken analysis of 623 million code changes, Stack Overflow Developer Survey 2025/2026, Anthropic 2026 RCT on AI-assisted comprehension.</em></p><p>Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21666c2fb6f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[POST /search Is a Lie. HTTP Finally Admits It.]]></title>
            <link>https://medium.com/@islamhafez0/post-search-is-a-lie-http-finally-admits-it-7736ad9cd675?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7736ad9cd675</guid>
            <category><![CDATA[https]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[rfc-10008]]></category>
            <category><![CDATA[api-design]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Wed, 08 Jul 2026 23:06:33 GMT</pubDate>
            <atom:updated>2026-07-08T23:06:33.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DpQ4gNV6q9IMSBj-BbimgA.png" /><figcaption>New HTTP QUERY Method by Islam Hafez</figcaption></figure><h3>POST /search Is a Lie. HTTP Finally Admits It.</h3><h3>For 30 years, every search API on the internet has been telling the protocol one thing and doing another. RFC 10008 just ended that.</h3><p>Somewhere in your codebase right now, there is a route called POST /search.</p><p>It works. It has always worked. And every developer who wrote it knew, at some level, that it was wrong — that using POST for a read-only operation was a small, quiet lie to the protocol. They wrote it anyway because HTTP left them no choice. The only verb that could carry a body was POST, and POST is defined to mean “this operation might change something.”</p><p>For three decades, every search API, every filter endpoint, every analytics query, every reporting tool on the internet made the same compromise. We picked the verb that <em>worked</em> over the verb that was <em>correct</em>, because the correct verb didn’t exist.</p><p>On June 15, 2026, after eleven years of drafts, the IETF published RFC 10008. The new method is called QUERY. And the first thing to understand about it is that it isn’t really adding something new. It’s making the protocol honest about what we were already doing.</p><h3>Why the Lie Happened in the First Place</h3><p>HTTP has always had a semantics problem for complex reads.</p><p>GET is the right verb for reading data. It’s safe (no side effects), idempotent (repeat it a hundred times, same result), and cacheable. Proxies can retry it. CDNs can cache it. Clients can prefetch it. Everything about GET is designed around the assumption that reading data is a safe operation that can be done again without consequence.</p><p>The problem is the URL. GET has no body. Your entire request — every filter, every parameter, every field — has to fit in the URI. And nobody actually knows what “fit” means, because the size limit isn’t defined by HTTP itself. It depends on the browser, the server, every proxy in between, and every CDN in the path. RFC 9110 recommends servers support at least 8,000 octets. Some support less. Some support more. None of them agree.</p><p>For simple queries, that’s fine. GET /products?category=laptops&amp;sort=price fits anywhere. But modern APIs don&#39;t stay simple:</p><pre>GET /analytics/reports<br>  ?filters[]=region:US,EU<br>  &amp;filters[]=date_range:2026-01-01..2026-06-30<br>  &amp;filters[]=revenue:&gt;10000<br>  &amp;group_by[]=month,region,product_line<br>  &amp;having[]=total_revenue:&gt;50000<br>  &amp;sort=total_revenue:desc<br>  &amp;fields[]=id,name,revenue,margin,growth_rate<br>  &amp;page=1&amp;per_page=100</pre><p>That’s not contrived. That’s a real analytics query. In a URL. And this is the mild version — Elasticsearch DSL, GraphQL queries, and SQL-style filter trees make this look minimalist.</p><p>So teams switched to POST. And POST solved the body-size problem and created a different one: POST is defined to mean “this might have side effects.” It is neither safe nor idempotent by default. Caches ignore POST responses. Proxies won’t automatically retry a failed POST. Monitoring tools flag POST calls as potentially state-changing. OpenAPI specs describe them under the “mutations” section. Every piece of infrastructure that makes decisions based on HTTP semantics now has the wrong information about what your search endpoint does.</p><p>We weren’t just working around a limitation. We were telling the protocol a lie, and that lie had real costs.</p><h3>What QUERY Actually Is</h3><p>QUERY is a single, precise addition to the HTTP method registry. Four properties, two of which it inherits from GET and two from POST:</p><p><strong>From GET:</strong> Safe. Idempotent. <strong>From POST:</strong> Carries a request body. <strong>New:</strong> Explicitly cacheable <em>with</em> a body.</p><pre>QUERY /products HTTP/1.1<br>Host: api.example.com<br>Content-Type: application/json<br>Accept: application/json</pre><pre>{<br>  &quot;filters&quot;: {<br>    &quot;category&quot;: &quot;laptops&quot;,<br>    &quot;price&quot;: { &quot;min&quot;: 500, &quot;max&quot;: 2000 },<br>    &quot;in_stock&quot;: true<br>  },<br>  &quot;sort&quot;: { &quot;field&quot;: &quot;price&quot;, &quot;direction&quot;: &quot;asc&quot; },<br>  &quot;page&quot;: 1,<br>  &quot;per_page&quot;: 50<br>}</pre><p>The request body carries the query. The method communicates what the request does. The protocol and the intent finally match.</p><p>Servers advertise which body formats they accept via a new Accept-Query response header. The RFC&#39;s examples include application/json, application/x-www-form-urlencoded, application/sql, application/jsonpath, and application/xslt+xml. QUERY doesn&#39;t care what format the body is — it&#39;s format-agnostic by design. A REST API, a GraphQL server, and an Elasticsearch cluster can all speak QUERY using their own body conventions.</p><h3>The Timeline: 11 Years. 16 Years. Both True.</h3><p>The idea behind QUERY isn’t new. The first draft circulated roughly eleven years ago. It moved through review for over a decade, reached a final draft in November 2025, received IESG approval on November 20, 2025, and was published as RFC 10008 on June 15, 2026.</p><p>The last genuinely new HTTP method before this was PATCH, published as RFC 5789 in March 2010. That makes QUERY the first new general-purpose HTTP method in <strong>sixteen years</strong>.</p><p>Both numbers — eleven years to draft, sixteen years since the last new method — are features, not bugs. HTTP underpins the entire web. A change to it gets reviewed against every server, every browser, every proxy, every CDN, every security assumption, every existing implementation that exists on the planet before it becomes a standard. That process is deliberately slow. It’s why “new HTTP method” is real news, not framework noise.</p><p>The RFC is 24 pages. Read it. It’s unusually readable for an IETF document — the problem statement alone is worth your time.</p><h3>The Author List Tells You Something</h3><p>RFC 10008 carries three names: <strong>Julian Reschke</strong> of greenbytes, <strong>James M. Snell</strong> of Cloudflare, and <strong>Mike Bishop</strong> of Akamai.</p><p>Cloudflare and Akamai, between them, sit in front of a significant portion of the web’s traffic. These aren’t academic researchers speculating about how CDNs might behave. They are the CDN. Their involvement in writing the spec means the caching behavior — the hardest part to get right — was designed by people who operate the caching infrastructure it will run on.</p><p>That matters more than it sounds. Caching a GET response is straightforward: the URL is the cache key. Caching a QUERY response requires including the request body in the cache key, and getting that wrong opens cache poisoning attacks. The spec is precise about this because the people who wrote it will also be the ones whose infrastructure gets poisoned if they got it wrong.</p><h3>Caching: The Part That Actually Changes Everything</h3><p>The difference between QUERY and POST /search isn&#39;t just semantic cleanliness. It&#39;s whether your responses can be cached.</p><p>POST responses are not cached by default. Every search request hits your server fresh. For simple APIs, that’s fine. For high-traffic search endpoints — a product catalog, a content discovery feed, a real-time analytics dashboard — it means every filter combination, every repeated query, every pagination request goes to the origin. No CDN edge caching. No shared cache hits. Your server takes the full load.</p><p>QUERY is explicitly cacheable. A CDN can store the response to a QUERY request and serve it to the next client who sends the same request body to the same URL. For read-heavy APIs, that’s not a minor ergonomic improvement. It’s a different performance tier.</p><p>The catch: the cache key must include the full request body, not just the URL. A cache that keys on the URL alone will serve one user’s search results to every user who queries the same endpoint — regardless of what their filter body says. That is a cache poisoning vulnerability, and it requires no bug in the application. It’s a misconfigured cache.</p><p>This is the part your infrastructure team needs to understand before you ship QUERY anywhere near production.</p><h3>What the Protocol Now Lets Intermediaries Do</h3><p>The semantic shift from POST to QUERY isn’t just about correctness. It’s about what intermediaries — proxies, CDNs, load balancers, API gateways — are permitted to do with your requests.</p><p>With POST, intermediaries have to assume the operation might have side effects. They won’t cache it. They won’t automatically retry a failed request. They won’t prefetch it. They treat it like a state change, because that’s what the protocol says POST might be.</p><p>With QUERY:</p><ul><li><strong>Caches</strong> can store and reuse responses.</li><li><strong>Clients</strong> can safely retry a failed QUERY without worrying about double-submission.</li><li><strong>Proxies</strong> can automatically retry on network failures.</li><li><strong>Monitoring tools</strong> can correctly classify it as a read operation.</li><li><strong>OpenAPI specs</strong> can describe it accurately without gymnastics.</li><li><strong>Rate limiters</strong> can apply read-operation quotas instead of write-operation quotas.</li></ul><p>Every layer of the stack that currently makes decisions based on HTTP method semantics gets the right information. That’s not a cosmetic improvement. Distributed systems built around HTTP use method semantics to make real decisions about retry behavior, caching, and traffic routing. Giving them accurate semantics means those decisions become correct.</p><h3>Where It Works Today (Be Specific With Yourself)</h3><p>Environment Status — July 2026 Node.js Native QUERY parsing since early 2024 ✓ OpenAPI 3.2 Full documentation support ✓ curl Supported — curl -X QUERY ... ✓ GraphQL servers Natural fit for query operations (server-side) ✓ Spring (Java) PR open, RequestMethod enum not yet updated ✗ Ruby on Rails Discussion stage only ✗ Chrome / Firefox / Safari Still evaluating; fetch() not yet ✗ WAFs (default rulesets) Not included in method allowlists pre-June 2026 ✗ CDNs (default config) Varies — verify explicitly before relying on it ✗</p><p>Node.js is ready. OpenAPI is ready. Your WAF is probably not.</p><p>The browser gap is the most significant constraint for public-facing APIs. Browser JavaScript’s fetch() doesn&#39;t support QUERY yet as of this writing, which means any API that needs to be called directly from a browser is either stuck on POST-as-fallback or waiting. For server-to-server APIs, internal APIs, and GraphQL backends, the picture is much better.</p><h3>The Security Side Nobody’s Talking About</h3><p>New HTTP methods are an attack surface before they’re a feature. Security infrastructure written before June 2026 doesn’t know QUERY exists, which creates gaps that are interesting to both attackers and defenders.</p><p><strong>WAF inspection gaps.</strong> Web application firewalls typically enforce method allowlists: GET, POST, PUT, DELETE, PATCH. A WAF that doesn’t know about QUERY might pass it through without running the injection and XSS detection rules it would run against a POST body carrying the same payload. This isn’t a theoretical problem — test it yourself:</p><pre># Send the same payload via POST first<br>curl -X POST https://target.com/api/search \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;q&quot;: &quot;test OR 1=1&quot;}&#39; -v</pre><pre># Then try QUERY<br>curl -X QUERY <a href="https://target.com/api/search">https://target.com/api/search</a> \<br>  -H &quot;Content-Type: application/json&quot; \<br>  -d &#39;{&quot;q&quot;: &quot;test OR 1=1&quot;}&#39; -v</pre><p>If your WAF blocks the POST but passes the QUERY, you’ve found a live inspection gap in your own infrastructure. Fix that before you enable QUERY in production.</p><p><strong>Cache poisoning.</strong> Already covered above — but worth repeating in plain terms. If a cache doesn’t include the full request body in its cache key, two different QUERY requests to the same URL will share a cache entry. User A searches for {&quot;category&quot;: &quot;laptops&quot;}. User B searches for {&quot;category&quot;: &quot;phones&quot;}. If the cache keys on URL alone, User B gets User A&#39;s laptop results. Worse: an attacker can deliberately populate the cache with a crafted response that other users will receive.</p><p><strong>CORS preflights.</strong> QUERY is not a CORS-safelisted method. Any browser JavaScript calling a QUERY endpoint cross-origin will trigger a preflight OPTIONS request — same as PUT or DELETE. The spec got this right on purpose. But your CDN, reverse proxy, and CORS middleware all need to handle that preflight consistently. Don’t assume — test the actual path.</p><p><strong>CSRF audit.</strong> CSRF middleware is typically scoped to state-changing methods. QUERY is safe by spec — but a developer might implement a QUERY endpoint that has an unintended side effect (logging, rate-limit tracking, “last searched” timestamp updates). If your CSRF middleware doesn’t cover QUERY because it’s “safe,” those side effects get a free pass from cross-site requests. Audit any QUERY endpoint with side effects explicitly.</p><h3>GraphQL Finally Has the Right Verb</h3><p>GraphQL is the clearest example of how far POST /search misrepresented what APIs were actually doing.</p><p>GraphQL query operations — not mutations, not subscriptions, just queries — are already safe, already idempotent, and already read-only by design. They’ve been executed over POST /graphql for years because GET couldn&#39;t carry the complex JSON bodies that GraphQL operations require.</p><p>QUERY is the verb GraphQL queries were always supposed to use. The operation is read-only. The method is now QUERY. The semantics match. CDN caching of GraphQL query responses becomes correct-by-default rather than requiring custom cache configurations that fight against POST semantics.</p><p>Server-side GraphQL frameworks are among the first candidates to ship QUERY support, and the alignment is clean enough that they should.</p><h3>The Practical Migration Path</h3><p>Don’t do a hard cutover. The ecosystem isn’t ready.</p><p>The right approach is additive: keep POST /search running alongside the new QUERY endpoint. Advertise QUERY support via the Accept-Query response header on the POST response. Let clients migrate as their tooling catches up. When QUERY traffic exceeds POST traffic for a given endpoint, deprecate POST. Until then, both coexist.</p><p>Before you enable QUERY anywhere that matters, four things need to be explicitly verified:</p><p><strong>1. Your framework routes it.</strong> Don’t assume — check the specific version. Spring doesn’t yet. Rails doesn’t yet. Express with Node 22+ does.</p><p><strong>2. Your WAF inspects the body.</strong> Run the comparison test above. If the WAF treats the QUERY body differently from a POST body, that’s a problem to fix now, not after you’ve launched.</p><p><strong>3. Your cache includes the body in the key.</strong> This is the highest-priority item for any public API. A misconfigured cache is worse than no caching — it serves wrong data to real users.</p><p><strong>4. Your CORS and CSRF middleware covers it.</strong> Don’t rely on inheritance from POST behavior. Explicitly add QUERY to the method list your security middleware handles.</p><h3>The Honest Summary</h3><p>Property GET POST QUERY Safe (no side effects) Yes No <strong>Yes</strong> Idempotent Yes No <strong>Yes</strong> Cacheable by default Yes No <strong>Yes</strong> Carries a request body No Yes <strong>Yes</strong> CORS preflight required No Depends <strong>Yes</strong> Standard since 1991 1996 <strong>June 2026</strong></p><h3>What This Signals About HTTP Itself</h3><p>PATCH took sixteen years from proposal to wide adoption. QUERY will probably follow a similar arc. The IETF doesn’t ship methods on a quarterly release cycle, and that’s exactly why each one matters.</p><p>The gap since PATCH was published in March 2010 is sixteen years. In those sixteen years, the web went from REST APIs being novel to REST APIs being infrastructure. The entire time, every search endpoint on the internet was using the wrong verb, and the protocol had no answer.</p><p>RFC 10008 is a 24-page document. It will take years to fully propagate through frameworks, WAFs, CDNs, and developer habits. But the vocabulary of HTTP — the shared language every API on the internet speaks — just got one new word. A word that makes it possible, for the first time, to say what POST /search was always trying to say.</p><p><em>RFC 10008 is available in full at rfc-editor.org/info/rfc10008. The IESG approval record and public review comments are on the IETF datatracker at datatracker.ietf.org/doc/rfc10008. All framework and browser support statuses are current as of July 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7736ad9cd675" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript ES2026 Is Not a Feature Drop. It’s a 30-Year Debt Payment.]]></title>
            <link>https://medium.com/@islamhafez0/javascript-es2026-is-not-a-feature-drop-its-a-30-year-debt-payment-826a4713b486?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/826a4713b486</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ecmascript-2026]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[es2026]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 14:00:00 GMT</pubDate>
            <atom:updated>2026-06-27T14:00:00.114Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8aNPOD9G_5d-O3jqB01Bw.png" /><figcaption>ES2026 — Islam Hafez</figcaption></figure><h3>TC39 didn’t ship new features. They fixed embarrassments. Here’s what broke, why it stayed broken, and what finally changed.</h3><p>Let’s be honest about something most “ES2026 features” posts won’t say: almost nothing in this release is genuinely <em>new</em>. The Temporal API has been in development since 2017. Explicit resource management has been a Stage 3 proposal since 2021. Math.sumPrecise exists because JavaScript has been silently miscalculating sums for three decades and nobody wanted to say it loud.</p><p>ES2026 is not innovation. It’s housekeeping. Important, overdue housekeeping — the kind where you finally fix the leaky pipe that’s been behind the wall since the house was built.</p><p>That framing actually makes it <em>more</em> interesting, not less. Because the question isn’t “what’s new?” — it’s “why did it take this long, and does it actually solve the problem?”</p><p>Let’s go through it.</p><h3>1. The Date Object Was a Copy-Paste from Java. In 1995. Java Deprecated It in 1997.</h3><p>I want you to sit with that sentence for a moment.</p><p>JavaScript’s Date object was copied from java.util.Date when Brendan Eich wrote the language in ten days. Java looked at that same API two years later and deprecated it. We kept using it for <strong>thirty years</strong>.</p><p>The specific ways Date is broken are almost artistic in their variety:</p><ul><li>Months are zero-indexed. January is 0. December is 11. Days start at 1 though, because why be consistent?</li><li>Date objects are <strong>mutable</strong>. Call .setMonth() and you&#39;ve silently modified your original. No warning. No error. Just a bug waiting to happen.</li><li>Timezone support is basically “local time” or “UTC.” That’s it. Need “what time is it right now in Tokyo for a user in Berlin?” — write your own math or import a library.</li><li>Date string parsing is implementation-defined. The same string can return different results in Chrome and Safari.</li></ul><p>The broader JavaScript ecosystem’s response was to build moment.js, then date-fns, then luxon, then dayjs — four major libraries that exist for one reason: Date is unusable for serious work.</p><p><strong>Temporal fixes all of it.</strong> Here’s what the same operations look like:</p><pre>// No more zero-indexed months<br>const launch = Temporal.PlainDate.from({ year: 2026, month: 6, day: 27 });</pre><pre>// Immutable by default — add() returns a new object<br>const oneWeekLater = launch.add({ days: 7 });<br>// launch is still 2026-06-27. Always.</pre><pre>// Real timezone support using IANA zone names<br>const nyTime = Temporal.ZonedDateTime.from(&quot;2026-06-27T14:30[America/New_York]&quot;);<br>const tokyoTime = nyTime.withTimeZone(&quot;Asia/Tokyo&quot;);<br>// &quot;2026-06-28T03:30:00+09:00[Asia/Tokyo]&quot;</pre><pre>// Duration math that actually works<br>const start = Temporal.PlainDate.from(&quot;2026-01-01&quot;);<br>const end = Temporal.PlainDate.from(&quot;2026-06-27&quot;);<br>const diff = start.until(end);<br>console.log(diff.toString()); // &quot;P5M26D&quot; — 5 months, 26 days</pre><p>Notice what’s gone: no library import, no new Date() footgun, no silent mutation, no timezone guessing.</p><p><strong>The practical impact:</strong> if your project uses date-fns or dayjs exclusively for date arithmetic (not formatting — Temporal handles that too via Intl), you can remove the dependency. For greenfield projects in Node 22+ or Chrome 144+, there is no longer a good reason to reach for a date library for most use cases.</p><p>One caveat worth stating plainly: Temporal is large. There are 6 core types (PlainDate, PlainTime, PlainDateTime, ZonedDateTime, Instant, Duration). The learning curve is real. But the alternative is continuing to use an API that Java abandoned before the first iPhone existed.</p><h3>2. using — Or: Why Do We Still Write try/finally Like It&#39;s 2003?</h3><p>Every language with serious resource management has a construct for this. Python has with. C# has using. Java has try-with-resources. Go has defer. Ruby has blocks.</p><p>JavaScript had try/finally. Which works, but punishes you for using it correctly:</p><pre>// The &quot;right&quot; way to manage a database connection before ES2026<br>let connection;<br>try {<br>  connection = await openConnection(config);<br>  const result = await connection.query(&quot;SELECT * FROM orders WHERE pending = true&quot;);<br>  return result;<br>} catch (err) {<br>  console.error(&quot;Query failed:&quot;, err);<br>  throw err;<br>} finally {<br>  if (connection) {         // don&#39;t forget this check<br>    await connection.close(); // don&#39;t forget this call<br>  }<br>}</pre><p>Now multiply that across file handles, event listeners, WebSocket connections, locks, timers. You’re spending cognitive overhead on cleanup that the language could handle automatically — and when you forget, the bug is silent. The connection stays open. Memory leaks. The database runs out of connections at 3am on a Tuesday.</p><p><strong>using makes cleanup automatic:</strong></p><pre>// ES2026<br>{<br>  await using connection = await openConnection(config);<br>  const result = await connection.query(&quot;SELECT * FROM orders WHERE pending = true&quot;);<br>  return result;<br>} // connection.close() is called here. Automatically. Even if an error was thrown.</pre><p>It works through Symbol.dispose (sync) and Symbol.asyncDispose (async). Your class opts in by implementing those methods — the language calls them when the variable goes out of scope. No finally. No if (resource) check. No leak.</p><p>Managing multiple resources? DisposableStack:</p><pre>{<br>  using stack = new DisposableStack();<br>  const file = stack.use(openFile(&quot;input.csv&quot;));<br>  const db   = stack.use(await openConnection(config));<br>  const lock = stack.use(acquireLock(&quot;import-job&quot;));<br>  // Do the work...<br>} // lock released → db closed → file closed. In reverse order. Automatically.</pre><p>TypeScript has supported this syntax since 5.2. Node.js and Chrome already ship it. If you’re writing server-side JavaScript that touches any external resource, this changes how you architect cleanup — in a good way.</p><h3>3. 0.1 + 0.2 = 0.30000000000000004. You Knew This. ES2026 Does Something About It.</h3><pre>console.log(0.1 + 0.2); // 0.30000000000000004</pre><p>This is the JavaScript meme that won’t die. And to be clear: Math.sumPrecise doesn&#39;t fix the fundamental representation problem. 0.1 and 0.2 still cannot be stored exactly in IEEE 754 floating-point, and two imprecise numbers added together will still give you an imprecise result.</p><p>What Math.sumPrecise actually fixes is <strong>error accumulation across many additions</strong> — which is the real problem in production code:</p><pre>// Approximating Euler&#39;s number (e) via power series<br>function* eulerTerms() {<br>  let term = 1;<br>  yield term;<br>  for (let i = 1; i &lt; 20; i++) {<br>    term /= i;<br>    yield term;<br>  }<br>}</pre><pre>const naive   = [...eulerTerms()].reduce((a, b) =&gt; a + b, 0);<br>const precise = Math.sumPrecise(eulerTerms());</pre><pre>console.log(naive);           // 2.7182818284590455<br>console.log(precise);         // 2.718281828459045<br>console.log(Math.E);          // 2.718281828459045</pre><pre>console.log(Math.abs(Math.E - naive));   // 4.44e-16  ← error<br>console.log(Math.abs(Math.E - precise)); // 0          ← exact</pre><p>The difference matters when you’re summing thousands of financial transactions and the rounding errors compound. If you’re building a tax calculator, a ledger, a statistics engine, or anything where small errors at scale become wrong answers — Math.sumPrecise gives you that precision natively, without reaching for decimal.js or big.js.</p><p>It accepts any iterable. Math.sumPrecise(values), Math.sumPrecise(generatorFn()), Math.sumPrecise(new Set([...])) — all valid.</p><h3>4. Error.isError() — Because instanceof Lies</h3><p>Here’s a bug that’s sitting in your codebase right now if you use iframes, Web Workers, or Node’s vm module:</p><pre>// An iframe has its own JavaScript realm — its own copy of every built-in<br>const iframe = document.createElement(&quot;iframe&quot;);<br>document.body.appendChild(iframe);<br>const err = new iframe.contentWindow.Error(&quot;Something went wrong&quot;);</pre><pre>console.log(err instanceof Error); // false</pre><p>The error was created with a different Error constructor than the one in your realm. instanceof checks the prototype chain, and the two Error constructors don&#39;t share one. So instanceof returns false even though you&#39;re looking at a perfectly real error.</p><p>Every error-handling utility, every logging library, every monitoring SDK that uses instanceof Error has this bug somewhere. Most of them handle it with workarounds like Object.prototype.toString.call(err) === &#39;[object Error]&#39;. Which works but is not exactly readable.</p><pre>// ES2026<br>Error.isError(new Error(&quot;real&quot;));            // true<br>Error.isError(new TypeError(&quot;also real&quot;));   // true<br>Error.isError({ message: &quot;fake error&quot; });    // false<br>Error.isError(&quot;a string&quot;);                   // false</pre><pre>// Works correctly across realms<br>Error.isError(new iframe.contentWindow.Error(&quot;cross-realm&quot;)); // true ✓</pre><p>It’s a small addition. But it’s one of those things where once you know the instanceof problem exists, you can&#39;t unsee it in every catch block you&#39;ve ever written.</p><h3>5. Native Base64 — Because btoa() Has Always Been Terrible</h3><p>btoa() and atob() have existed since forever and they are embarrassingly bad. btoa() takes a <em>string</em>, not bytes. Want to encode actual binary data? You have to convert your bytes to a string first, which requires a workaround that nobody remembers how to write from memory:</p><pre>// The old way — genuinely awful<br>const bytes = new Uint8Array([72, 101, 108, 108, 111]); // &quot;Hello&quot;<br>const base64 = btoa(String.fromCharCode(...bytes)); // &quot;SGVsbG8=&quot;</pre><p>String.fromCharCode(...bytes) — inside a btoa() call. For <em>encoding bytes</em>. In 2025. This was the state of the art.</p><pre>// ES2026<br>const bytes = new Uint8Array([72, 101, 108, 108, 111]);<br>bytes.toBase64(); // &quot;SGVsbG8=&quot;<br>bytes.toHex();    // &quot;48656c6c6f&quot;</pre><pre>// And back<br>Uint8Array.fromBase64(&quot;SGVsbG8=&quot;); // Uint8Array [72, 101, 108, 108, 111]<br>Uint8Array.fromHex(&quot;48656c6c6f&quot;); // same</pre><pre>// URL-safe variant (no + or / characters)<br>bytes.toBase64({ alphabet: &quot;base64url&quot; }); // &quot;SGVsbG8=&quot;</pre><p>Direct methods on Uint8Array. No string conversion dance. URL-safe variant built in. This will quietly eliminate a few lines of boilerplate from every project that handles file uploads, SSH keys, encryption output, or any binary protocol.</p><h3>6. Iterator.concat() — The Hole in ES2025&#39;s Iterator Helpers</h3><p>ES2025 shipped iterator helpers: .map(), .filter(), .take(), .drop(). They were a genuine improvement — lazy evaluation, no intermediate arrays, chainable. But there was an obvious missing piece: you couldn&#39;t concatenate two iterators without materializing them.</p><pre>// ES2025 — the workaround<br>function* concat(...iterables) {<br>  for (const it of iterables) yield* it;<br>}</pre><p>Every project that used iterator helpers had some version of that function sitting in a utils.js file. ES2026 closes the gap:</p><pre>const dbRecords = fetchFromDatabase();   // async iterator<br>const cached    = localCache.values();   // Map iterator<br>const defaults  = defaultValues();       // generator</pre><pre>const all = Iterator.concat(cached, dbRecords, defaults);</pre><pre>// Still fully lazy — nothing evaluated until you iterate<br>for (const record of all.filter(r =&gt; r.active).take(100)) {<br>  process(record);<br>}</pre><p>The important word is <em>lazy</em>. Iterator.concat doesn&#39;t pull all the values out and combine them. It sequences the iterators — finishing one before starting the next — which means you can concat a database cursor and a generator without loading either into memory.</p><h3>Wait — Is That Everything?</h3><p>No. And this is where most “ES2026 features” posts quietly sweep things under the rug.</p><p>The six features above are the ones with real architectural impact — the ones worth changing how you write code. But ES2026 shipped more than that, and a few of them deserve at least a mention.</p><p><strong>Map.prototype.getOrInsert()</strong> is one of those features you&#39;ll wonder why wasn&#39;t always there. The pattern of &quot;check if key exists, insert default if not, then get the value&quot; is everywhere:</p><pre>// Before — three operations, two lookups<br>if (!cache.has(userId)) {<br>  cache.set(userId, []);<br>}<br>cache.get(userId).push(event);</pre><pre>// ES2026 — one operation<br>cache.getOrInsert(userId, []).push(event);</pre><pre>// Need a computed default? getOrInsertComputed takes a factory function<br>cache.getOrInsertComputed(userId, () =&gt; buildDefaultProfile()).update(event);</pre><p>Works on WeakMap too. Perfect for caching, grouping, and memoization patterns.</p><p><strong>RegExp.escape()</strong> is the end of a very specific kind of bug — the one where user input containing . or * or ( silently turns your regex into something you didn&#39;t write:</p><pre>const userQuery = &quot;What is 2+2? (seriously)&quot;;</pre><pre>// Before — manual escaping, always incomplete, always forgotten<br>const safe = userQuery.replace(/[.*+?^${}()|[\]\\]/g, &#39;\\$&amp;&#39;);<br>new RegExp(safe);</pre><pre>// ES2026<br>new RegExp(RegExp.escape(userQuery));<br>// Properly escaped, every special character handled, built into the language</pre><p>Every search box, every user-input-driven filter, every dynamic regex in your codebase has this bug right now unless someone remembered to escape. RegExp.escape() makes the safe path the obvious path.</p><p><strong>JSON.parse with source text access</strong> is niche but important for anyone dealing with large integers. JSON doesn&#39;t have a BigInt type, so when you parse {&quot;id&quot;: 9007199254740993}, JavaScript silently corrupts the number — it can&#39;t represent it accurately in a 64-bit float:</p><pre>// Before — the ID gets silently corrupted<br>JSON.parse(&#39;{&quot;id&quot;: 9007199254740993}&#39;).id;<br>// → 9007199254740992  ← wrong, and you&#39;d never know</pre><pre>// ES2026 — reviver gets access to the original source string<br>JSON.parse(&#39;{&quot;id&quot;: 9007199254740993}&#39;, (key, value, context) =&gt; {<br>  if (key === &quot;id&quot;) return BigInt(context.source); // use the raw string<br>  return value;<br>});<br>// → 9007199254740993n  ← correct</pre><p>If your API returns large IDs, financial values, or timestamps as JSON numbers, this has been silently wrong. Now you can fix it without a custom JSON parser.</p><p><strong>Array.fromAsync()</strong> closes the same gap for async iterables that Array.from() closed for sync ones. Collecting the results of a paginated API, an async generator, or a stream into an array used to require a manual for await...of loop and a push:</p><pre>// Before<br>const results = [];<br>for await (const page of fetchPages()) {<br>  results.push(...page.items);<br>}</pre><pre>// ES2026<br>const results = await Array.fromAsync(fetchPages());</pre><pre>// With a mapping function<br>const titles = await Array.fromAsync(fetchPages(), page =&gt; page.title.toUpperCase());</pre><p>Small ergonomic win. You’ll reach for it more than you expect.</p><h3>The Spec vs. Reality Gap — An Honest Note</h3><p>There’s genuine disagreement across sources about which features are <em>officially</em> in ES2026 versus “implemented in browsers and effectively available.” This matters.</p><p>Some sources note that Temporal and using/await using reached Stage 4 in March 2026, making them slated for ES2027 — not ES2026. Other sources, including the TC39 spec editor&#39;s changelog, include them in the ES2026 listing.</p><p>The practical answer: it doesn’t matter that much. If something is at Stage 4 and shipping in Chrome, Firefox, and Node, it’s available to you today. The spec year is a bureaucratic label, not a deployment gate. Use the compatibility table, not the year stamp, when deciding whether to reach for something.</p><h3>Browser and Runtime Support — The Actual Picture</h3><p>Feature Chrome Firefox Safari Node Temporal 144+ Full Tech Preview 22+ (flag) using / await using 130+ Flag 18.2+ 22+ Math.sumPrecise 137+ 136+ 18.4+ 22+ Error.isError() 135+ 134+ 18.4+ 24+ Uint8Array.toBase64() 132+ 132+ 17.4+ 22+ Iterator.concat() 132+ 133+ 18.2+ 22+ Map.getOrInsert() 131+ 132+ 17.4+ 22+ RegExp.escape() 136+ 134+ 18.4+ 24+ JSON.parse source 134+ 132+ 17.4+ 22+ Array.fromAsync() 121+ 115+ 16.4+ 22+</p><p>For Node.js server-side work, most of this is usable today without polyfills. For browser code targeting modern evergreen browsers, you’re largely covered. Temporal is the one outlier — Safari is still in Technical Preview as of June 2026.</p><h3>What This Actually Means for Your Codebase</h3><p>Stop installing moment, date-fns, or dayjs in new projects. Temporal is here and it&#39;s better than all of them, particularly for timezone-aware work.</p><p>Audit your try/finally resource cleanup. Every file handle, database connection, or lock that gets released in a finally block is a candidate for using. Start with the ones that are most error-prone — the ones where forgetting the cleanup has caused a bug before.</p><p>Don’t throw out your decimal.js for existing financial code. Math.sumPrecise is for summation precision, not arbitrary-precision arithmetic. Know the difference.</p><p>Update your error-handling utilities to use Error.isError() if you touch iframes or Workers. It&#39;s a one-line fix that closes a real correctness bug.</p><p>Replace every dynamic new RegExp(userInput) in your codebase with new RegExp(RegExp.escape(userInput)). That&#39;s not an upgrade — that&#39;s a bug fix you should have shipped years ago.</p><p>ES2026 won’t make you a better programmer. But it removes a class of decisions you should never have had to make — “which date library,” “how do I safely encode bytes,” “how do I remember to clean up this resource,” “how do I escape this user input for a regex” — and that’s worth something. That’s what a mature language is supposed to do.</p><p><em>All features verified against the TC39 finished proposals list, the ECMAScript 2027 specification changelog (which documents ES2026 additions), and cross-referenced with MDN and caniuse. Browser support figures are as of June 2026.</em></p><p>Cheers !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=826a4713b486" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Next.js 16.3 Makes Server Apps Feel Like SPAs — and It’s Kind of a Big Deal]]></title>
            <link>https://medium.com/@islamhafez0/next-js-16-3-makes-server-apps-feel-like-spas-and-its-kind-of-a-big-deal-86543c16e021?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/86543c16e021</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 13:32:47 GMT</pubDate>
            <atom:updated>2026-06-27T13:51:22.347Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_9I_cM8mD0SRbkduoF7dg.png" /><figcaption>Next.js Instant Naigations by Islam Hafez</figcaption></figure><h3>Instant Navigations is the feature Next.js developers have been asking for since the Server Components era began. Here’s exactly what changed, and why it matters.</h3><p>There’s a criticism that has followed Next.js like a shadow ever since the App Router shipped with React Server Components: <strong>navigating between pages feels slow.</strong></p><p>You click a link. Nothing happens. Then — after a round-trip to the server — the next page appears.</p><p>For content sites, that’s fine. For apps that need to feel alive and responsive, it has been a real problem. One that’s pushed many developers back toward pure client-side SPAs, even when they didn’t want to give up everything a server offers.</p><p>Next.js 16.3 ships a direct answer to this. The team is calling it <strong>Instant Navigations</strong> — a suite of tools that closes the gap between the snappy feel of client-driven SPAs and the architectural advantages of server-driven apps.</p><blockquote>“You get the full benefits of a server, but navigations are instant — like in a single-page app.”<em> — Next.js team</em></blockquote><h3>The Problem in Plain Terms</h3><p>When you navigate in a typical server-driven Next.js app, two things need to happen before you see the next page:</p><ol><li>The client reaches the server across the network</li><li>The server finishes generating a response</li></ol><p>Both take time. The result is a navigation that <em>“feels like a website”</em> — not an app.</p><p>Compare that to a single-page app. When you click a link in a well-built SPA:</p><ol><li>You click</li><li><strong>Instantly</strong> — a shell of the next page appears (some data still loading)</li><li>The server responds, and the full page reveals</li></ol><p>The key insight the Next.js team landed on: you don’t need to close <em>both</em> gaps at once. If you can eliminate the server-generation delay, the remaining network latency becomes far more manageable — especially with smarter prefetching.</p><h3>Stream, Cache, or Block — You Decide</h3><p>To unlock the new behaviors, you first opt in via a single config flag:</p><pre>// next.config.ts<br>const nextConfig = {<br>  cacheComponents: true,<br>};</pre><p>Once that’s on, any route that awaits data on the server surfaces a choice in the new <strong>Instant Insights</strong> panel inside your dev tools. Three paths, clearly labeled:</p><p><strong>Stream</strong> — Wrap the slow part in a &lt;Suspense&gt; boundary. The user instantly sees a loading skeleton. The navigation is already done; content streams in behind it.</p><p><strong>Cache</strong> — Use the &#39;use cache&#39; directive. The user sees previously cached UI immediately. No loading state. No wait. For most routes, this will be the cleanest option.</p><p><strong>Block</strong> — The deliberate opt-out. If an empty shell would be worse than just waiting — say, an article page where a half-loaded layout is confusing — you export a single line:</p><pre>// page.tsx<br>export const instant = false;</pre><p>What makes this elegant is the constraint it imposes. Slow routes become <em>errors</em> in development. You’re not allowed to silently ship a sluggish experience — you have to make an explicit choice about every route. That’s a meaningful shift in accountability.</p><h3>Partial Prefetching: Stealing the Best Trick from SPAs</h3><p>Even with Streaming and Caching handling server-generation time, there’s still the network gap between the client and the server. Before a user clicks, Next.js needs to close that gap too.</p><p>The old solution was aggressive: fire a prefetch request for every link in the viewport. Scroll down a page with a sidebar of 20 chat links? That’s 20 separate network requests. Developers noticed. It looked ridiculous in the Network tab, and frankly, the team admitted as much.</p><p>The new approach — <strong>Partial Prefetching</strong> — takes inspiration from how SPAs handle code-splitting. Instead of prefetching per-link, Next.js now prefetches a reusable <em>shell</em> per-route, cached client-side for the entire session.</p><ul><li>20 sidebar links to /chat/[id]? → <strong>One prefetch.</strong> One shell. Reused for all 20.</li><li>Links to /dashboard and /settings? → <strong>Two prefetches.</strong> One per distinct route.</li></ul><p>Enable it alongside Cache Components:</p><pre>// next.config.ts<br>const nextConfig = {<br>  cacheComponents: true,<br>  partialPrefetching: true,<br>};</pre><p>When you need to go deeper — prefetching actual content for a specific high-value link, not just its shell — you can opt in selectively:</p><pre>&lt;Link prefetch={true}&gt;View Profile&lt;/Link&gt;</pre><p>And if you don’t mind extra server load, you can extend prefetching to runtime-cached content:</p><pre>export const prefetch = &#39;allow-runtime&#39;;</pre><p>You’re no longer forced into an all-or-nothing decision. The shell is the baseline guarantee; everything beyond that is a deliberate upgrade.</p><h3>The Tooling Is Just as Important</h3><p>This release doesn’t just change runtime behavior — it ships a meaningful upgrade to the developer experience around navigations.</p><p><strong>Instant Insights Panel</strong> — A new overlay in dev tools that automatically flags routes where navigations aren’t instant. Think of it as a linter for navigation speed. It points you exactly at the await that&#39;s causing the delay and presents your three options.</p><p><strong>Navigation Inspector</strong> — Lets you pause any navigation at the shell during development, visually inspect what got prefetched, and then resume to see the completed page. If you’ve ever wondered “what does my user <em>actually</em> see the moment they click?”, this answers it directly and visually.</p><p><strong>instant() test helper for Playwright</strong> — Arguably the most practical addition for teams with CI pipelines. It lets you assert what&#39;s visible <em>before</em> the server responds:</p><pre>import { instant } from &#39;@next/playwright&#39;;</pre><pre>test(&#39;product title is available immediately&#39;, async ({ page }) =&gt; {<br>  await page.goto(&#39;/products/shoes&#39;);</pre><pre>  // These assertions run BEFORE the network responds<br>  await instant(page, async () =&gt; {<br>    await page.click(&#39;a[href=&quot;/products/hats&quot;]&#39;);<br>    await expect(page.locator(&#39;h1&#39;)).toContainText(&#39;Baseball Cap&#39;);<br>    await expect(page.getByText(&#39;Checking inventory...&#39;)).toBeVisible();<br>  });</pre><pre>  // This one waits for the full response<br>  await expect(page.getByText(&#39;12 in stock&#39;)).toBeVisible();<br>});</pre><p>The team is also exploring surfacing these errors at <em>build time</em>, so regressions in instant routes get caught before they ever reach production.</p><h3>Does It Actually Work? Real Numbers from v0</h3><p>The Next.js team didn’t ship this in theory alone — they applied it to <a href="https://v0.app/">v0.app</a>, Vercel’s own AI interface, which has a rich client experience and had been struggling with navigation latency for a while.</p><p>Instant Insights surfaced the slow routes. The team worked through fixes. Navigation times dropped dramatically — from hundreds of milliseconds toward near-zero in most cases. A follow-up post with the specific patterns they used is coming.</p><p>If you want a self-contained open-source example to explore, <a href="https://next-beats.dev/">Next Beats</a> is a music player built on the 16.3 Preview. Cache Components is on, every route uses Stream or Cache, and Partial Prefetching is enabled. It’s the cleanest reference implementation available right now.</p><h3>Quick Reference</h3><p>What you want How to do it Instant navigation via streaming Wrap slow parts in &lt;Suspense&gt; Instant navigation via caching Add &#39;use cache&#39; directive Opt a route out of instant export const instant = false Enable Partial Prefetching partialPrefetching: true in config Deeper per-link prefetch &lt;Link prefetch={true}&gt; Allow runtime content prefetch export const prefetch = &#39;allow-runtime&#39; Test instant regressions instant() helper for Playwright</p><h3>The Bottom Line</h3><p>The tension between “SPA feel” and “server architecture” has defined a lot of frontend debates for the past few years. Developers have felt forced to choose — either take the DX and performance benefits of the server model, or give your users the snappy experience they expect from modern apps.</p><p>Next.js 16.3 doesn’t resolve that debate, but it does meaningfully shrink the experiential gap. If your users are clicking links and wondering why nothing is happening, this update was written for you.</p><p>Both cacheComponents and partialPrefetching are behind opt-in flags for now — but the team has been explicit: these are the future defaults. Getting ahead of them today is the right call.</p><pre>npm install next@preview</pre><p>Give the <a href="https://preview.nextjs.org/docs/app/guides/instant-navigation">preview docs for Instant Navigations</a> a read, then check the <a href="https://github.com/vercel/next.js/discussions/95130">GitHub Discussion</a> to share feedback with the team.</p><p><em>The stable release of Next.js 16.3 is still in progress. Known issues include some blocking routes not being reported as Instant Insights when Partial Prefetching is on, and tooling quirks in Safari — use Chrome or Firefox in development for best results.</em></p><p><strong>Tags:</strong> Next.js · React · Web Performance · JavaScript · Frontend Development</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86543c16e021" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Arrays and Stacks: Two Data Structures That Will Rewire Your Brain]]></title>
            <link>https://medium.com/@islamhafez0/arrays-and-stacks-two-data-structures-that-will-rewire-your-brain-7eaf668dd6a3?source=rss-e1fdebe6da8e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7eaf668dd6a3</guid>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[stack]]></category>
            <category><![CDATA[lifo]]></category>
            <category><![CDATA[arrays]]></category>
            <dc:creator><![CDATA[Islam Hafez]]></dc:creator>
            <pubDate>Thu, 25 Jun 2026 23:43:52 GMT</pubDate>
            <atom:updated>2026-06-25T23:50:27.013Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7qqdthbZbR2VubByCsXKYw.png" /><figcaption>Arrays and Stacks by Islam Hafez</figcaption></figure><p>You probably think arrays are simple. You’re right.<br>You also think you understand them. You’re wrong.</p><p>Most beginners treat data structures like vocabulary lists — memorize the definition, pass the interview, never think about it again. That’s like learning the word <em>“ignite”</em> but never realizing it describes everything from a matchstick to a rocket engine.</p><p>Arrays and stacks aren’t definitions. They’re <strong>lenses</strong>.</p><p>Once you see through them, you stop writing code and start designing systems.</p><p>Let’s rewire that beginner brain of yours.</p><h3>Arrays: The Simplest Thing That Isn’t Simple</h3><h3>What your textbook told you</h3><blockquote><em>“An array is a contiguous block of memory that stores elements of the same type, accessed by index.”</em></blockquote><p>Technically correct. Practically useless.</p><h3>What’s actually happening</h3><p>You declare:</p><pre>int scores[5];</pre><p>Behind the scenes, the computer says:<br>“I need room for 5 integers” — and carves out one uninterrupted slab of memory (about 20 bytes).</p><p>Let’s say that block starts at address 1000.</p><p>When you access:</p><pre>scores[3]</pre><p>The computer does:</p><pre>1000 + (3 * 4) = 1012</pre><p>That’s it.<br>One multiplication. One addition.</p><p>That’s why array access is <strong>O(1)</strong> — not because it’s “optimized,” but because it’s <em>trivial math</em>.</p><p>The index <strong>is the path</strong>.</p><h3>The trap</h3><p>Arrays feel like they have no rules.</p><p>They don’t.<br>They have <strong>physics</strong>.</p><p><strong>Insertion at the end?</strong><br>O(1) — until the array is full. Then everything gets copied to a new block.</p><p>That “amortized O(1)” you keep hearing about?<br>It hides the fact that one operation can suddenly cost <strong>O(n)</strong>.</p><p><strong>Insertion at the beginning?</strong><br>O(n). Always.</p><p>Insert at index 0 in a million-element array?<br>You move a million elements. No shortcuts.</p><p><strong>Deletion?</strong><br>Same problem. Remove one element, and everything shifts.</p><h3>When arrays shine</h3><ul><li>You know the size ahead of time</li><li>You mostly read, rarely modify</li><li>You care about <strong>cache locality</strong> (CPU loves contiguous memory)</li><li>You need raw speed</li></ul><h3>When arrays fail you</h3><ul><li>Size is unpredictable</li><li>You insert/delete frequently</li><li>You need structure and constraints</li></ul><p>Which brings us to stacks.</p><h3>Stacks: Arrays With Manners</h3><h3>What your textbook told you</h3><blockquote><em>“A stack is a LIFO (Last In, First Out) data structure with push and pop operations.”</em></blockquote><p>Again, correct. Again, useless.</p><h3>What’s actually happening</h3><p>A stack is just an array with <strong>rules</strong>.</p><p>It has a pointer called top, and that’s the only place you’re allowed to touch.</p><ul><li>push → add to the top</li><li>pop → remove from the top</li><li>peek → look at the top</li></ul><p>That’s it.</p><h3>Why the restriction is the point</h3><p>Beginners see limitations.<br>Engineers see guarantees.</p><p>Because access is restricted, you get:</p><ul><li>The last item added is <strong>always</strong> the first removed</li><li>No accidental corruption of the middle</li><li>Operations that are always <strong>O(1)</strong></li></ul><p>No surprises. No hidden costs.</p><h3>Why stacks are everywhere</h3><p><strong>Undo systems</strong><br>Every action is pushed. Undo pops it.</p><p><strong>Function calls</strong><br>Each call goes on the stack. Return pops it.<br>That’s how recursion works.</p><p><strong>Parsing</strong><br>Brackets, HTML, expressions — all rely on LIFO behavior.</p><h3>The constraint</h3><p>Stacks are rigid.</p><ul><li>You can’t search without destroying it</li><li>You can’t access the middle</li><li>You can’t skip order</li></ul><p>If your problem isn’t LIFO, a stack isn’t just bad — it’s wrong.</p><h3>Arrays vs. Stacks: The Comparison That Matters</h3><p>Forget comparison tables. They’re misleading.</p><p>Here’s the truth:</p><blockquote><strong><em>An array is a tool. A stack is a policy.</em></strong></blockquote><ul><li>Arrays → raw power, no discipline</li><li>Stacks → strict discipline, limited flexibility</li></ul><p>You can build a stack using an array.<br>You cannot turn a stack into a full array.</p><p>Why use a stack?</p><p>Because it <strong>prevents misuse</strong>.</p><p>You’re not just storing data — <br>you’re enforcing <em>correct behavior</em>.</p><p>That’s engineering.</p><h3>The Bigger Lesson</h3><p>You didn’t just learn arrays and stacks.</p><p>You learned this:</p><blockquote><strong><em>Every data structure is a contract between you and memory.</em></strong></blockquote><p>StructureYou give upYou getArrayDynamic sizing, cheap insertsFast random access, cache localityStackRandom access, flexibilityLIFO guarantee, O(1) operations</p><p>Every system works like this.</p><ul><li>Monoliths → simple, not scalable</li><li>Microservices → scalable, complex</li><li>SQL → consistent, rigid</li><li>NoSQL → flexible, less strict</li></ul><p>There are no perfect tools.</p><p>Only trade-offs you understand — and ones you don’t.</p><h3>What To Learn Next</h3><p>If this clicked, keep going:</p><ol><li><strong>Linked Lists</strong> — fast inserts, slow access</li><li><strong>Queues</strong> — FIFO instead of LIFO</li><li><strong>Hash Tables</strong> — real power begins here</li><li><strong>Trees &amp; Graphs</strong> — modeling real-world relationships</li></ol><p>Before you move on, do this:</p><p>Look at your last piece of code and ask:</p><ul><li>What data structure did I use?</li><li>What did it cost me?</li><li>What would happen if I used another one?</li></ul><p>If you can’t answer those, you didn’t choose.</p><p>You just typed.</p><p>Start engineering.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7eaf668dd6a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>