<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Doogal Simpson</title>
    <description>The latest articles on DEV Community by Doogal Simpson (@doogal).</description>
    <link>https://dev.to/doogal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3657111%2Fac69c96a-33e1-4023-99ef-ee3059b3ccb6.jpeg</url>
      <title>DEV Community: Doogal Simpson</title>
      <link>https://dev.to/doogal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/doogal"/>
    <language>en</language>
    <item>
      <title>Count-Min Sketch Explained: Trillions of Counters</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Wed, 10 Jun 2026 15:38:27 +0000</pubDate>
      <link>https://dev.to/doogal/count-min-sketch-explained-trillions-of-counters-342</link>
      <guid>https://dev.to/doogal/count-min-sketch-explained-trillions-of-counters-342</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: A Count-Min Sketch is a probabilistic data structure used to estimate the frequency of events in massive datasets. By running items through multiple hash functions and storing counts in fixed-size arrays, it compresses trillions of counters into kilobytes of memory. It guarantees no underestimations but allows slight overestimations due to hash collisions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If there is one thing I constantly think about when designing high-volume systems, it is how quickly memory gets devoured. Let's say your team is building an analytics engine for an ad network. You need to answer a seemingly basic question: How many times has each user seen each ad? If you have 2 billion users and 10 million ads, you are staring down 20 trillion unique counters. Storing that in a standard database table or hash map will eat up terabytes of RAM. &lt;/p&gt;

&lt;p&gt;But what if I told you that you could store that exact same frequency data in just 16 kilobytes of memory? That is exactly what a Count-Min Sketch allows us to do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use a Count-Min Sketch instead of a hash map?
&lt;/h2&gt;

&lt;p&gt;A hash map requires memory that scales linearly with the number of unique items, which becomes impossibly expensive at massive scale. A Count-Min Sketch uses a fixed amount of memory by trading exact precision for highly accurate estimates.&lt;/p&gt;

&lt;p&gt;When I look at our ad network scenario, allocating even a tiny 4-byte integer for 20 trillion counters demands massive memory overhead. A Count-Min Sketch avoids this by acting as a bounded probability structure. It does not store the keys (the user-ad pairs) at all. Instead, it relies on hashing to map an infinite stream of events into a strictly bounded memory footprint.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does a Count-Min Sketch algorithm actually work?
&lt;/h2&gt;

&lt;p&gt;It uses a matrix of independent arrays and corresponding hash functions to generate a unique footprint for every item. When an item is processed, it is hashed multiple times to increment specific counters across the arrays.&lt;/p&gt;

&lt;p&gt;The results from these hash functions act as a unique fingerprint for your item across the arrays. &lt;/p&gt;

&lt;p&gt;Here is exactly how I break down the mechanics of inserting an item into a Count-Min Sketch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Structure:&lt;/strong&gt; Initialize four separate arrays, each containing 1,024 empty integer counters.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Hash Functions:&lt;/strong&gt; Assign a unique, independent hash function to each of the four arrays.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Hashing:&lt;/strong&gt; Take your incoming item (like a user ID combined with an ad ID) and run it through all four hash functions.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Update:&lt;/strong&gt; Each hash function outputs a specific index for its assigned array. Go to that index in each array and increment the counter by one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How do you read the frequency count from a Count-Min Sketch?
&lt;/h2&gt;

&lt;p&gt;To retrieve a count, you hash the item again using the same functions, look up the values in each array, and return the lowest number. Because hash collisions only ever inflate numbers, the minimum value is the most accurate estimate.&lt;/p&gt;

&lt;p&gt;When you want to query the count, you take your item and run it through the exact same four hash functions. This gives you the fingerprint of your four array locations, returning four different numbers. &lt;/p&gt;

&lt;p&gt;Because multiple different items might hash to the same index (a collision), some counters will be artificially high. But a counter can never be lower than the true frequency of your item. Therefore, returning the minimum value across your arrays filters out the noise from collisions. You get a mathematical guarantee that you are never going to have an underestimate.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the accuracy of a Count-Min Sketch?
&lt;/h2&gt;

&lt;p&gt;A Count-Min Sketch is highly accurate, often exceeding 99% accuracy depending on the configured width and depth. You can predictably increase accuracy by adding more arrays and hash functions.&lt;/p&gt;

&lt;p&gt;The only error you will encounter is an overestimate caused by hash collisions. However, the math works out in your favor remarkably fast. With just four arrays of 1,024 elements, the error rate is incredibly small. If you scale this up to just eight arrays and eight hash functions, the difference between your estimate and the actual real count hits 99.9% accuracy. I find it crazy that this structure is capable of storing trillions and trillions of counters in a footprint so small it can literally fit in a CPU cache.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What happens when a Count-Min Sketch gets full?
&lt;/h3&gt;

&lt;p&gt;It never technically gets "full" because it has a fixed size in memory. However, as you add a massive volume of items, the arrays become saturated. This increases the likelihood of hash collisions, which eventually reduces the accuracy of your estimates by artificially inflating the counts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can you delete an item from a Count-Min Sketch?
&lt;/h3&gt;

&lt;p&gt;Generally, no. Because multiple items share the same counters due to hash collisions, decrementing a counter for one item would likely corrupt the counts of other completely unrelated items that happen to hash to that same bucket.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the difference between a Count-Min Sketch and a Bloom Filter?
&lt;/h3&gt;

&lt;p&gt;A Bloom Filter is a probabilistic data structure used to check if an item exists in a set (returning a boolean true or false). A Count-Min Sketch is used to estimate how many times an item has appeared in a stream (returning an integer frequency count).&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>algorithms</category>
      <category>systemdesign</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Apple Secure Enclave: Face ID Security Explained</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Wed, 10 Jun 2026 15:38:05 +0000</pubDate>
      <link>https://dev.to/doogal/apple-secure-enclave-face-id-security-explained-5gk</link>
      <guid>https://dev.to/doogal/apple-secure-enclave-face-id-security-explained-5gk</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: No, neither Apple nor the government can read your Face ID data. Your biometrics are processed entirely on-device within the Secure Enclave—a physically isolated subsystem with its own CPU and memory. The main processor never sees the raw data; it only receives a simple "yes" or "no" match confirmation.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As a software engineer, I am naturally skeptical when a massive tech company asks us to scan our faces to unlock our devices. The immediate architectural question is always: where does that data go, and who holds the database keys? The short answer is that there is no biometric database in the cloud. The way modern iPhones handle Face ID is actually an elegant lesson in hardware-level security and threat modeling. Let's break down exactly how this system is designed to ensure nobody—not even the engineers who built it—can access your raw biometric data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Apple Secure Enclave and how does it isolate data?
&lt;/h2&gt;

&lt;p&gt;The Secure Enclave is a dedicated, tiny computer sitting inside the main system-on-chip of your iPhone. It operates with its own completely separate CPU, memory, and a stripped-down operating system that is entirely independent of iOS.&lt;/p&gt;

&lt;p&gt;Think of your iPhone as a massive corporate office building. The main CPU and iOS handle everything from the public lobby traffic to the cafeteria logistics. The Secure Enclave, however, is a windowless, bank-vault room in the basement. It has its own power lines, its own security guard, and it explicitly does not trust anyone else in the building. Its sole responsibility is processing highly sensitive cryptographic operations. Because its memory is physically separated and heavily encrypted away from the main system architecture, an exploit in iOS does not automatically grant an attacker access to the enclave.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does the iPhone process Face ID sensor data securely?
&lt;/h2&gt;

&lt;p&gt;When you look at your phone, the camera module captures and immediately encrypts the biometric sensor data before passing it to the main CPU. The main CPU cannot read this data; it blindly routes the encrypted package to the Secure Enclave, which then decrypts it, checks for a match, and returns a simple boolean result.&lt;/p&gt;

&lt;p&gt;To make this highly digestible, here is the exact lifecycle of a Face ID authentication request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Capture&lt;/strong&gt;: The TrueDepth camera reads your facial geometry and creates a map.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Hardware Encryption&lt;/strong&gt;: The camera hardware encrypts this raw sensor data on the spot.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Blind Routing&lt;/strong&gt;: The encrypted package is handed to the main CPU (which lacks the decryption keys).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Decryption &amp;amp; Processing&lt;/strong&gt;: The Secure Enclave receives the package, decrypts it safely inside its isolated memory, and compares it against the stored mathematical model of your face.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Resolution&lt;/strong&gt;: The Secure Enclave passes a &lt;code&gt;true&lt;/code&gt; (match) or &lt;code&gt;false&lt;/code&gt; (no match) back to the main CPU to unlock the device.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From a software perspective, the main CPU is essentially calling an asynchronous, black-box function that only ever returns a boolean. The main thread never has access to the underlying variables or state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why did Apple architect Face ID to be completely inaccessible?
&lt;/h2&gt;

