<?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 Nic Bell on Medium]]></title>
        <description><![CDATA[Stories by Nic Bell on Medium]]></description>
        <link>https://medium.com/@nicbell?source=rss-85267dcf3fb4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5Nx2GkuI3zxeV8KX27tcVw.jpeg</url>
            <title>Stories by Nic Bell on Medium</title>
            <link>https://medium.com/@nicbell?source=rss-85267dcf3fb4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:40:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicbell/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[I tried local AI coding and it scared me]]></title>
            <link>https://nicbell.medium.com/i-tried-local-ai-coding-and-it-scared-me-6ceeea3c74b6?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ceeea3c74b6</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[energy]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Sat, 31 Oct 2026 23:23:46 GMT</pubDate>
            <atom:updated>2026-11-02T08:58:38.213Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all heard the pitch. Executive boards are drooling with collective salivation over a singular, sleek corporate dream: <em>fire the engineers, plug in autonomous AI agents, and watch the software write itself for pennies on the dollar.</em></p><p>I used to view this transformation through a standard professional lens. Then, I spent an afternoon trying to configure a local Large Language Model (LLM) on my desktop to perform a dead-simple front-end task on a tiny hobby project.</p><p>What followed wasn’t a triumph of open-source autonomy. It was a chaotic, frustrating descent into a hardware bottleneck that completely pulled back the curtain on the AI hype cycle. By the time my graphics card finished choking on a couple of Kotlin files, I realised something terrifying: <strong>We are currently operating inside a massive, heavily subsidised tech bubble with very little contingency planning.</strong></p><p>Here is what happens when you force consumer hardware to do the raw math of “artificial intelligence” locally — and why the entire industry may be creating a structural dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3kLHKJuWIsnxEftx" /><figcaption>Photo by <a href="https://unsplash.com/@thomasfos?utm_source=medium&amp;utm_medium=referral">Thomas Foster</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The Experiment: A Tiny UI Edit Meets Local Hardware</h4><p>I wasn’t trying to build a self-replicating neural network. I was working on a small Android hobby project with fewer than a hundred files, written in Jetpack Compose. I have a robust, modern development desktop: a high-end processor, 32GB of blazing-fast 6400MHz DDR5 RAM, and a modern desktop GPU with 12GB of dedicated VRAM.</p><p>My goal was simple. I had two UI screens that used a beautiful, edge-to-edge Call-to-Action (CTA) layout. I wanted to modify a third screen to match that exact same visual pattern—swapping out a floating action button for the edge-to-edge CTA group.</p><p>Rather than doing it manually, I decided to test a local 14-billion parameter model running natively on my hardware. No cloud. No data privacy leaks. Just pure local execution.</p><p>What happened next felt like trying to manage a worst-case, outsourced corporate software loop.</p><p>The local model started spitting out mountains of over-polite, robotic apologies. It outlined obvious architectural steps I already knew. Then, it delivered absolute garbage. It completely lost its tether to reality and began hallucinating fake Android XML layout code — ignoring the actual Compose code I had fed it. When I called it out, it entered an infinite loop of over-apologising, faked some raw JSON tool calls to save face, and ground my terminal to a halt.</p><h4>Diagnosing the Amnesia: The Brutal Math of Context</h4><p>When a local model starts hallucinating like a corporate project manager spinning a failure, it’s not because the model is inherently “stupid.” It’s because the software physically cut its brain off mid-sentence.</p><p>When you use local IDE chat plugins, they try to be “smart.” Behind your back, they wrap your query in a massive automated payload: thousands of tokens of system instructions, full directory repository maps, and verbose definitions for background tools.</p><p>By the time I attached just three Kotlin files to my prompt, the input payload skyrocketed to <strong>27,633 tokens</strong>.</p><p>The local engine was hard-capped to a 16,384-token memory limit. My real files were literally clipped out of the model’s brain. The model woke up with total amnesia, saw the words “Android project,” and fell back on its generic, pre-trained default scripts because the actual context was pushed out of its memory bank.</p><p>I first tried removing a lot of the context and just providing the three files to a detached chat. The problem is project context (library versions, project structure, available tools) are the very thing that make the LLM able to generate useful code. Otherwise it is much like StackOverflow through a chat window. Useful for answering a question but not part of your workflow.</p><p>To fix it, I increased the software context window to 32k tokens to let the model “think.” My GPU screamed to life, processing the prompt at a blistering <strong>92 tokens per second</strong>.</p><p>But then, the progress bar reset to zero.</p><p>A 14B model takes up roughly 9GB of VRAM just to sit idle. A 27,000-token prompt leaves absolutely no physical room left for the GPU’s memory tracker (the Key-Value cache). My 12GB graphics card hit a hard wall, panicked, and had to drop its memory payload back down to system RAM, grinding the processing speed down to a painful crawl.</p><p>At 92 tokens per second, it was going to take my modern, high-end GPU nearly <strong>five minutes</strong> of continuous, maxed-out mathematical calculation just to read and memorise three source code files and some project context before it could even begin typing a single word of a solution.</p><p>And that’s when the terror set in.</p><h4>Understanding vs. Tokenisation: The Organic vs. Silicon Cost</h4><p>Make no mistake: frontier cloud models are incredible. They generate excellent code, and they do it fast. There is no argument there. But because we only ever see the final code appear in seconds on a screen, we are completely detached from what it actually takes to get it there.</p><p>If you ask me a complex software architecture question, I will tap into my years of experience, cognitive frameworks, and fundamental understanding of logic. I can provide you with a highly accurate, nuanced answer in roughly 30 seconds. The biological cost of that computation? Thirty seconds of my time, and maybe two deep breaths of air. The human brain runs on about <strong>20 Watts</strong> of power — less than a dim incandescent lightbulb.</p><p>A frontier cloud model can give you that same answer in 10 seconds for a fraction of a cent. It feels incredibly efficient. It feels cheaper than my time.</p><p>But under the hood, the AI is not using a framework of understanding to find the answer. It doesn’t know what code is. Instead, it is utilizing massive tokenization of language — running brute-force matrix multiplication equations across hundreds of billions of parameters just to predict the most statistically probable next word. To compile a single line of code, it has to compute the mathematical relationships between <em>every single token against every other token</em> in your codebase, scaling quadratically (O(N²)).</p><p>Because it lacks the organic shortcuts of human understanding, it requires an obscene, terrifying amount of physical compute to appear intelligent.</p><h4>The $300,000 Hardware Umbilical Cord</h4><p>When we run queries in an enterprise environment, our prompts easily balloon to <strong>200,000 to 500,000 tokens</strong>. To shrink the search space and force the model to give a precise answer, the system has to ingest a massive mountain of organizational context: internal documentation, system architectures, team rules, formatting skills, and Model Context Protocol (MCP) integrations. To compress what would be a five-minute processing freeze into seconds, cloud providers route that massive payload directly to an enterprise data center cluster.</p><p>They aren’t using a desktop graphics card. They are using an <strong>Nvidia HGX H100 or H200 server node</strong>.</p><p>A single one of these server blocks contains 8 interconnected enterprise GPUs packing up to <strong>1,120 gigabytes of ultra-fast High-Bandwidth Memory (HBM3e)</strong> working in absolute synchronization. A single node costs roughly <strong>$300,000 to $350,000</strong> just to purchase — and large data centres string thousands of them together.</p><p>When you hit send on a multi-repo agent query, that single Nvidia node flashes to maximum capacity, drawing up to <strong>10,200 Watts of electricity</strong> simultaneously. For those few seconds of execution, your single prompt is pulling more power from the electrical grid than a street of a dozen residential homes.</p><p>Industry data shows that a normal, short text prompt uses about 0.3 Watt-hours (Wh). A 500k context query burns through <strong>350 to 500+ Watt-hours</strong>. But how many coding tasks end with just one query? Imagine a conversation going back-and-forth for 20 minutes to build out a new UI screen and some unit tests. How many Kilowatt-hours (kWh) did that session just take? Ten? Twenty? Easily. To put that in perspective, 20 kWh is nearly <strong>a full day’s worth of electricity</strong> for an entire American house, or <strong>almost half a week’s worth</strong> for a home in Europe.</p><h4>The Loss-Leader Economics of the AI Bubble</h4><p>If you are wondering why these extraordinary levels of computing power only cost you a flat $20 a month, the answer is simple: <strong>You are being heavily subsidised during an aggressive, venture-backed land grab.</strong></p><p>The financial records and leaked projections from major AI labs reveal staggering, unsustainable losses. Financial models show that market leaders like OpenAI are projected to lose roughly <strong>$14 billion a year</strong>, with cumulative losses expected to reach up to <strong>$115 billion by 2029</strong>. Reports indicate that these firms routinely lose over <strong>$1.20 for every single dollar they bring in</strong> on adjusted figures.</p><p>Worse yet, the entire model relies on a broken conversion ratio. Only about 5% of global users actually pay for a premium subscription. The other 95% are utilising heavy data centre compute completely for free — a cost entirely absorbed by venture capital and multi-billion dollar cash infusions from tech giants.</p><p>The industry is burning cash to hide the true cost of compute, racing to hook AI into your enterprise workflow, lock you into their ecosystem, and make your entire code infrastructure entirely dependent on their cloud endpoints before the bill catches up.</p><h4>The Hidden Macro Crisis: Nuclear Reboots and Grid Queues</h4><p>When you scale this brute-force tokenisation across millions of global developers, the infrastructure begins to warp.</p><p>Data centre electricity consumption in the US alone is projected to climb to an explosive <strong>30 to 35 Gigawatts by 2030</strong> — the equivalent of adding the entire power grid of Spain or Taiwan just to run computers. This astronomical demand is fracturing physical infrastructure in the real world:</p><ul><li><strong>The Power Source Conflict:</strong> Tech companies heavily market their investments in solar and wind, but AI data centres run 24/7/365. When the sun sets and the wind stops, these massive clusters rely on baseline grids. This skyrocketing demand has forced utility companies to delay closing old coal plants and actively build new natural gas facilities.</li><li><strong>Bypassing the Public Grid:</strong> The situation has gotten so severe that tech giants are completely abandoning public utilities. Companies like Microsoft, Amazon, and Google are signing historic contracts to buy 100% of the output from nuclear power plants — including restarting the decommissioned Three Mile Island nuclear facility — just to feed their AI clusters.</li><li><strong>The 7-Year Waiting List:</strong> In major data centre hubs like Northern Virginia or Ireland, physical capacity is exhausted. Tech companies are currently being told by utility providers that they must wait <strong>5 to 7 years</strong> just to get permission to plug new AI facilities into the physical power grid.</li><li><strong>The Hidden Water Footprint:</strong> Crunching a 500k context window generates extreme physical heat. To keep these AI chips from melting, data centres use massive liquid or evaporative cooling systems. A single large AI data centre facility can consume up to <strong>5 million gallons of water a day</strong> — the same water usage as a town of 50,000 people.</li></ul><h4>The Trap: Absolute Vendor Dependency</h4><p>And this is the true structural crisis waiting for the tech industry.</p><p>Non-technical executives are looking at highly polished, heavily subsidized cloud AI demos and making permanent, structural organizational changes based on an infrastructure illusion. They are laying off mid-level and junior engineering teams under the assumption that an automated agent can autonomously maintain and scale a corporate tech stack.</p><p>By firing the human pipeline, companies are destroying their own institutional memory. They are trading organic human understanding — which runs on 20 watts of power and decades of contextual experience — for a multi-million-dollar silicon umbilical cord that runs at a massive corporate loss.</p><p>When the venture capital dries up, or when the global energy grid hits its physical limit and cloud provider prices skyrocket to reflect the true, terrifying cost of massive data centre consumption, companies will have no fallback option. The human knowledge workers will have already been made redundant, and organisations will find themselves permanently tied into proprietary vendor AI systems with skyrocketing subscription costs, bloated AI-generated codebases, and too few experienced engineers left who actually understand how the foundation works.</p><p>We are drastically overestimating the current economic viability of automated engineering. If a modern, high-end desktop setup can be brought to its knees by a single layout button change, the industry isn’t ready for a skeleton crew. We are heading into an infrastructure trap, and right now, the tech world is running toward it full speed without a way out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ceeea3c74b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Infinite Monkey Theorem Is Obsolete. AI Has a Better One.]]></title>
            <link>https://nicbell.medium.com/the-infinite-monkey-theorem-is-obsolete-ai-has-a-better-one-0b0de44f22ba?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/0b0de44f22ba</guid>
            <category><![CDATA[computes]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 11:31:26 GMT</pubDate>
            <atom:updated>2026-08-06T11:51:02.936Z</atom:updated>
            <content:encoded><![CDATA[<p>For centuries, the infinite monkey theorem has been one of mathematics’ favourite thought experiments. Its premise is delightfully absurd: given an infinite number of monkeys and an infinite amount of time, one of them will eventually type the complete works of Shakespeare.</p><p>The theorem was never really about monkeys. It was about probability. Given unlimited random attempts, every finite sequence of characters eventually becomes inevitable. The experiment illustrates that randomness, combined with infinity, can produce any result.</p><p>For most of history, this was a reasonable way to think about exhaustive search. If you could search forever, you would eventually find the answer. But AI has fundamentally changed that picture. We no longer rely on random search — we build systems that perform guided search. That shift changes not only how we think about AI, but how we should think about intelligence itself.</p><h3>From Random Search to Guided Search</h3><p>Imagine the task is to write <em>Hamlet</em>. A monkey has only one strategy: press keys at random and hope that chance eventually produces Shakespeare. Every possible string of characters is equally likely, making success unimaginably improbable until infinity enters the equation.</p><p>A modern language model approaches the same problem differently. It begins with a remarkably strong prior — a statistical model of human language built from trillions of words. Rather than treating every possible continuation as equally likely, it concentrates its effort on continuations that resemble meaningful language.</p><p>That difference becomes even more pronounced once reasoning, external tools, retrieval, memory, and verification are introduced. Modern AI systems don’t simply generate an answer; they generate hypotheses, evaluate them, reject poor candidates, refine promising ones, and iterate. The search is no longer random. It is guided by probability, feedback, and increasingly sophisticated reasoning.</p><h3>Compute Is the New Resource</h3><p>The original theorem depended on infinite time. The AI version depends on compute.</p><p>Every additional unit of compute allows a model to explore more of the solution space. It can consider alternative approaches, reason more deeply, recover from mistakes, and verify intermediate results before producing an answer. Instead of waiting for luck, the system spends computation searching intelligently.</p><p>Coding agents demonstrate this particularly well. They don’t possess perfect implementations waiting to be recalled from memory. They write code, execute tests, inspect failures, modify the implementation, and repeat the process until the program behaves correctly. The solution emerges through iterative search rather than immediate recall.</p><p>This same pattern is becoming common across mathematics, scientific discovery, robotics, planning, and engineering. Increasingly, intelligence looks less like retrieving facts and more like navigating an enormous search space efficiently.</p><h3>Context Is Compressed Compute</h3><p>This perspective reveals something that initially seems counterintuitive: context is a form of compute efficiency.</p><p>Imagine asking an AI:</p><blockquote>Plan me a vacation.</blockquote><p>That’s an enormous search space. Should it recommend a beach or a city? A weekend or three weeks? Luxury or backpacking? Domestic or international? Travelling alone or with family? Does the person enjoy hiking, museums, nightlife, or relaxing by a pool?</p><p>The model must spend compute inferring preferences before it can even begin planning the trip.</p><p>Now compare that with:</p><blockquote>Plan a seven-day honeymoon in Italy for two people in late September. We enjoy food, history, and walking rather than beaches, have a budget of $6,000, and want to avoid changing hotels more than once.</blockquote><p>The model hasn’t become more intelligent. The problem has simply become much easier because the search space is dramatically smaller. Most possible itineraries can be discarded immediately, allowing the model to spend its compute refining a handful of good options instead of exploring thousands of poor ones.</p><p>A good prompt doesn’t contain magic words. It contains information. Every relevant constraint, preference, example, or objective eliminates branches of the search tree before the model begins reasoning.</p><h3>Knowledge Transfers Compute</h3><p>This leads to what I think is the more interesting principle:</p><p><strong>Knowledge transfers compute.</strong></p><p>When an experienced engineer writes a detailed prompt, they’re not demonstrating prompt-writing skill as much as they’re transferring years of accumulated knowledge. They already understand the domain, the constraints, the common failure modes, and the trade-offs that matter. That knowledge represents computation they have already performed over the course of their career.</p><p>Instead of forcing the model to rediscover those insights through search, they simply provide them as context. The AI begins much closer to the correct solution because less exploration is required.</p><p>This also explains why experts consistently obtain better results from AI than beginners. It’s tempting to believe they know secret prompting techniques, but in practice they usually possess something more valuable: a better mental model of the problem itself. They know which details matter because they understand how those details reshape the search space.</p><p>Seen through this lens, documentation, architecture diagrams, design specifications, examples, and institutional knowledge all become forms of computational optimisation. They reduce the amount of reasoning the AI must perform because someone has already done part of that work.</p><h3>The Updated Theorem</h3><p>The infinite monkey theorem can be reimagined for the age of AI:</p><blockquote>Given sufficient compute, a sufficiently capable model, and a reliable mechanism for verification, the probability of finding a correct solution approaches one as guided search continues.</blockquote><p>But the more useful extension is this:</p><blockquote><strong><em>For a fixed compute budget, better context increases the probability of finding the correct solution.</em></strong></blockquote><p>Or, stated more simply:</p><blockquote><strong><em>Better context buys compute. Poor context taxes it.</em></strong></blockquote><p>Every ambiguity forces the model to consider more possibilities. Every missing constraint creates additional branches in the search tree. Every piece of relevant knowledge supplied up front reduces the amount of computation required to reach a high-quality answer.</p><h3>A Different Way to Think About Intelligence</h3><p>The original infinite monkey theorem belongs to a world where randomness was the simplest explanation for exhaustive search. AI suggests a richer model.</p><p>Instead of imagining infinite monkeys typing forever, imagine an experienced engineer solving a difficult problem. They don’t consider every possible solution. They eliminate most of the search space before they begin, drawing on years of accumulated knowledge, experience, and pattern recognition. Their expertise doesn’t make them think harder — it allows them to think less.</p><p>AI works in much the same way. Compute powers the search, but context determines where the search begins. The more knowledge we transfer into the prompt — through constraints, examples, documentation, or domain expertise — the less search remains for the model to perform.</p><p>This has an important implication. Much of today’s conversation about AI focuses on using it more: more prompts, more agents, more reasoning, and more compute. But that may be optimising the wrong metric.</p><p><strong>The winners won’t be the people who use AI the most. They’ll be the people who give AI the least work to do while achieving the same outcome.</strong></p><p>Organizations with clear documentation, well-defined processes, structured knowledge, and shared context won’t just make humans more productive. They’ll make AI more efficient too. They’ve already done part of the computation, allowing the model to spend less time searching and more time solving.</p><p>The infinite monkey theorem taught us that infinite randomness eventually finds everything.</p><p>The AI version teaches something far more practical:</p><blockquote><strong><em>Intelligence isn’t just about searching more. It’s about reducing the amount of search required.</em></strong></blockquote><p>Or, more simply:</p><blockquote><strong><em>Compute explores the search space. Context shapes it. Knowledge shrinks it.</em></strong></blockquote><p>That’s not just a new version of the infinite monkey theorem.</p><p>It’s a new way to think about intelligence itself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0b0de44f22ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cognitive Density: The Hidden Cost of AI Productivity]]></title>
            <link>https://nicbell.medium.com/cognitive-density-the-hidden-cost-of-ai-productivity-1654b58ba6da?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1654b58ba6da</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Fri, 10 Jul 2026 15:07:12 GMT</pubDate>
            <atom:updated>2026-07-13T07:01:40.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TrHZJl4xxawrEx0c" /></figure><p>I started thinking about this while reviewing some AI-generated code.</p><p>The code itself wasn’t bad. In fact, it was surprisingly good. It implemented the feature correctly, followed our conventions, and would probably have taken me an hour or two to write myself.</p><p>What struck me wasn’t how quickly the code had been produced. It was how long it took me to become comfortable with it.</p><p>I still had to read it.</p><p>I still had to understand the assumptions it was making.</p><p>I still had to convince myself it solved the right problem, handled the edge cases, and wasn’t quietly introducing technical debt.</p><p>It occurred to me that AI hadn’t removed the work. It had simply moved it.</p><p>That led me to an idea I’ve been calling <strong>cognitive density</strong>.</p><p>I think cognitive density is the amount of context a person has to process, hold, and switch between over a given period of time. Looking back over the last twenty years of software engineering, it strikes me that almost every productivity improvement has increased cognitive density, even while making us individually more productive.</p><p>That’s why, despite better tools than ever before, so many developers finish the day mentally exhausted.</p><p>Not because they’re working longer.</p><p>Because they’re carrying more.</p><h3>Every productivity gain gets reinvested</h3><p>Every major communication tool arrived with the same promise: save time.</p><p>Email was faster than letters.</p><p>Instant messaging was faster than email.</p><p>Slack reduced the friction of asking questions.</p><p>Cloud collaboration removed waiting for documents.</p><p>Now AI can generate code, documentation, design ideas, SQL queries and test suites in seconds.</p><p>Each innovation dramatically reduced the cost of producing information.</p><p>What’s interesting is what happened next.</p><p>The time savings rarely became free time.</p><p>Instead, organisations quietly reinvested those gains into producing more.</p><p>If documentation became easier to write, we wrote more documentation.</p><p>If deployment became easier, we deployed more frequently.</p><p>If AI can generate five possible implementations instead of one, we don’t stop after reading the first — we review all five.</p><p>The capacity created by technology almost always gets consumed.</p><p>The workday stays roughly the same length.</p><p>The amount of context flowing through it doesn’t.</p><h3>Software engineering has become a context management problem</h3><p>Think about a fairly ordinary engineering day.</p><p>You’re implementing a feature when Slack pings with a question about an architectural decision made six months ago.</p><p>While answering that, GitHub notifies you that someone has requested a review on a pull request.</p><p>CI has failed on another branch.</p><p>A production alert appears.</p><p>Someone asks whether an AI-generated implementation looks safe to merge.</p><p>You return to your original feature and spend a few minutes remembering what you were thinking before you were interrupted.</p><p>None of these tasks are individually difficult.</p><p>The difficulty comes from carrying so many different mental models at once.</p><p>I don’t think cognitive density is the number of tasks you complete.</p><p>It’s the number of independent contexts your brain has to maintain simultaneously.</p><p>Writing a thousand lines of code inside one coherent feature may actually be lower cognitive density than reviewing three unrelated pull requests, debugging an intermittent production issue, discussing architecture in Slack and validating two AI-generated implementations.</p><p>The output might be smaller.</p><p>The mental load is much higher.</p><h3>We removed the waiting, but the waiting was doing something</h3><p>One thing I’ve realised is that software engineering used to have more natural pauses.</p><p>You’d submit a pull request and wait.</p><p>You’d kick off a build and make a coffee.</p><p>You’d email another team and expect a response tomorrow.</p><p>You’d wait for QA.</p><p>You’d wait for a deployment window.</p><p>At the time, those delays felt like inefficiencies.</p><p>Looking back, I wonder whether they were also providing something useful.</p><p>Those small pockets of waiting gave your brain permission to let go of one context before loading the next. Sometimes you’d stare out of the window. Sometimes you’d chat to a colleague. Sometimes the solution to the problem you’d been wrestling with for hours would simply appear halfway through making a coffee.</p><p>The pauses weren’t always interruptions to the work.</p><p>Sometimes they were part of the work.</p><p>Today’s tools have compressed almost all of that latency.</p><p>Slack expects an immediate response.</p><p>Pull requests appear instantly.</p><p>CI finishes quickly.</p><p>AI responds before you’ve finished thinking about the question you asked.</p><p>The next piece of work is ready before you’ve mentally finished the previous one.</p><p>We’ve become incredibly good at removing latency from our systems.</p><p>I’m not convinced we’ve considered what that latency was doing for the humans using them.</p><h3>AI amplifies cognitive density</h3><p>I don’t think AI is creating this problem.</p><p>I think it’s accelerating a trend that has been building for decades.</p><p>The obvious benefit of AI is that it produces things incredibly quickly.</p><p>The less obvious consequence is that every piece of output still has to be understood before it becomes useful.</p><p>As engineers, we don’t merge code because it exists.</p><p>We merge it because we understand it.</p><p>When I write a feature myself, I build the mental model incrementally. Every design decision follows naturally from the previous one because I made those decisions.</p><p>When an AI generates hundreds of lines of code, that mental model doesn’t magically appear in my head.</p><p>I have to reconstruct it.</p><p>Why did it structure things this way?</p><p>What assumptions has it made?</p><p>Is this solving the actual problem, or just the prompt I happened to write?</p><p>Will the next engineer understand this?</p><p>Unless you’re unusually brave, you don’t simply trust the output.</p><p>You validate it.</p><p>That validation is work.</p><p>AI has dramatically reduced the cost of generating code.</p><p>It hasn’t reduced the cost of understanding it.</p><p>In some cases, it has increased it, because the amount of code arriving for review has grown much faster than our ability to absorb it.</p><p>The bottleneck hasn’t disappeared.</p><p>It has moved from production to comprehension.</p><h3>Why we feel exhausted</h3><p>I think this explains a feeling that many software engineers have struggled to articulate.</p><p>You finish the day mentally drained despite never leaving your desk.</p><p>It’s easy to assume you weren’t productive because you didn’t write much code.</p><p>But perhaps that’s the wrong measure.</p><p>Perhaps what exhausted you wasn’t what you produced.</p><p>It was what you processed.</p><p>Every pull request you reviewed.</p><p>Every AI suggestion you evaluated.</p><p>Every Slack thread you dipped into.</p><p>Every production incident that interrupted your train of thought.</p><p>Every architecture discussion that required loading another mental model into working memory.</p><p>None of these things are particularly heavy on their own.</p><p>Together, they create an extraordinary cognitive load.</p><p>The workday hasn’t necessarily become longer.</p><p>It has become denser.</p><p>AI has amplified that density because it has increased the speed at which context arrives.</p><p>The machine can generate information faster than ever before.</p><p>The developer still has to understand it.</p><p>And perhaps that’s why so many of us end the day with the same feeling.</p><p>Not that we’ve done too much work.</p><p>But that we’ve carried too much context.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1654b58ba6da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Pivot of Erlich Bachman: AI Guru or Grifter 2.0?]]></title>
            <link>https://nicbell.medium.com/the-pivot-of-erlich-bachman-ai-guru-or-grifter-2-0-ee040a1751aa?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee040a1751aa</guid>
            <category><![CDATA[erlich-bachman]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Wed, 16 Jul 2025 09:43:30 GMT</pubDate>
            <atom:updated>2025-07-16T09:53:04.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VpED21rkRgheavhz.jpg" /></figure><p>After selling his stake in <em>Pied Piper</em> for a suspiciously low sum — rumoured to be just enough to fund a yearlong ayahuasca retreat in Bali — <strong>Erlich Bachman</strong> disappeared from Silicon Valley. Some assumed he’d finally flamed out. Others swore they saw him at a crypto rave in Tulum wearing a bathrobe and Crocs, claiming he invented the blockchain.</p><p>But three years later, at a minor tech conference in Fresno, he returned. Not with a beard or enlightenment — but with a pitch deck titled <strong>“Bachmanity 2.0: Artificial Intelligence, Organic Disruption.”</strong></p><blockquote><em>“We are not building </em>AI<em>,” he announced. “We are building </em>Erlich Intelligence™ — EI.<em> It’s artificial, but with swagger.”</em></blockquote><h3>The Pivot</h3><p>Erlich claimed he had trained a proprietary AI model on transcripts of his own conversations, VC calls, and episodes of <em>Entourage</em>. The result? An AI that could “pitch better than any founder, out-bluff any investor, and micro-dose empathy at scale.”</p><p>He called it <strong>“Brotocol™”</strong> — an LLM-powered chatbot that advises startup founders with confident, half-true bravado.</p><p>It had features like:</p><ul><li><strong>“Crush It Mode”</strong> — Spits out 10 VC-ready taglines regardless of product.</li><li><strong>“Pivot Panic Button”</strong> — Randomly generates new startup directions (“What if it’s Uber… but for AI ethics?”).</li><li><strong>“Disruptor’s Oracle”</strong> — Quotes Steve Jobs, but reworded so they avoid lawsuits.</li></ul><p>Investors were skeptical, until one demo blew minds. Brotocol advised a pre-seed founder to say:</p><blockquote>“We’re not solving a problem — we’re defining the next paradigm.”</blockquote><p>The room exploded in applause. Someone invested $3 million on the spot.</p><h3>Trouble on the Horizon</h3><p>Within months, <strong>Bachmanity AI</strong> was valued at $200M on paper. Erlich moved back into the incubator house, now rebranded as the <strong>“EI Compound.”</strong> It featured kombucha taps, an AI-generated mural of Elon Musk fighting Plato, and a 24/7 VC pitch simulation room.</p><p>But cracks showed:</p><ul><li>Brotocol once advised a founder to “acquire Apple or pivot to NFTs.”</li><li>The AI accidentally got hired by a Series A company and negotiated a better equity package than the human founders.</li><li>Users complained that the bot “negged” them into burnout.</li></ul><p>Meanwhile, Erlich was trying to raise a Series B, saying Brotocol could replace <strong>entire</strong> startup teams.</p><blockquote><em>“Who needs talent,” he said, “when you’ve got </em>tone<em>?”</em></blockquote><h3>The Fall (or the Next Pivot?)</h3><p>Eventually, regulators got involved. Something about “emotional manipulation as a service” being a grey area. Investors pulled out. The servers were sold for scrap. Brotocol lives on in a few obscure Discord servers where it now advises indie game developers and NFT artists.</p><p>Erlich? Unfazed. Rumour has it he’s working on a new product: <strong>“AI for AI” — a meta-startup where artificial intelligences advise each other.</strong></p><blockquote><em>“I call it </em>Recursive Grift™,<em>” he says. “And if that doesn’t work, I’ll pivot to AI-generated wine.”</em></blockquote><p>The valley may laugh, but they’ve done that before. And somehow, Erlich always ends up back on stage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee040a1751aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The New Normal: How Layoffs Became a Strategy, Not a Necessity]]></title>
            <link>https://nicbell.medium.com/the-new-normal-how-layoffs-became-a-strategy-not-a-necessity-697e91f9d8a1?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/697e91f9d8a1</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[layoffs]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Fri, 11 Jul 2025 13:12:20 GMT</pubDate>
            <atom:updated>2025-07-11T14:02:31.510Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been writing software professionally for nearly two decades. In that time, I’ve lived through the 2008 global financial crisis, the rise of social media and smartphones, multiple tech booms, a pandemic, and everything in between. I’ve seen companies struggle, adapt, and occasionally collapse under external pressures.</p><p>What I hadn’t seen — until recently — is layoffs becoming <strong>decoupled from economic reality</strong>.</p><p>Back then, when layoffs happened, you could usually trace a clear line between cause and effect. Revenue dropped. Market conditions changed. A merger happened. Even if you didn’t agree with the decision, you could understand why it was made.</p><p>But in today’s tech industry — especially in big tech — that clarity is gone. Mass layoffs have become a <strong>strategic instrument</strong>, not a desperate measure. Companies are reporting <strong>record-breaking profits</strong> and <strong>growing user bases</strong>, yet still cutting thousands of jobs. And the explanations? Vague, abstract, and often contradictory.</p><p>Companies recently are justifying layoffs making statements like:</p><blockquote>AI is changing everything, so we’re making changes too — exactly what changes, to whom, and for what measurable reason remains unclear, but trust us: it’s visionary.</blockquote><p>What does that actually mean? It’s always abstract enough to <strong>sound profound</strong>, but vague enough to <strong>justify almost anything</strong>.</p><p>Is AI costing them money, so they need to reduce staff?<br>Is AI making their teams more productive, so they need fewer people?<br>Is AI just the buzzword of the quarter, slapped on to justify a decision that was already made?</p><p>No one knows — and perhaps that’s the point.</p><h3>Layoffs as an Experiment</h3><p>What I’ve come to believe is this: mass layoffs in big tech have become <strong>normalised</strong> — and even <strong>experimental</strong>.</p><p>Historically, layoffs were tied to:</p><ul><li><strong>Clear financial distress</strong></li><li><strong>Restructuring due to mergers or acquisitions</strong></li><li><strong>Market downturns (like 2008 or the COVID-19 shock)</strong></li></ul><p>Now, companies post <strong>record profits</strong> and still <strong>cut thousands of roles</strong> — often white-collar, knowledge work in product, engineering, or marketing. The narrative has changed from “we can’t afford to keep these people” to:</p><ul><li>“We need to be more agile”</li><li>“We’re streamlining operations”</li><li>“We’re aligning resources with our long-term vision”</li></ul><p>In many cases, the <strong>business fundamentals haven’t worsened</strong> — they’re simply experimenting with headcount as a <strong>variable to optimise</strong>, not a <strong>responsibility to uphold</strong>.</p><p>Companies now cut large swaths of their workforce almost to <strong>see what happens</strong>. Will productivity drop? Will customers notice? Will engineers still hit deadlines? If not — great. The cost savings stick. If things do fall apart, they’ll rehire under a new org chart or a different strategy.</p><p>This logic is <strong>new</strong>, and it’s deeply unsettling.</p><p>It treats human beings as toggles in a spreadsheet. It assumes institutional knowledge is disposable. It values short-term optics — like boosting margins or impressing investors — over long-term resilience and trust.</p><h3>AI Is Just the Latest Excuse</h3><p>AI is the latest in a long line of justifications for cuts, following “pandemic over-hiring,” “market uncertainty,” and “macroeconomic headwinds.” But in many cases, it functions as a <strong>convenient narrative cover</strong>, not a real explanation.</p><p>The irony is that AI might actually require <strong>more talent</strong>, not less — especially in product, security, UX, and data ethics. But that nuance gets lost when the primary goal is to <strong>signal strategic focus</strong> or <strong>appease investors</strong>.</p><h3>What This Means for Workers</h3><p>For those of us in the industry, this shift has serious implications:</p><ul><li><strong>Job security is no longer tied to performance.</strong> Great reviews, big contributions, and loyalty don’t always matter.</li><li><strong>Transparency is disappearing.</strong> Companies are using visionary language to obscure basic operational decisions.</li><li><strong>Trust is eroding.</strong> Teams no longer feel confident that leadership is acting in good faith.</li></ul><p>More and more experienced professionals are stepping back and asking: <em>Is this sustainable? Is this ethical? Is this the industry I want to remain in?</em></p><h3>What Now?</h3><p>Some are choosing to leave big tech for smaller companies with clearer missions. Others are going freelance, consulting, or building their own businesses. Many are staying — but watching, warier than before.</p><p>Whatever path you’re on, one thing is clear: the conversation needs to change.</p><p>We can’t keep treating layoffs like routine maintenance. We can’t keep letting vague strategy statements justify real human loss. And we can’t afford to become desensitised to the toll this is taking on our industry’s people, culture, and future.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=697e91f9d8a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The strangest app that I ever built]]></title>
            <link>https://nicbell.medium.com/the-strangest-app-that-i-ever-built-688e95d20f1e?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/688e95d20f1e</guid>
            <category><![CDATA[window-mobile-application]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[windows-phone]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Tue, 12 Dec 2023 16:52:42 GMT</pubDate>
            <atom:updated>2023-12-12T18:00:54.347Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Umw8VxULuqxBO3S4Kya2iA.png" /></figure><p>In 2010, I was employed at a media agency located near Old Street in London. Among our esteemed clients was The Times newspaper, which had commissioned us to develop an online spelling bee. The spelling bee was primarily sponsored by Collins Dictionary and Microsoft. This captivating spelling bee was accessible both as a website and as an application for iPhones and iPod Touch devices.</p><p>At a certain juncture, a realisation within Microsoft surfaced regarding their sponsorship of an iOS application. It was then decided that we must, without question, develop a counterpart for mobile phones running Microsoft’s operating system.</p><p>Now lets dive a bit into what Microsoft’s mobile operating system was at the time. Windows Phone 7 had recently been announced but the first devices would only be available to purchase in nine months time. One of the things about working for a plucky little agency is you very rarely turn down a project or money. If we had chosen to wait nine months there is a good chance someone would change their mind, with this in mind we offered to build an application for whatever operating system was available at the time. This operating system was Windows Mobile 6.x.</p><p>Windows Mobile 6 was first released on February 12, 2007 it was based on Windows CE which had been around since 1996. Windows Mobile 6 was primarily used on business devices with a stylus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/240/0*c_fBA_gmzPgWKx5e.png" /><figcaption>Window Mobile 6.1</figcaption></figure><p>Windows Mobile received an update on April 1, 2008 called 6.1. This update had some performance improvements. One of the more notable devices to run this OS was the HTC Touch Diamond. HTC was one of a handful of vendors skinning Windows Mobile in order to improve it’s user experience. HTC’s skin TouchFLO 3D was the precursor to HTC Sense which would go on to improve the user experience of early versions of Android.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/0*nKv22Ihh3XXYCp6z.PNG" /><figcaption>Window Mobile 6.5</figcaption></figure><p>The last update to Windows Mobile 6 was 6.5 which was announced on May 11, 2009. It was kind of intended as a stopgap between Windows Mobile 6.1 and the newly announced Windows Phone 7. Along with launch of Windows Mobile 6.5, Microsoft launched the “<a href="https://en.wikipedia.org/wiki/Windows_Marketplace_for_Mobile">Windows Marketplace for Mobile</a>” which was a very primitive app store. Up until then there had been no real centralised marketplace to purchase apps for these devices. User’s had to ride their luck downloading and installing CAB files from the internet.</p><p>Interestingly the agency that I was working for actually had quite a bit of knowledge of these devices as one of our other clients was T-Mobile. The agency helped design operator skins for T-Mobile devices which were usually just rebadged HTC phones. This app would be the first official mobile app that I had ever built. I had previously dabbled in J2ME on feature phones a few years earlier, more specifically on one of the Motorola triplets, the V300.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*wrY3bOfmQkfy65BT.jpg" /><figcaption>Motorola V300</figcaption></figure><p>Now that the background story is set, lets get stuck into how this app was developed. My engineering background at the time consisted of a few years of Java and C# so <strong>.NET Compact Framework</strong> (.NET CF) was a logical choice over C++. Unfortunately for me this experience wouldn’t be entirely free of C++ but more about that later.</p><p>Windows Mobile devices exhibited a wide range of form factors and resolutions, presenting the challenge of determining what specifications to support. I wanted to establish an effective testing strategy to ensure compatibility across this diverse range of devices but it was near impossible to get usage stats for these devices. The best we could do is use websites such as XDA Forums and GSM Arena to gauge interest in various devices and then categorise them by hardware specs, resolution and OS version. Through research and prototyping, I concluded that supporting WVGA, VGA, and QVGA touch-enabled devices running Windows Mobile 6.x would be optimal. Given the rudimentary emulators, real device testing was essential. To address this, I asked for a budget to create a collection of devices with different specs, resolutions and OS versions. Fortunately, sourcing these devices second-hand at reasonable prices was possible through CEX. This allowed for thorough testing and broad compatibility of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*7LbAoVXW6ymildgCsH51Fg.png" /><figcaption>Spelling Bee on HTC Touch HD2</figcaption></figure><p>The build posed significant challenges, given that the .NET Compact Framework wasn’t designed for creating a sophisticated interface. To overcome this limitation, I developed a custom UI renderer. This renderer constructed a UI canvas capable of accommodating a collection of UI elements. Each UI element featured multiple sets of positioning coordinates for each resolution, along with images corresponding to different states and event handlers for gestures and taps. The canvas, upon capturing a screen gesture, executed a ‘hit test’ to route the event to the appropriate UI element. This allowed the element to handle the event and update its state accordingly. The UI canvas itself was also a type of UI element, this allowed screens to be composed of reusable chunks with their own canvases. It also made it easier to control which parts of the UI were invalidated and needed redrawing in a different state. Think of this a hybrid of Jetpack Compose and HTML image maps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*3_1wy3sH2OXWRYcR0kE91A.png" /><figcaption>Spelling Bee on HTC Touch 3G</figcaption></figure><p>The memory consumption of the UI render process was substantial. To mitigate this, I made a concerted effort to release resources or layers that were unnecessary or covered completely by other layers, aiming to free up memory. Despite these efforts, the application faced recurrent crashes due to out-of-memory exceptions on specific devices. Extensive debugging revealed a crucial factor — the garbage collector (GC) was not effectively reclaiming memory.</p><p>In the Common Language Runtime (CLR), the GC operates as an automatic memory manager. Contrary to immediate memory release, the GC runs when necessary, often triggered by system-reported memory thresholds. The perplexing issue arose with Samsung devices, which, despite being well-spec’d compared to other test devices, consistently encountered memory depletion problems. Upon closer inspection, it became evident that Samsung devices retained a significant portion of memory reserved for their own applications, inaccessible to other applications. Unfortunately, the GC lacked the awareness of this memory being reserved.</p><p>To resolve this challenge, the solution involved implementing a regular, manual invocation of garbage collection to ensure efficient memory management, particularly on Samsung devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Q30dGh_t27RordzI2pSAdQ.png" /><figcaption>Spelling Bell on Samsung Omnia II</figcaption></figure><p>Another significant challenge revolved around playing sound and typing answers, crucial elements for users, especially in the context of a spelling bee. At the time .NET CF did not support playing our sound files, the work-around for this was <a href="https://learn.microsoft.com/en-us/dotnet/standard/native-interop/pinvoke">P/Invokes</a> and hooking into certain unmanaged DLLs, with the expectation that these would be available on each device. I needed similar sorcery to disable auto-suggest when users typed in their answers.</p><p>Dealing with loading and drawing PNGs with alpha channels to achieve our rich UI involved navigating through the intricacies of unmanaged code. I won’t delve into the details to spare you the technical nuances of COM import, IImageFactory and “coredll.dll”. You’ve got Google for that.</p><p>While engrossed in the spelling bee project, another unexpected request surfaced — a sound-desk application for recording words and updating the word database. Opting for Java over .NET, I found it better suited for this task, thanks to its robust libraries for sound capture. The user interface, relatively straightforward, was crafted using Swing. 🤣</p><p>I believe I was the sole user of this app. Possibly one other person at Microsoft downloaded it to validate that we had completed the work. However, the agency received compensation, and I received my salary, for us the project was a successful venture despite its limited user base. Years later, I ventured back into mobile engineering, this time as an Android engineer. Even at its most challenging, the experience is notably more pain-free compared to the complexities encountered during this project.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNoJJbAH7Sc8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNoJJbAH7Sc8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNoJJbAH7Sc8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a81f0a3010dab48ba4a52ac8181c20bc/href">https://medium.com/media/a81f0a3010dab48ba4a52ac8181c20bc/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=688e95d20f1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing EmVeeAye]]></title>
            <link>https://nicbell.medium.com/introducing-emveeaye-34581e800ab4?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/34581e800ab4</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 18:47:11 GMT</pubDate>
            <atom:updated>2023-02-17T20:13:28.123Z</atom:updated>
            <content:encoded><![CDATA[<p>A micro-library containing some kind of MVI for Android, heavily inspired by everything but with much less stuff.</p><p>I wanted a YAGNI approach to MVI and unidirectional data flow using coroutines StateFlow. Instead of many separate classes, handling intents, producing actions, reducing and state emissions can happen inside the view model. Then just test the sequence of emission from the view model. Of course, if you use this library and like having lots of files and jumping around, by all means, enjoy yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uO6BqPzkd0ZXHHza.png" /></figure><h4>Intents vs actions</h4><p>How do these differ? What you want is not always what you get.</p><p>You’re feeling a bit sleepy, your intent is to have a cup of coffee. You handle your intent by checking to see if there is any coffee, after that your action may be to have a coffee or not have a coffee. One of these actions may reduce you to a less sleepy state, the other will leave you sleepy as well as disappointed.</p><p>This means the view model receives an intent, handles it and gets everything it needs to update the state then generates an action. The action is used to update the state via a reducer. (state, action) -&gt; new state. The view observes the state.</p><h4>Side effects</h4><p>I chose to follow the latest opinion from Google of a singular UI state object rather than separate states &amp; events (side-effects).</p><blockquote>UI actions that originate from the ViewModel — ViewModel events — should always result in a UI state update. — <a href="https://developer.android.com/topic/architecture/ui-layer/events#handle-viewmodel-events">Android Developer docs</a></blockquote><h3>Using the library</h3><p>State is a data class. Intents, actions are sealed classes. The view Model receives intents and transforms them to actions. Actions are used to update the state via a reducer function (state, action) -&gt; new state.</p><pre>class MyViewModel : MVIViewModel&lt;MyIntent, MyState, MyAction&gt;(<br>    initialState = MyState(),<br>    reducer = { state, action -&gt;<br>        when (action) {<br>            is MyAction.ShowContent -&gt; state.copy(data = action.data)<br>            is MyAction.ShowError -&gt; state.copy(error = action.error)<br>        }<br>    }<br>) {<br>    // You will need to implement `onIntent` to handle all your intents<br>    override fun onIntent(intent: MyIntent) = when (intent) {<br>        MyIntent.LoadContent -&gt; handleLoadContent()<br>        MyIntent.DoSomething -&gt; handleSomethingAction()<br>    }<br><br>    private fun handleLoadContent() = withState {<br>        updateState(MyAction.ShowContent(listOf(&quot;Test&quot;)))<br>    }<br><br>    private fun handleSomethingAction() = withState {<br>        updateState(MyAction.ShowError(&quot;I don&#39;t want to do anything.&quot;))<br>    }<br>}</pre><p>In your activity or fragment you can observe state changes.</p><pre>class MainActivity : AppCompatActivity() {<br><br>    private val vm: MyViewModel by viewModel()<br><br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        //..<br><br>        observeFlow(vm.state) { updateUI(it) }<br>    }<br>    //..<br>}</pre><p>If you like to have separate classes for reducer functions you can use those by implementing the Reducer type alias.</p><pre>class MyStateReducer : Reducer&lt;MyState, MyAction&gt; {<br>    override fun invoke(state: MyState, action: MyAction) = when (action) {<br>        is MyAction.ShowContent -&gt; state.copy(data = action.data)<br>        is MyAction.ShowError -&gt; state.copy(error = action.error)<br>    }<br>}<br><br>class MyViewModel : MVIViewModel&lt;MyIntent, MyState, MyAction&gt;(<br>    initialState = MyState(),<br>    reducer = MyStateReducer()<br>) {<br>    //..<br>}</pre><h4><strong>Saving state</strong></h4><p>The view model constructor accepts a SavedStateHandle which is null by default. When a SavedStateHandle is supplied the state is automatically restored and saved with each state update.</p><p>⚠️ Your state will need to implement Parcelable in order to be saved by SavedStateHandle.</p><pre>class MyViewModel(savedStateHandle: SavedStateHandle) : MVIViewModel&lt;MyIntent, MyState, MyAction&gt;(<br>    initialState = MyState(),<br>    reducer = { state, action -&gt; /**/ },<br>    savedStateHandle = savedStateHandle<br>) {<br>    //..<br>}</pre><h3>Testing</h3><p>The ViewModelTest class allows us to test the flow of state emitted from the view model.</p><pre>class MyViewModelTest : ViewModelTest() {<br><br>    private val vm = MyViewModel()<br><br>    @Test<br>    fun myTest() = runTest {<br>        // WHEN<br>        vm.onIntent(MyIntent.LoadContent)<br><br>        // THEN<br>        vm.state.assertFlow(<br>            MyState(),<br>            MyState(data = listOf(&quot;Test&quot;))<br>        )<br>    }<br><br>    @Test<br>    fun myTest2() = runTest {<br>        // WHEN<br>        vm.onIntent(MyIntent.DoSomething)<br><br>        // THEN<br>        vm.state.assertFlow(<br>            MyState(),<br>            MyState(error = &quot;I don&#39;t want to do anything.&quot;)<br>        )<br>    }<br>}</pre><p>Available on <a href="https://github.com/nicbell/EmVeeAye">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34581e800ab4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Grunt Setup Using NPM Scripts]]></title>
            <link>https://nicbell.medium.com/simplifying-grunt-setup-using-npm-scripts-8e9e9887d811?source=rss-85267dcf3fb4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e9e9887d811</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[grunt]]></category>
            <category><![CDATA[npm]]></category>
            <dc:creator><![CDATA[Nic Bell]]></dc:creator>
            <pubDate>Mon, 23 Nov 2015 16:08:01 GMT</pubDate>
            <atom:updated>2015-11-24T20:43:07.879Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Wednesday, 15 April 2015</strong></p><p>Before using Grunt we often need to run quite a few commands to install prerequisites and dependencies.</p><p>We would like to run <strong>grunt task:target</strong>, but before we can do that we may have to install Grunt, Bower or fetch dependencies. This may vary from project to project, so sometimes getting up and running can be quite a chore. Fortunately this problem can be easily solved by using NPM scripts.</p><p>When you run an NPM script it automatically runs <strong>pre</strong> and <strong>post</strong> hooks</p><pre>{ <br>  &quot;name&quot;: &quot;example&quot;, <br>  &quot;scripts&quot;: {<br>    &quot;pregrunt&quot;: &quot;npm i -g grunt-cli &amp;&amp; npm i,<br>    &quot;grunt&quot;: &quot;grunt&quot;<br>  }<br>}</pre><p>With this setup we need to run <strong>npm run grunt task:target </strong>which will automatically run <strong>pregrunt </strong>and install everything we need.</p><p>We can take it a step further by having a release build which leverages <strong>pregrunt</strong> to install our dependencies and <strong>postrelease </strong>to remove files that we do not want released.</p><pre>{   <br>  &quot;name&quot;: &quot;example&quot;,   <br>  &quot;scripts&quot;: {<br>    &quot;pregrunt&quot;: &quot;npm i -g grunt-cli &amp;&amp; npm i&quot;,<br>    &quot;grunt&quot;: &quot;grunt&quot;,</pre><pre>    &quot;release&quot;: &quot;npm run grunt -- release&quot;,<br>    &quot;postrelease&quot;: &quot;npm i -g rimraf &amp;&amp; rimraf node_modules &amp;&amp; rimraf .sass-cache&quot;<br>    }<br>}</pre><p>For this, all we need to do is run<strong> npm run release</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e9e9887d811" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>