&lt;p&gt;Apple built the Secure Enclave this way to intentionally eliminate their own ability to access user biometrics. By making it architecturally impossible to retrieve the data, they protect themselves from being legally compelled to hand it over to governments or law enforcement.&lt;/p&gt;

&lt;p&gt;In system design, we frequently talk about the principle of least privilege. Apple took this to the absolute extreme: zero privilege. If they had built a backdoor or a software hook to extract Face ID data for debugging, that exact same mechanism could be targeted by a legal subpoena. By deliberately throwing away the keys and keeping all processing strictly localized to a secure hardware component on the user's physical device, they avoid the situation entirely. When pressed by outside authorities, they can honestly respond that they simply do not possess the technical capability to fulfill the request.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does Face ID data get backed up to iCloud?
&lt;/h3&gt;

&lt;p&gt;No. Face ID mathematical models never leave your physical device. They are never synced to iCloud, sent to Apple's servers, or even transferred over when you migrate your data to a new iPhone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a software update modify the Secure Enclave to expose data?
&lt;/h3&gt;

&lt;p&gt;The Secure Enclave runs its own bare-bones operating system that strictly limits its operational capabilities. While Apple can issue firmware updates to the enclave, its fundamental hardware architecture is designed to prevent it from ever exporting raw biometric data back to the main CPU.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens to Face ID data if I wipe my iPhone?
&lt;/h3&gt;

&lt;p&gt;When you erase all content and settings on your device, the cryptographic keys stored inside the Secure Enclave are securely and permanently destroyed. This instantly renders any existing biometric models or encrypted device data permanently unreadable.&lt;/p&gt;

</description>
      <category>security</category>
      <category>softwareengineering</category>
      <category>systemarchitecture</category>
      <category>iosdevelopment</category>
    </item>
    <item>
      <title>How Face ID Adapts to Beards and Facial Changes</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Wed, 10 Jun 2026 15:37:52 +0000</pubDate>
      <link>https://dev.to/doogal/how-face-id-adapts-to-beards-and-facial-changes-2n4j</link>
      <guid>https://dev.to/doogal/how-face-id-adapts-to-beards-and-facial-changes-2n4j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: Apple's Face ID doesn't rely on a single, static image. Instead, it stores a high-precision mathematical map of your facial geometry that continuously updates. Every successful unlock merges slight physical variations into your stored profile. For sudden, dramatic changes—like shaving a full beard—it falls back to your passcode to securely verify and register your new geometry.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I always find it fascinating how authentication systems handle edge cases. Have you ever wondered why Face ID doesn't suddenly lock you out just because you've aged a few years, gained a bit of weight, or decided to grow a beard? &lt;/p&gt;

&lt;p&gt;As engineers, I think we can all appreciate how brittle static comparisons can be. If a security system expects byte-for-byte perfection, even a slight shift in environmental variables causes a failure. Face ID sidesteps this by treating your face not as a hardcoded static asset, but as a living, continuously updating dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does Face ID Handle Gradual Facial Changes?
&lt;/h2&gt;

&lt;p&gt;Face ID handles gradual changes by continuously merging new, successful scans into your existing biometric profile. Instead of a static check, every unlock acts as a micro-update to the mathematical model of your face.&lt;/p&gt;

&lt;p&gt;Think of it like calculating a moving average in a time-series database. Face ID maps the geometry of your face down to the millimeter. When you attempt to unlock your phone, the system compares the current depth-map against its baseline. If the contours match within an acceptable threshold of confidence, the phone unlocks. But the operation doesn't stop at a simple boolean true or false.&lt;/p&gt;

&lt;p&gt;The system takes the delta—the slight millimeter changes from your new stubble or weight shift—and merges it with the baseline data. Because this happens dozens of times a day, the model drifts perfectly in sync with your actual physical appearance.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Happens to Face ID When You Shave a Beard?
&lt;/h2&gt;

&lt;p&gt;When you drastically alter your appearance, Face ID detects a partial match but fails the overall confidence threshold, prompting a passcode fallback. Entering the correct passcode provides the secondary authorization needed to overwrite the biometric mismatch and register your new face shape.&lt;/p&gt;

&lt;p&gt;Sudden transformations break that moving average we just talked about. Let's say you shave off a massive beard. The system scans your face and recognizes the unchanged data clusters—your forehead, your eye spacing, the bridge of your nose. However, the lower half of the geometry is completely foreign. Because the delta is too large, the system rejects the biometric authentication.&lt;/p&gt;

&lt;p&gt;To bridge this gap, the software pivots to a fallback mechanism. Let's say you are building a fintech app. If a user suddenly logs in from a completely new IP address on an unrecognized device, you don't instantly lock their account; you ask for a two-factor authentication code. Face ID operates on the exact same logic. By entering your passcode, you provide deterministic proof of identity. The system then takes that heavily modified facial scan, attaches it to the secure passcode validation, and drastically updates your baseline model so you can seamlessly unlock your phone the next time.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does the Algorithm Respond to Different Severity Levels?
&lt;/h2&gt;

&lt;p&gt;The Face ID algorithm classifies geometric variations into minor, gradual, and drastic changes based on match confidence thresholds. Minor or gradual shifts are handled invisibly by merging the new data, while drastic deviations trigger a hard security gate. Here is a quick breakdown of how the system resolves these varying scenarios:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Change Severity&lt;/th&gt;
&lt;th&gt;Example Scenario&lt;/th&gt;
&lt;th&gt;Biometric Match Confidence&lt;/th&gt;
&lt;th&gt;System Resolution&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Minor&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Morning puffiness, 1-day stubble&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;Unlocks immediately and silently updates the mathematical model.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Gradual&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Growing a beard over a few months&lt;/td&gt;
&lt;td&gt;High (maintained by daily updates)&lt;/td&gt;
&lt;td&gt;Unlocks immediately and incrementally shifts the baseline.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Drastic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Shaving a long beard, heavy bandages&lt;/td&gt;
&lt;td&gt;Partial / Low&lt;/td&gt;
&lt;td&gt;Rejects biometrics, prompts for passcode, then drastically updates model upon passcode success.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does Face ID store photos of my face?
&lt;/h3&gt;

&lt;p&gt;Face ID does not store actual photographs of your face. It stores a mathematical representation of your facial depth map locally on the device's Secure Enclave, which cannot be reverse-engineered into an image file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does Face ID sometimes require my passcode randomly?
&lt;/h3&gt;

&lt;p&gt;Aside from drastic facial changes, iOS imposes strict time and failure-based limits to ensure the overall integrity of the device. For instance, the system will force a passcode fallback if the phone hasn't been unlocked in over 48 hours or has recently rebooted. It will also lock down and demand a PIN if it detects five consecutive unsuccessful biometric match attempts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Face ID learn two completely different faces?
&lt;/h3&gt;

&lt;p&gt;Yes, you can manually set up an "Alternate Appearance" in the iOS settings. This allows the system to maintain a secondary baseline model, which is highly useful if you regularly wear heavy, face-obscuring safety gear for work.&lt;/p&gt;

</description>
      <category>faceid</category>
      <category>biometrics</category>
      <category>algorithms</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Optimize Your Codebase for AI Coding Agents</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Mon, 08 Jun 2026 14:02:21 +0000</pubDate>
      <link>https://dev.to/doogal/optimize-your-codebase-for-ai-coding-agents-1ccj</link>
      <guid>https://dev.to/doogal/optimize-your-codebase-for-ai-coding-agents-1ccj</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR: Quick Answer&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;If your codebase doesn't contain the exact nouns and verbs you use to prompt your AI coding agent, the agent will do a much worse job. By ensuring your code reflects your spoken domain language, agents can map instructions directly to components, preventing them from generating messy, monolithic scripts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're using a coding agent and your codebase does not contain the nouns and the verbs that you use to prompt the agent with, your agent will do a worse job. Period. I see this happen all the time. What do I mean by this? Let's say you're building a system that sells t-shirts online. You've got a bit where you have to take payment by calling a payment processor, a bit to update an order in a database, and a bit to send a message to a warehouse to ship the item.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why do AI coding agents write monolithic scripts instead of modular code?
&lt;/h2&gt;

&lt;p&gt;AI agents write monolithic scripts because they lack clear semantic hooks in your existing codebase. If your code doesn't explicitly define the business concepts you are prompting for, the agent defaults to a procedural list of database updates and API calls to satisfy the request.&lt;/p&gt;

&lt;p&gt;As I'm describing that t-shirt store flow above, there are some clear nouns in there: &lt;em&gt;order&lt;/em&gt;, &lt;em&gt;payment processor&lt;/em&gt;, &lt;em&gt;warehouse&lt;/em&gt;. There are also some verbs: &lt;em&gt;take payment&lt;/em&gt;, &lt;em&gt;create order&lt;/em&gt;, &lt;em&gt;send message&lt;/em&gt;. I want to stress that you want all of these things to exist in your codebase as named verbs and nouns. If you just prompt an agent to build the system for you without any of that semantic structure already in place, you'll just get a long script. The AI will just make a raw API call, create a row in a database, and send a message all in one file. You won't have any of these concepts properly modeled.&lt;/p&gt;
&lt;h2&gt;
  
  
  How do nouns and verbs improve AI coding agent accuracy?
&lt;/h2&gt;

&lt;p&gt;Explicit nouns and verbs allow the agent to map human-language prompts directly to specific classes and methods. When your prompt matches the structural language of your codebase, the AI understands your intent by conceptual analogy rather than just blindly grepping for syntax.&lt;/p&gt;

&lt;p&gt;Think about what happens when you have all of these concepts written as first-class systems. The next time you prompt the agent—because you prompt it with human language, using nouns and verbs—you might say something like: "Every time taking a payment fails, roll the order back."&lt;/p&gt;

&lt;p&gt;Because the structure is there, the agent is able to figure out, "Oh, you've prompted me with the noun &lt;em&gt;order&lt;/em&gt;, and I can see in the codebase there's this thing called &lt;code&gt;Order&lt;/code&gt;. You used the verb &lt;em&gt;take payment&lt;/em&gt;, and there is a verb within this codebase called &lt;code&gt;takePayment&lt;/code&gt;." It starts to search by analogy. This makes agents so much more effective at actually doing the thing you want it to do and not making mistakes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// The agent can easily map natural language to this structure&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PaymentProcessor&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;takePayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Order&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;rollBack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&gt;/* ... */&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What are the best naming conventions for AI coding agents?
&lt;/h2&gt;

&lt;p&gt;The best naming conventions treat your business domain as first-class citizens in the code. You should align your variables, classes, and function names exactly with the plain-English vocabulary you use when describing features to your team or your AI tools.&lt;/p&gt;

&lt;p&gt;If you're refactoring your codebase, remember that your biggest context is your codebase itself, and it should reflect the nouns and verbs that you use to prompt it. Here is how that translation looks in practice:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Spoken Prompt Language&lt;/th&gt;
&lt;th&gt;Poor Implementation (Procedural)&lt;/th&gt;
&lt;th&gt;AI-Optimized Implementation (Nouns/Verbs)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;"Take the payment"&lt;/td&gt;
&lt;td&gt;&lt;code&gt;await fetch('https://api.stripe.com/charge')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;paymentProcessor.takePayment()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Create the order"&lt;/td&gt;
&lt;td&gt;&lt;code&gt;db.query('INSERT INTO orders...')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;order.create()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Message the warehouse"&lt;/td&gt;
&lt;td&gt;&lt;code&gt;axios.post('http://warehouse/api')&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;warehouse.sendMessage()&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If your current code looks like the middle column, you can ask an agent to refactor it into the format on the right. Once those nouns and verbs are established, every subsequent prompt will be drastically more accurate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions about AI Coding Agents
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does domain-driven design actually matter for AI?
&lt;/h3&gt;

&lt;p&gt;Yes, absolutely. Domain-driven design (DDD) drastically improves AI coding assistants because it forces developers to use a ubiquitous language. When the codebase uses the same terminology you use in your prompts, the AI can seamlessly translate your natural language into the correct structural changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my AI keep hallucinating functions that don't exist?
&lt;/h3&gt;

&lt;p&gt;I usually see this happen when the agent understands your intent but cannot find the corresponding structural concepts in your codebase. If you ask an agent to "process a refund," but your code only has a generic database update query, the AI might invent a &lt;code&gt;processRefund&lt;/code&gt; method because the noun and verb you prompted with were missing from the code entirely.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I just use an agent to fix my messy procedural code?
&lt;/h3&gt;

&lt;p&gt;Yes, this is one of the highest-leverage ways to use an agent. You can prompt the AI to extract procedural scripts into dedicated classes and functions using specific nouns and verbs. Once refactored, the agent will have a much easier time navigating and modifying the code in the future.&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>cleancode</category>
      <category>promptengineering</category>
      <category>generativeai</category>
    </item>
    <item>
      <title>Prompting AI Coding Agents to Write Clean Code</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Mon, 08 Jun 2026 14:01:56 +0000</pubDate>
      <link>https://dev.to/doogal/prompting-ai-coding-agents-to-write-clean-code-1jfn</link>
      <guid>https://dev.to/doogal/prompting-ai-coding-agents-to-write-clean-code-1jfn</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: AI coding agents default to writing dense, monolithic scripts because they seek the path of least resistance to your desired outcome. To fix this, you must explicitly define what "good code" means for your project using concise, unambiguous, and highly opinionated rules stored in an &lt;code&gt;agents.md&lt;/code&gt; file.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine handing a feature ticket to a junior developer with zero architectural guidelines and walking away. You would expect a messy, monolithic pull request that technically works but is an absolute nightmare to maintain. That is exactly how AI coding agents operate out of the box.&lt;/p&gt;

&lt;p&gt;I see developers getting frustrated with AI output all the time, complaining that the generated code is a dense wad of unreadable script. But the reality is that the agent is just giving you exactly what you asked for: a functional result, achieved via the absolute shortest path possible.&lt;/p&gt;

&lt;p&gt;If you want better output, you have to engineer your environment to demand it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do AI agents default to writing bad code?
&lt;/h2&gt;

&lt;p&gt;AI agents output poor-quality code because they are optimized to reach a functional outcome through the path of least resistance. Unless instructed otherwise, they prioritize immediate execution over long-term readability, modularity, or architectural patterns.&lt;/p&gt;

&lt;p&gt;By default, an LLM treats your prompt like a one-off task. It doesn’t automatically understand your project's separation of concerns, your naming conventions, or how you manage state. It just wants to get the feature working as fast as possible. If you don't explicitly ask for well-structured code, you are going to get a dense, monolithic script. That script will be difficult for you to read, and eventually, it will be difficult for other AI agents to read and modify in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  How can I force my AI agent to write clean code?
&lt;/h2&gt;

&lt;p&gt;You need to instruct the agent with specific, opinionated rules about your codebase rather than just telling it to "write good code." Your instructions must clearly define your architectural preferences while remaining concise and unambiguous so the model doesn't get confused.&lt;/p&gt;

&lt;p&gt;You can't just slap "make no mistakes and write clean code" at the end of a prompt. The agent is just guessing what "clean" means to you. You need to be deeply opinionated. Do you want early returns? Do you prefer functional programming principles or object-oriented classes? You have to lay out exactly what "better code" looks like in your specific environment.&lt;/p&gt;

&lt;p&gt;However, tokens are a real constraint. If you overload the agent with a massive wall of text, or if you provide advice that contradicts itself, the agent will get confused and hallucinate. Conciseness and clarity are non-negotiable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the best way to structure AI coding guidelines?
&lt;/h2&gt;

&lt;p&gt;The most effective approach is a two-tier documentation system: a highly detailed reference document in your codebase for deep context, and a summarized, punchy Markdown file that the agent reads by default. This keeps the token count low while providing a fallback for complex refactors.&lt;/p&gt;

&lt;p&gt;Here is how I recommend breaking down your guidelines so the agent stays on track without blowing up your context window:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Document Type&lt;/th&gt;
&lt;th&gt;File Location&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Detail Level&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;The Rules Engine&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;agents.md&lt;/code&gt; (or &lt;code&gt;.cursorrules&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;The default file the agent reads on every prompt. Keeps the agent aligned with core patterns.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Summarized.&lt;/strong&gt; Bullet points, hard constraints, and extremely concise opinions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;The Deep Context&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/docs/architecture.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A fallback reference used only when the agent veers off track or tackles a major refactor.&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Detailed.&lt;/strong&gt; In-depth explanations of how the codebase is laid out and why.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I generally have my long-form, detailed version of how I want my codebase to be laid out sitting safely in a &lt;code&gt;docs&lt;/code&gt; folder. Then, in my &lt;code&gt;agents.md&lt;/code&gt; file, I keep a tightly summarized version.&lt;/p&gt;

&lt;p&gt;By default, the agent reads the &lt;code&gt;agents.md&lt;/code&gt; file and does a reasonable job keeping the code clean. If I find that the agent is starting to veer away from the architecture I want, I don't argue with it in the chat. Instead, I explicitly point it toward the detailed docs folder to realign its context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What should I include in my agents.md file?
&lt;/h3&gt;

&lt;p&gt;Keep it strictly to your non-negotiable coding standards. Include rules on file structure, preferred libraries, naming conventions, and specific patterns to avoid (like "never use nested ternaries" or "always extract API calls to a service layer").&lt;/p&gt;

&lt;h3&gt;
  
  
  Does giving an AI too many coding rules break its output?
&lt;/h3&gt;

&lt;p&gt;Yes. Providing overly verbose or contradictory rules overloads the context window, causing the agent to lose focus on the actual task. This is why keeping your default instructions concise and unambiguous is critical for stable performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I stop my AI agent from ignoring my system prompts?
&lt;/h3&gt;

&lt;p&gt;If the agent ignores your rules, your instructions might be too vague or conflicting. Ensure your &lt;code&gt;agents.md&lt;/code&gt; uses strong, directive language (e.g., "Always do X", "Never do Y") and temporarily point the agent to your detailed &lt;code&gt;docs&lt;/code&gt; folder to reinforce the structural requirements.&lt;/p&gt;

</description>
      <category>aicoding</category>
      <category>promptengineering</category>
      <category>cleancode</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Why COBOL Still Powers Modern Banking Systems</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Mon, 08 Jun 2026 14:01:29 +0000</pubDate>
      <link>https://dev.to/doogal/why-cobol-still-powers-modern-banking-systems-10p4</link>
      <guid>https://dev.to/doogal/why-cobol-still-powers-modern-banking-systems-10p4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: COBOL still runs 95% of ATM transactions and 43% of banking systems because replacing it is overwhelmingly risky and expensive. Originally adopted in the 1960s for its readable, English-like syntax, COBOL became the foundation of financial business logic. Today, modern languages are simply layered on top of this legacy core.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next time you pull cash out of an ATM, take a second to think about the software architecture making that transaction happen. I often hear engineers assume their request is hitting a modern Go microservice or a highly optimized Rust backend. &lt;/p&gt;

&lt;p&gt;The reality is much older. That transaction is almost certainly passing through a piece of software written in a programming language from 1959.&lt;/p&gt;

&lt;p&gt;COBOL (Common Business-Oriented Language) is over 60 years old, yet it refuses to go away. Despite decades of new frameworks and paradigms, it remains the core of global finance. Let's look at why this old language still runs the majority of our banking systems today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is COBOL still used in banking systems today?
&lt;/h2&gt;

&lt;p&gt;COBOL remains deeply embedded in finance because ripping it out poses a massive operational and financial risk to institutions. Over decades, banks built their core business logic on this language, meaning modern applications are typically just layered on top of a legacy COBOL foundation.&lt;/p&gt;

&lt;p&gt;The sheer volume of legacy code is hard to wrap your head around. There are roughly 220 billion lines of COBOL still sitting in production environments right now. Over the years, instead of replacing it, banks started adding Java, Python, and other modern languages into their stack. &lt;/p&gt;

&lt;p&gt;What happens in practice is that a mobile app request hits a modern API, which then routes through various middleware layers, until it eventually talks to the COBOL core to actually move the money. You have a situation where the core of these old systems is entirely COBOL. Touching that foundation is incredibly risky, so the industry just keeps building around it.&lt;/p&gt;

&lt;h3&gt;
  
  
  COBOL's Footprint in Modern Finance
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Percentage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ATM Transactions&lt;/td&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;In-Person Banking Transactions&lt;/td&gt;
&lt;td&gt;80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Active Bank Adoption&lt;/td&gt;
&lt;td&gt;43%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  What made COBOL so popular for business logic in the 1960s?
&lt;/h2&gt;

&lt;p&gt;COBOL was explicitly designed to read a bit like plain English. This readability allowed non-technical managers to review the code and verify it was executing the correct business rules.&lt;/p&gt;

&lt;p&gt;In the 1960s, 70s, and 80s, bridging the gap between business requirements and technical execution was a major priority for businesses. If you were writing financial software, you wanted managers to come along, look at what you wrote, and say, "Okay, I think I understand what this thing is doing, and I can verify this is what I want it to do."&lt;/p&gt;

&lt;p&gt;Because of this management-friendly approach, banks and massive corporations wrote nearly all of their business logic in COBOL. It solved a communication problem between the business side and the engineering side. The adoption was so widespread that by 1997, 80% of all business logic globally had been written in it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why is migrating away from COBOL so difficult for banks?
&lt;/h2&gt;

&lt;p&gt;Migrating legacy banking systems requires translating decades of complex, undocumented business rules into modern languages without breaking a live financial network. For technical leaders, the massive cost and high risk of failure usually outweigh the benefits of modernization.&lt;/p&gt;

&lt;p&gt;Imagine you are a bank's CTO and the board asks what project you want to prioritize next year. You could propose a complete COBOL replacement project. But realistically, migrating software that has been patched and modified for 40 years is highly likely to go wrong. If it breaks, transactions stop, regulators get involved, and you will probably lose your job. Most leaders look at that risk and decide to leave the migration for later.&lt;/p&gt;

&lt;p&gt;When a bank actually commits to a rewrite, the undertaking is massive. For example, the Commonwealth Bank of Australia spent five years and three-quarters of a billion dollars to finally get rid of their COBOL. They did it eventually, which is a great engineering achievement. However, other institutions have tried to replace their COBOL and failed, burning millions of dollars in the process before reverting to the mainframe. It is simply very expensive and highly risky to get rid of this stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can we automatically translate COBOL to Java or Python?
&lt;/h3&gt;

&lt;p&gt;While there are automated transpilers and AI tools that can convert COBOL syntax into Java or Python, they generally produce code that is hard to maintain. More importantly, automated tools cannot untangle decades of undocumented business logic, which still requires engineers to manually test and verify.&lt;/p&gt;

&lt;h3&gt;
  
  
  Are there still developers writing new COBOL code?
&lt;/h3&gt;

&lt;p&gt;Yes, though they are rare. Most modern COBOL work is strictly maintenance, bug fixing, or writing API wrappers to allow modern web applications to communicate with the legacy systems, rather than building completely new standalone COBOL applications from scratch.&lt;/p&gt;

&lt;h3&gt;
  
  
  What happens if a bank's COBOL system fails?
&lt;/h3&gt;

&lt;p&gt;If a core COBOL system goes offline, the bank effectively stops processing transactions. ATM withdrawals halt, card transactions are declined, and inter-bank transfers queue up or fail entirely until the system is restored, which is why banks invest heavily in maintaining these environments.&lt;/p&gt;

</description>
      <category>cobol</category>
      <category>legacycode</category>
      <category>techdebt</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>How OLED &amp; LTPO Enable Always-On Displays</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Sun, 07 Jun 2026 17:05:54 +0000</pubDate>
      <link>https://dev.to/doogal/how-oled-ltpo-enable-always-on-displays-3e3h</link>
      <guid>https://dev.to/doogal/how-oled-ltpo-enable-always-on-displays-3e3h</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR: Always-on displays don’t drain your phone battery because they rely on two hardware advancements: OLED panels and LTPO technology. OLEDs save power by physically turning off pixels to display black backgrounds. Meanwhile, LTPO allows the screen’s refresh rate to drop to 1Hz, preventing the CPU from constantly waking up.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I often glance down at my phone sitting on my desk. The screen is technically "sleeping," but the time and a few notification icons are still glowing brightly. As a software engineer, I know that powering a display is usually the most expensive operation on a mobile device. So why doesn't this "always-on" state completely tank my battery by lunchtime?&lt;/p&gt;

&lt;p&gt;It comes down to two specific hardware technologies doing heavy lifting in the background: OLED and LTPO.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do OLED screens save battery on lock screens?
&lt;/h2&gt;

&lt;p&gt;OLED screens save battery by physically turning off individual pixels to display the color black. Since the majority of an always-on lock screen is black, the phone only draws power for the few active pixels showing the time or notifications.&lt;/p&gt;

&lt;p&gt;To understand why this matters, I always think about traditional LCDs. Let's say you have an application with a dark mode interface running on an LCD device. To show black, the screen's backlight still blasts at full power, and the liquid crystals just block the light from passing through. It's like leaving the main power breaker on in your house and throwing a heavy blanket over the lamps to make a room dark. You're still paying for the electricity.&lt;/p&gt;

&lt;p&gt;OLED (Organic Light-Emitting Diode) panels are fundamentally different. Every single pixel generates its own light. If a pixel needs to be black, it just shuts off entirely. When my phone enters its resting state, roughly 95% of the display is physically powered down. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why is the CPU the real battery drainer for phone screens?
&lt;/h2&gt;

&lt;p&gt;The display panel itself is only part of the power consumption equation; the CPU driving it is the real battery killer. Traditional screens require the CPU to wake up 60 times a second just to tell the display what to render, which prevents the processor from staying in a deep sleep state.&lt;/p&gt;

&lt;p&gt;Even if most of the pixels are turned off because of OLED tech, standard OLEDs still have a fixed refresh rate of 60Hz. Imagine you have a background worker polling a database every 16 milliseconds just to see if a value changed. That constant polling overhead is going to chew through your resources. For a phone, waking the CPU up 60 times a second just to render a static clock is incredibly inefficient. I find that the problem isn't the active pixels—it's the CPU thrashing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an LTPO display and how does it reduce battery usage?
&lt;/h2&gt;

&lt;p&gt;LTPO (Low-Temperature Polycrystalline Oxide) is a backplane technology that improves how capacitance is stored within a pixel, allowing the screen's refresh rate to dynamically scale. For always-on displays, LTPO can drop the refresh rate down to just 1Hz, meaning the CPU only wakes up once per second.&lt;/p&gt;

&lt;p&gt;By holding the charge longer, the display doesn't need constant hand-holding from the processor. Instead of waking up 60 times a second, the CPU fires up just once a second to update the minute on the clock or pulse a notification icon. Going from 60 wake-ups a second down to one is a massive reduction in compute cycles. This allows the device to stay in a low-power state almost indefinitely while still showing you relevant information.&lt;/p&gt;

&lt;h3&gt;
  
  
  Display Technology Power Breakdown
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Display Tech&lt;/th&gt;
&lt;th&gt;Black Pixel Behavior&lt;/th&gt;
&lt;th&gt;Refresh Rate&lt;/th&gt;
&lt;th&gt;CPU Wakeups / Sec&lt;/th&gt;
&lt;th&gt;Battery Impact for Always-On&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standard LCD&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Backlight stays on, blocks light&lt;/td&gt;
&lt;td&gt;Fixed 60Hz&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;Severe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Standard OLED&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pixels physically turn off&lt;/td&gt;
&lt;td&gt;Fixed 60Hz&lt;/td&gt;
&lt;td&gt;60&lt;/td&gt;
&lt;td&gt;Moderate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;LTPO OLED&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pixels physically turn off&lt;/td&gt;
&lt;td&gt;Dynamic (down to 1Hz)&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Minimal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does always-on display cause screen burn-in on OLEDs?
&lt;/h3&gt;

&lt;p&gt;No, modern always-on displays prevent screen burn-in through software tricks. The operating system will imperceptibly shift the position of the clock and icons by a few pixels every minute, ensuring no single pixel is left on for extended periods.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can LCD screens support an always-on display?
&lt;/h3&gt;

&lt;p&gt;Technically yes, but practically no. Because an LCD requires the entire backlight to be illuminated to show even a single white pixel of text, an always-on state would drain the battery exactly as fast as if you were actively using the phone.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much battery does an always-on display actually use?
&lt;/h3&gt;

&lt;p&gt;With LTPO and OLED technology combined, an always-on display typically consumes about 1% to 2% of your battery life per hour. If you leave your phone sitting untouched for an entire 8-hour workday, you might only lose around 10% of your total capacity.&lt;/p&gt;

</description>
      <category>hardware</category>
      <category>smartphones</category>
      <category>mobiledevelopment</category>
      <category>techexplained</category>
    </item>
    <item>
      <title>Why Mobile CPUs Have Performance &amp; Efficiency Cores</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Sun, 07 Jun 2026 17:05:38 +0000</pubDate>
      <link>https://dev.to/doogal/why-mobile-cpus-have-performance-efficiency-cores-4dgm</link>
      <guid>https://dev.to/doogal/why-mobile-cpus-have-performance-efficiency-cores-4dgm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: Unlike traditional laptops that rely on a single type of power-hungry CPU core, modern mobile phones use a hybrid architecture combining high-performance cores with low-power efficiency cores. The operating system dynamically shifts workloads between them, using performance cores for intensive tasks like gaming, and efficiency cores for background tasks, ultimately maximizing battery life.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I constantly see developers obsessing over raw processing speed. But as a software engineer writing code for these devices, I always emphasize one harsh reality: in the mobile world, raw speed is completely useless if the device dies in thirty minutes. Imagine building a sports car that can hit 200 miles per hour, but it only holds a single gallon of gas. You'd have a blast for about a minute before you're stranded on the side of the road. That is the exact challenge hardware engineers face when designing modern mobile CPUs.&lt;/p&gt;

&lt;p&gt;When I look at traditional computers, like older laptop architectures, they typically rely on one type of CPU core. It’s powerful, it gets the job done, but it is incredibly energy-hungry. Mobile phones don't have the luxury of a massive battery or an AC adapter plugged into the wall, so they had to adopt a completely different architectural approach to survive a full day off the charger.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do mobile phones have different types of CPU cores?
&lt;/h2&gt;

&lt;p&gt;Mobile phones use different types of CPU cores to solve the competing demands of high-end processing speed and all-day battery life. By pairing "performance" cores with "efficiency" cores, the device can physically switch processing engines based on how demanding the current workload is.&lt;/p&gt;

&lt;p&gt;I like to think of it like a hybrid vehicle. When you are cruising through a slow suburban parking lot, the car uses a small electric motor that sips energy. But the second you merge onto a fast highway, the combustion engine kicks in to give you the necessary power. Mobile CPUs do the exact same thing with the code we write.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do performance cores and efficiency cores compare?
&lt;/h2&gt;

&lt;p&gt;Performance cores run at higher clock speeds and consume significantly more power, whereas efficiency cores operate at lower speeds but offer vastly superior performance-per-watt. The efficiency cores are deliberately designed to be "worse" at raw speed so they can handle lighter background loads without needlessly draining the battery.&lt;/p&gt;

&lt;p&gt;To put this into perspective, let’s look at the Apple A17 Pro chip. It utilizes a split architecture consisting of two performance cores and four efficiency cores.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Core Type&lt;/th&gt;
&lt;th&gt;Core Count&lt;/th&gt;
&lt;th&gt;Clock Speed&lt;/th&gt;
&lt;th&gt;Power Draw&lt;/th&gt;
&lt;th&gt;Efficiency Ratio&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Performance&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;3.78 GHz&lt;/td&gt;
&lt;td&gt;~8 Watts&lt;/td&gt;
&lt;td&gt;Standard&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Efficiency&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;2.00 GHz&lt;/td&gt;
&lt;td&gt;~1.5 Watts&lt;/td&gt;
&lt;td&gt;~5x more performant per watt&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Looking at those numbers, I find it fascinating that the efficiency cores only draw a fraction of the power but still deliver respectable clock speeds. In fact, those efficiency cores end up being about five times more performant per watt than their high-speed counterparts.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does the operating system decide which core to use?
&lt;/h2&gt;

&lt;p&gt;The operating system acts as a traffic controller, constantly analyzing the real-time demands of running applications and routing instructions to the appropriate CPU core. High-priority, foreground tasks get routed to performance cores, while background tasks get handed off to efficiency cores.&lt;/p&gt;

&lt;p&gt;Let's say you and I are building a mobile 3D game. When the user is actively playing, rendering heavy graphics, and interacting with the screen, the OS routes that workload to the performance cores. We get all the raw speed we need to keep the frame rate high and the gameplay smooth.&lt;/p&gt;

&lt;p&gt;But what happens when the user locks their phone and puts it on the desk? The device still needs to stay awake enough to receive a text message or ping our server for push notifications. The OS recognizes this low-priority state and routes those background tasks exclusively to the 1.5-watt efficiency cores. The phone processes the data perfectly fine, but it isn't burning through battery power to do it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why isn't "more CPU cores" always better for mobile?
&lt;/h3&gt;

&lt;p&gt;Simply adding more high-powered cores to a mobile device generates too much heat and drains the battery faster than the system can physically handle. True mobile optimization is about having the right type of core available when you need it, rather than just maximizing the total core count.&lt;/p&gt;

&lt;p&gt;I often hear the misconception that "more CPUs is better," but that is only half right. If we crammed eight massive performance cores into a phone, it would thermally throttle within minutes. What I always look for in mobile engineering is highly targeted CPU efficiency—giving you the power exactly when you need it the most.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can software developers force the OS to use a performance core?&lt;/strong&gt;&lt;br&gt;
Generally, no. Modern operating systems abstract hardware scheduling away from the application layer. I recommend assigning different Quality of Service (QoS) priorities to your threads (like marking a thread as "user-interactive" versus "background"), which heavily hints to the OS where the work should go, but the system makes the final hardware routing decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do modern laptops use efficiency cores now?&lt;/strong&gt;&lt;br&gt;
Yes. While older laptops relied on a single core type, modern laptop processors (like Apple's M-series or Intel's newer chips) have adopted this exact hybrid big.LITTLE architecture to improve battery life without sacrificing desktop-level performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens if all the efficiency cores are fully utilized?&lt;/strong&gt;&lt;br&gt;
If the efficiency cores are completely saturated with background tasks and a new process spins up, the OS scheduler will begin pushing workloads onto the performance cores to prevent system lag. The OS prioritizes keeping the device responsive, even if it means a temporary hit to battery life.&lt;/p&gt;

</description>
      <category>computerarchitecture</category>
      <category>processors</category>
      <category>mobiledevelopment</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Amdahl's Law: Why More CPU Cores Don't Make Code Faster</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Sun, 07 Jun 2026 17:05:24 +0000</pubDate>
      <link>https://dev.to/doogal/amdahls-law-why-more-cpu-cores-dont-make-code-faster-7j2</link>
      <guid>https://dev.to/doogal/amdahls-law-why-more-cpu-cores-dont-make-code-faster-7j2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: Amdahl's Law dictates that the maximum speedup of a parallelized program is strictly limited by the portion of its code that must run serially. If one-third of your application relies on sequential operations like resource locking, your maximum possible speedup is exactly 3x—regardless of whether you use 8 or 64 CPU cores.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You're really excited. You just dropped serious cash on a shiny new 8-core CPU. You compile your heavy workload, spin it up, and eagerly watch the execution time drop. But wait—it's only running three times faster than it did on your old single-core setup. &lt;/p&gt;

&lt;p&gt;Assuming it’s a hardware bottleneck, you empty your wallet for a massive 64-core beast. I often see developers make this assumption: more cores means more speed, right? Yet when you run the program again, you're even more disappointed to find it &lt;em&gt;still&lt;/em&gt; caps out at exactly three times faster. &lt;/p&gt;

&lt;p&gt;What is happening here? You’ve just run headfirst into Amdahl's Law. &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Amdahl's Law in software engineering?
&lt;/h2&gt;

&lt;p&gt;Amdahl's Law is a principle that calculates the theoretical maximum performance improvement of a system when only a part of that system is optimized. When I explain this concept to other engineers, I emphasize that it proves the speed of a parallelized program is ultimately capped by the percentage of its code that must execute sequentially. &lt;/p&gt;

&lt;p&gt;If a third of your program is serial code, the absolute maximum speedup you can achieve is three times. It mathematically defines the ceiling on how fast a program can run based entirely on the proportion of code that simply cannot be parallelized. &lt;/p&gt;

&lt;h2&gt;
  
  
  Why does serial code limit parallel processing speed?
&lt;/h2&gt;

&lt;p&gt;Serial code creates a hard mathematical ceiling because certain operations must happen one after another to maintain data integrity. When parallel threads hit a shared resource and have to wait in line, adding more CPU cores yields zero additional speed because those extra cores are just sitting idle in the queue.&lt;/p&gt;

&lt;p&gt;Programs inevitably have some amount of their makeup that is inherently serial. If you have shared state in your application, running multiple parallel processes against it without guardrails will corrupt your data. To prevent this, we introduce locks on shared resources. &lt;/p&gt;

&lt;p&gt;Imagine your team is building a ticketing system for a massive stadium tour. Thousands of users can browse seats in parallel, but the actual checkout process requires a strict lock to ensure two people don't buy the exact same front-row seat. That checkout lock is serial. There is always some amount of your program that simply cannot be run in parallel, and that puts a permanent ceiling on how much throwing more hardware at the problem actually helps.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does the serial proportion impact maximum speedup?
&lt;/h2&gt;

&lt;p&gt;The theoretical speed limit of your application is inversely proportional to the fraction of its serial execution time. As you add an infinite number of cores, the parallel execution time approaches zero, leaving only the serial execution bottleneck.&lt;/p&gt;

&lt;p&gt;I put together this quick breakdown to show how that mathematical ceiling plays out based on the serial makeup of your code:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Proportion of Serial Code&lt;/th&gt;
&lt;th&gt;Maximum Theoretical Speedup (Infinite Cores)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1/2 (50%)&lt;/td&gt;
&lt;td&gt;2x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1/3 (33.3%)&lt;/td&gt;
&lt;td&gt;3x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1/4 (25%)&lt;/td&gt;
&lt;td&gt;4x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1/10 (10%)&lt;/td&gt;
&lt;td&gt;10x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1/20 (5%)&lt;/td&gt;
&lt;td&gt;20x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This demonstrates why the concept of "more cores is more fast" is ultimately a lie. You cannot just throw more cores at a system forever. To actually make your application faster once you hit this hardware ceiling, you have to do the hard engineering work of refactoring your architecture to reduce shared state, minimize lock contention, and shrink that serial footprint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How is Amdahl's Law different from Moore's Law?
&lt;/h3&gt;

&lt;p&gt;Moore's Law is an observation about hardware scaling over time, stating that the number of transistors on a microchip doubles roughly every two years. Amdahl's Law is a mathematical formula regarding software execution, defining the strict limits of parallelizing a specific workload regardless of how powerful the hardware is.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Amdahl's Law apply to distributed microservices?
&lt;/h3&gt;

&lt;p&gt;Yes. In distributed systems, network latency, synchronized database writes, and single-threaded message queues act as the serial bottlenecks. Even if you spin up hundreds of container replicas, the system can only process requests as fast as the slowest sequential dependency allows.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Gustafson's Law?
&lt;/h3&gt;

&lt;p&gt;Gustafson's Law is the counter-argument to Amdahl's Law. It suggests that as developers get access to more computing power, they don't just run the exact same problems faster; they increase the size and complexity of the problem. As the problem size grows, the parallel portion of the workload usually scales up while the serial portion remains relatively fixed, improving the overall efficiency of adding more cores.&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>softwareengineering</category>
      <category>parallelcomputing</category>
      <category>performanceoptimization</category>
    </item>
    <item>
      <title>Why Quantum Computers Won't Replace Classical Computing</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Sat, 06 Jun 2026 08:30:08 +0000</pubDate>
      <link>https://dev.to/doogal/why-quantum-computers-wont-replace-classical-computing-3f5p</link>
      <guid>https://dev.to/doogal/why-quantum-computers-wont-replace-classical-computing-3f5p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: Despite the hype, quantum computers are not faster general-purpose replacements for classical machines. While a standard $400 smartphone can perform basic arithmetic millions of times faster than a quantum computer, quantum machines remain highly specialized tools designed exclusively for complex mathematical tasks like factoring large primes and breaking encryption.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I constantly see engineers assume that "quantum" is just a synonym for "infinitely faster." We hear about a 1,000-qubit computer that costs $10 million, requires temperatures colder than deep space to function, and we naturally expect it to run our web servers and game engines at warp speed.&lt;/p&gt;

&lt;p&gt;But if I take a regular $400 smartphone and ask it to multiply two numbers, it will completely smoke that quantum computer. Let me break down why quantum computers are actually terrible at doing the things we write code for every day.&lt;/p&gt;

&lt;h2&gt;
  
  
  Are quantum computers faster than classical computers?
&lt;/h2&gt;

&lt;p&gt;No, for general-purpose computing, quantum computers are massively slower than the device sitting in your pocket right now. A standard smartphone can execute basic mathematical operations millions of times faster than a quantum computer.&lt;/p&gt;

&lt;p&gt;If I ask a $400 phone to multiply two numbers together, the processor handles it in picoseconds. Hand that exact same operation to a 1,000-qubit quantum computer, and it takes microseconds to complete. That makes the quantum computer roughly 10 million times slower at basic arithmetic.&lt;/p&gt;

&lt;p&gt;Think of it like comparing a commuter car to a massive mining excavator. If I need to drive to the grocery store, the car gets me there efficiently. The excavator tops out at a crawl, burns a ton of fuel, and is entirely the wrong tool for the job. Classical computers are the commuter cars. They are perfectly optimized for adding, sorting arrays, running web browsers, and serving web traffic. If you try to run standard software architectures—like a neural network or a basic CRUD app—on a quantum machine, it simply will not work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are quantum computers actually good for?
&lt;/h2&gt;

&lt;p&gt;Quantum computers excel at a very small number of highly specialized mathematical jobs rather than general application execution. Their most famous use case is quickly factoring massive prime numbers to break encryption protocols like RSA 2048.&lt;/p&gt;

&lt;p&gt;Classical computers fundamentally struggle with factoring large primes. If I try to write a script to crack modern RSA encryption using standard brute-force computation on classical silicon, it would take an absurdly long time. Classical architecture isn't built to evaluate those distinct mathematical possibilities efficiently.&lt;/p&gt;

&lt;p&gt;Quantum computing flips this problem on its head. By leveraging qubits, I can essentially nudge them into an arrangement that solves the prime factoring problem incredibly fast. &lt;/p&gt;

&lt;p&gt;Here is a quick breakdown of how classical and quantum machines compare across different engineering workloads:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Workload / Operation&lt;/th&gt;
&lt;th&gt;Classical Computer (Standard Silicon)&lt;/th&gt;
&lt;th&gt;Quantum Computer (Qubits)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Basic Arithmetic (Multiplication)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Picoseconds&lt;/td&gt;
&lt;td&gt;Microseconds (10M times slower)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Web Browsing &amp;amp; Application Logic&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Highly Optimized&lt;/td&gt;
&lt;td&gt;Completely Inefficient&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Sorting Algorithms&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Highly Optimized&lt;/td&gt;
&lt;td&gt;Impractical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Factoring Large Primes (RSA 2048)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Centuries / Millennia&lt;/td&gt;
&lt;td&gt;Exceptionally Fast&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Operating Temperature&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Room Temperature&lt;/td&gt;
&lt;td&gt;Colder than Deep Space&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Will quantum computers replace regular computers?
&lt;/h2&gt;

&lt;p&gt;No, quantum computers will never serve as a catch-all replacement for classical computers. They are the next wave of specialized computation, meant to act alongside traditional silicon rather than replace it entirely.&lt;/p&gt;

&lt;p&gt;I never expect to see a quantum laptop for writing React code or running Docker containers. Instead, the future of our industry points toward hybrid architectures. Let's say your team is building a fintech application that hits a highly specific, computationally dense mathematical problem. You will run your standard infrastructure on classical machines, and when your system hits that bottleneck, it will offload that single task to a quantum co-processor. Quantum is not a generic upgrade; it is a specialized tool for very specific use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can quantum computers run standard software and operating systems?
&lt;/h3&gt;

&lt;p&gt;No, quantum computers cannot run standard software like Linux, web browsers, or video games. Traditional software compiles into binary instructions designed for classical transistors, whereas quantum computers rely on quantum logic gates manipulating qubits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why do quantum computers need to be so cold?
&lt;/h3&gt;

&lt;p&gt;Quantum computers must operate at temperatures near absolute zero to maintain the delicate state of their qubits. Any ambient heat or electromagnetic interference from the environment causes "decoherence," which collapses the quantum state and introduces massive calculation errors.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is RSA encryption useless now that quantum computers exist?
&lt;/h3&gt;

&lt;p&gt;Not yet. While quantum computers theoretically have the capability to break RSA 2048, current quantum hardware does not yet have enough stable, error-corrected qubits to execute this at scale. However, the tech industry is already moving toward quantum-resistant cryptographic algorithms to prepare for when the hardware inevitably catches up.&lt;/p&gt;

</description>
      <category>quantumcomputing</category>
      <category>computerscience</category>
      <category>cryptography</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Spotify's Approximate Nearest Neighbor Search</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Sat, 06 Jun 2026 08:29:20 +0000</pubDate>
      <link>https://dev.to/doogal/spotifys-approximate-nearest-neighbor-search-2697</link>
      <guid>https://dev.to/doogal/spotifys-approximate-nearest-neighbor-search-2697</guid>
      <description>&lt;p&gt;&lt;strong&gt;Quick Answer: Spotify skips exact nearest neighbor calculations because searching hundreds of millions of tracks is too slow. Instead, it uses an approximate nearest neighbor (ANN) approach. By structuring data in a multi-layered graph, the algorithm uses data "highways" to rapidly traverse the dataset, narrowing down the local neighborhood instantly to deliver fast recommendations.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You just finished listening to a track, and before you can even think about what to queue up next, Spotify seamlessly transitions into a song that perfectly matches the vibe. It feels like magic, but under the hood, it is a massive engineering challenge. &lt;/p&gt;

&lt;p&gt;How do you figure out the absolute best next song when you have a catalog of hundreds of millions of tracks? If you do this the naive way, the database lookup would take far too long to keep the music playing smoothly. Here is how recommendation algorithms actually handle data at that scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why doesn't Spotify use exact nearest neighbor search?
&lt;/h2&gt;

&lt;p&gt;Exact nearest neighbor (KNN) algorithms calculate the mathematical distance between your current song and every single other song in the database to find the closest match. When a catalog hits hundreds of millions of records, computing these distances for every user query becomes incredibly data-intensive and far too slow for real-time playback.&lt;/p&gt;

&lt;p&gt;Imagine your system is trying to find a high-energy dance remix. If the algorithm has to literally measure the distance from that track to every acoustic indie song, heavy metal track, and classical symphony in existence just to rule them out, the latency spikes. To keep the infrastructure costs sane and the user experience immediate, you have to abandon the idea of finding the &lt;em&gt;absolute&lt;/em&gt; perfect match and settle for finding an incredibly close match, incredibly fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does approximate nearest neighbor (ANN) search work?
&lt;/h2&gt;

&lt;p&gt;Approximate nearest neighbor (ANN) search algorithms trade a tiny fraction of accuracy for massive performance gains by organizing data into navigable, multi-layered graphs. Instead of scanning the whole database, the algorithm drops into a top-level map with very few points and travels across massive distances, stepping down through layers of increasing density until it finds the right local neighborhood.&lt;/p&gt;

&lt;p&gt;I like to picture this data structure as a real-world roadmap. At the very bottom level, every single song in the catalog lives on a map, clustered roughly by genre, tempo, or mood. Up in the "pop" neighborhood, all those songs are connected to each other by tiny minor roads or bridges. &lt;/p&gt;

&lt;p&gt;Instead of making the algorithm drive through every single minor road to find a destination, we build layers on top of it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Graph Layer&lt;/th&gt;
&lt;th&gt;Map Analogy&lt;/th&gt;
&lt;th&gt;Node Density&lt;/th&gt;
&lt;th&gt;Navigation Distance&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Top Layer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Highways / Motorways&lt;/td&gt;
&lt;td&gt;Very Low (Few Songs)&lt;/td&gt;
&lt;td&gt;Massive (Cross-genre jumps)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Middle Layer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Major Roads&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Moderate (Sub-genre travel)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Bottom Layer&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Minor Roads / Bridges&lt;/td&gt;
&lt;td&gt;High (All Songs)&lt;/td&gt;
&lt;td&gt;Small (Track-to-track)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  How does the algorithm traverse this layered data?
&lt;/h3&gt;

&lt;p&gt;The search starts at the highest, sparsest layer of the graph and looks for the nearest node before dropping down to the next level. It repeats this process, stepping down from highways to major roads to minor roads, naturally zeroing in on the correct cluster.&lt;/p&gt;

&lt;p&gt;Let's say your song finishes. The system queries that top layer. It grabs a highway and travels a massive distance to reach the general vicinity of the target sound. Now that it is in the right neighborhood, it drops to the middle layer. It travels along major roads to get even closer to the specific vibe. Finally, it drops to the bottom layer where all the songs live, taking minor roads to bounce between a few highly relevant tracks until it finds the closest available neighbor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is approximate search accurate enough for music recommendations?
&lt;/h2&gt;

&lt;p&gt;Yes, for recommendation systems, an approximate nearest neighbor is more than good enough because the user cannot tell the difference between a 99% match and a 100% match. The algorithm might skip over the theoretical exact nearest neighbor, but the track it outputs will still be mathematically adjacent to it.&lt;/p&gt;

&lt;p&gt;In software engineering, you constantly weigh computational cost against user value. Spending massive amounts of CPU time to find the absolute mathematically closest song offers zero perceivable benefit to the listener. Traversing a layered graph cuts the search time down exponentially, keeping the music playing without a hiccup.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the difference between KNN and ANN?
&lt;/h3&gt;

&lt;p&gt;Exact K-Nearest Neighbors (KNN) scans the entire dataset to compute the exact distance between the query and every possible point, guaranteeing absolute accuracy at the cost of speed. Approximate Nearest Neighbors (ANN) uses structured indexes (like graphs or trees) to quickly hone in on the right neighborhood, prioritizing extreme speed over perfect accuracy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do graph-based search algorithms consume a lot of memory?
&lt;/h3&gt;

&lt;p&gt;Yes, algorithms that rely on multi-layered graphs, such as Hierarchical Navigable Small World (HNSW), require a significant memory footprint because they have to store all the connections (edges) between the nodes at multiple layers. However, the trade-off in ultra-low latency query times makes the memory cost worthwhile for large-scale consumer applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why not use a standard relational database for song recommendations?
&lt;/h3&gt;

&lt;p&gt;Standard relational databases are designed for structured querying (e.g., finding exact matches for "Artist = Daft Punk"). Recommendations rely on vector embeddings—complex arrays of numbers that represent the "vibe" or audio features of a song. Relational databases cannot efficiently calculate the distance between these high-dimensional vectors at scale.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>algorithms</category>
      <category>softwareengineering</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>How Face ID Works: Infrared Lasers &amp; Neural Networks</title>
      <dc:creator>Doogal Simpson</dc:creator>
      <pubDate>Mon, 11 May 2026 14:15:22 +0000</pubDate>
      <link>https://dev.to/doogal/how-face-id-works-infrared-lasers-neural-networks-26o2</link>
      <guid>https://dev.to/doogal/how-face-id-works-infrared-lasers-neural-networks-26o2</guid>
      <description>&lt;p&gt;&lt;strong&gt;TL;DR: Face ID does not compare standard selfies to unlock your phone. Instead, it projects 30,000 infrared laser dots onto your face to create a highly precise 3D geometry map. A neural network converts this map into a mathematical feature vector, comparing it to your saved profile to authenticate your identity.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Most people think their phone unlocks by snapping a quick selfie and playing a game of spot-the-difference. I get it—from a user perspective, that’s exactly what it feels like. But under the hood, modern facial authentication relies on an entirely different stack of hardware and software. It’s not looking at your face; it’s reading your face's topography like a surveyor mapping a mountain range. Let's break down the actual engineering happening in the fraction of a second it takes to unlock your screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  How does Face ID map your face in the dark?
&lt;/h2&gt;

&lt;p&gt;Face ID uses infrared (IR) light instead of the visible light spectrum to detect depth. By projecting 30,000 microscopic infrared laser dots onto your skin, the system can operate flawlessly even in pitch-black conditions. This hardware approach creates a highly accurate 3D topographic map of your features.&lt;/p&gt;

&lt;p&gt;Visible light cameras are useless without an external light source. If you’ve ever tried to build a computer vision pipeline using a basic webcam in a dark room, you know the struggle. To bypass this environmental limitation, facial recognition systems use an infrared emitter. Think of it like dropping a massive, invisible net of laser points over your face. As these dots hit your nose, cheekbones, and jawline, they scatter. Because the hardware knows exactly when and where these dots were fired, it can measure how they scatter to map the exact contours of your face down to half a millimeter of distance.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens to the scattered infrared data?
&lt;/h2&gt;

&lt;p&gt;A dedicated infrared sensor captures the scattered light to build a raw 3D geometry map. This physical map is then fed into an onboard neural network to be translated into a mathematical format called a feature vector. This vectorization allows for instantaneous mathematical comparisons rather than heavy spatial rendering.&lt;/p&gt;

&lt;p&gt;Raw infrared scatter isn't incredibly useful on its own for fast database lookups. Comparing two raw point clouds containing 30,000 spatial coordinates takes significant compute power, and a mobile CPU would choke trying to execute that matrix operation instantly. Instead, the local neural network performs dimensionality reduction. It takes this massive spatial geometry map and compresses it into a highly specific, lightweight array of numbers. &lt;/p&gt;

&lt;p&gt;If you imagine a hashing algorithm turning a massive file into a short string, a feature vector is a similar concept, but optimized for physical spatial data. When the device authenticates you, it's essentially running a fast mathematical distance calculation between the live vector and the originally stored vector. If the distance between these two arrays of numbers falls within a strict geometric threshold, the neural network confirms your identity. It is a highly efficient boundary check rather than a heavy pixel-by-pixel image comparison.&lt;/p&gt;

&lt;h3&gt;
  
  
  What are the steps in the Face ID authentication pipeline?
&lt;/h3&gt;

&lt;p&gt;The pipeline operates as a real-time hardware-to-software relay, transforming physical light into mathematical security tokens. It starts with infrared emission and reflection, moving into depth mapping, and finally executes neural network vectorization to determine a match. Here is exactly how the data flows from the sensor to the CPU during a single authentication request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;1. Emission:&lt;/strong&gt; The dot projector fires 30,000 infrared lasers at the target surface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2. Reflection:&lt;/strong&gt; The lasers scatter based on the physical depth and contours of the face.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3. Capture:&lt;/strong&gt; An infrared camera reads the distorted dot pattern.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4. Mapping:&lt;/strong&gt; The system constructs a 3D geometry map from the captured depth data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;5. Vectorization:&lt;/strong&gt; A neural network translates the 3D map into a unique feature vector.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;6. Comparison:&lt;/strong&gt; The system calculates the mathematical distance between the new vector and the originally saved lock-screen vector to approve or deny access.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why can't you trick Face ID with a photograph?
&lt;/h2&gt;

&lt;p&gt;A printed photo or a digital screen is a two-dimensional flat plane lacking any physical depth. Because Face ID authenticates based on 3D geometry rather than visual appearance, a flat surface immediately fails the depth check. The resulting depth map simply doesn't match human topography.&lt;/p&gt;

&lt;p&gt;Let's say your team is building a fintech app that handles high-value wire transfers. If your internal biometric authentication relied purely on pixel-based visual matching (like a standard webcam feed), a malicious actor could bypass it simply by holding a high-resolution iPad photo of the victim to the lens. &lt;/p&gt;

&lt;p&gt;But because Face ID relies on infrared depth mapping, holding up a screen or a printed photo just looks like a perfectly flat sheet of glass or paper to the IR sensor. The neural network expects to see a nose protruding several centimeters and eye sockets recessed into the skull. A flat plane produces a geometry map with zero depth delta. When that flat map is vectorized, the resulting embedding lands miles away from the authorized feature vector in the latent space, and the system instantly denies access.&lt;/p&gt;

&lt;h2&gt;
  
  
  What else do developers ask about Face ID?
&lt;/h2&gt;

&lt;p&gt;When integrating biometric security, engineers often have secondary questions about privacy limits and hardware edge cases. Understanding how the device stores data and adapts to changes helps clarify system limitations. Here are three common follow-up queries regarding the lifecycle of a facial feature vector.&lt;/p&gt;

&lt;h3&gt;
  
  
  Does Face ID store photos of my face?
&lt;/h3&gt;

&lt;p&gt;No, the system does not store visible light images or full 3D point clouds of your face. It only retains the mathematical representation, or feature vector, derived from your facial geometry. This vector is securely locked away on the device's hardware enclave and never leaves the phone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can Face ID adapt if I wear glasses or grow a beard?
&lt;/h3&gt;

&lt;p&gt;Yes, because it relies on a neural network and feature vectors, the system continuously updates its mathematical model. If a newly generated vector is close enough to authenticate you, the system subtly adjusts the stored baseline vector. This accounts for gradual physical changes over time without requiring a manual reset.&lt;/p&gt;

&lt;h3&gt;
  
  
  How accurate is the infrared dot projector?
&lt;/h3&gt;

&lt;p&gt;The hardware is exceptionally precise, mapping facial contours with a distance accuracy down to half a millimeter. This ensures that even the most minor topographic depth variations are captured and fed into the neural network. As a result, geometric spoofing of the authentication system is incredibly difficult.&lt;/p&gt;

</description>
      <category>computervision</category>
      <category>neuralnetworks</category>
      <category>machinelearning</category>
      <category>authentication</category>
    </item>
  </channel>
</rss>
