<?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 Darin Wilson on Medium]]></title>
        <description><![CDATA[Stories by Darin Wilson on Medium]]></description>
        <link>https://medium.com/@darinw?source=rss-19a644648b55------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*KfmHGbSEdINCFdBr5YHbrA.jpeg</url>
            <title>Stories by Darin Wilson on Medium</title>
            <link>https://medium.com/@darinw?source=rss-19a644648b55------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 08:49:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@darinw/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[A Step Toward Prompting Agents With Greater Precision]]></title>
            <link>https://shift.infinite.red/a-step-toward-prompting-agents-with-greater-precision-4a4b538bee21?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a4b538bee21</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[satire]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Fri, 16 Oct 2026 16:15:25 GMT</pubDate>
            <atom:updated>2026-10-16T16:15:25.141Z</atom:updated>
            <content:encoded><![CDATA[<p>As we all scramble to find our way through the new paradigm of agentic coding, the hype-versus-reality cycle is starting to become all too familiar.</p><p>We read a breathless post about how someone one-shotted a Postgres replacement using the latest hotness, promising that “this changes everything.” But when it comes to our own projects, the experience is quite different.</p><p>Incorrect feature implementations, broken UIs, hallucinations, all topped off by a huge monthly bill.</p><p>I’ve certainly struggled with this. And I’ve come to feel that the problem is not the models, but how we speak to them.</p><p>The unfortunate truth is that natural language is a clumsy tool for specifying how a piece of software should work. It’s ambiguous, verbose, and easily misunderstood. Humans can roll with this, but for coding agents, it’s another story.</p><h3>The Problem Illustrated</h3><p>Let’s take a classic programming exercise: scoring a game of bowling. Here’s what we might say to an agent:</p><blockquote>Write a function that calculates the score for a game of ten-pin bowling. The input is a list of how many pins the player knocked down on each ball.<br><br>A game has ten frames. In each turn, the bowler gets two tries to knock down all the pins. If they don’t knock them all down, the score for that frame is just the number of pins hit.<br><br>If the player gets all ten pins with both balls in a round, that’s a spare, and they get a bonus equal to the next roll. If they get all ten on the first ball, that’s a strike, and the bonus is the next two throws. In that case the frame is over and they don’t take a second shot.<br><br>Keep doing this for every frame, adding the scores up as you go.<br><br>The last frame is special. If the bowler gets a spare or strike in the tenth round, they get extra balls to finish calculating the bonus, but those extra rolls don’t count as frames of their own. Otherwise, calculate the bonus the same way as before.<br><br>Return the total.</blockquote><p>A human can make sense of it without no problem. But for an agent, even this simple description is rife with trip hazards:</p><h4>Nothing has a consistent name</h4><p>A single unit of play is called a frame, a turn, and a round, and delivery of the ball is a try, a ball, a roll, a throw, and a shot. The bowler is also the player. A human groks all this without thinking. An agent might invent multiple concepts for the same thing.</p><h4>Decisions are buried in prose</h4><p>The scoring logic is a decision tree: strike, spare, or open frame. But our prompt spreads it across three paragraphs, presents the cases out of order (spare before strike, though strike must be checked first), and buries a critical rule (“the frame is over”) in a trailing sentence. Then the tenth frame arrives with “otherwise,” which could refer to at least two different conditions.</p><h4>Looping is too loose</h4><p>“Keep doing this for every frame.” Doing what, exactly? Starting where? How does the position in the list of rolls advance? Too much logic is implied, and that’s a breeding ground for bugs.</p><h4>There’s no way to name and reuse behavior</h4><p>“Calculate the bonus the same way as before.” Which way? We described two bonuses. Natural language has no mechanism for describing behavior, and referring to it later by name. So we resort to pointing vaguely backwards.</p><p>It’s no wonder we’re often disappointed by what our agents produce.</p><h3>A Possible Solution</h3><p>After struggling with these issues over and over, I began experimenting with different ways to prompt agents with more precision. In time, the structure of my prompts settled into a specific format, which eliminated all of the issues described above, and added some unexpected side benefits.</p><p>Using this new specification language, here is how I would take the same exercise and prompt an agent to complete it:</p><pre>function isStrike(rolls, rollIndex) {<br>  return rolls[rollIndex] === 10;<br>}<br><br>function isSpare(rolls, rollIndex) {<br>  return rolls[rollIndex] + rolls[rollIndex + 1] === 10;<br>}<br><br>function strikeBonus(rolls, rollIndex) {<br>  return rolls[rollIndex + 1] + rolls[rollIndex + 2];<br>}<br><br>function spareBonus(rolls, rollIndex) {<br>  return rolls[rollIndex + 2];<br>}<br><br>function scoreGame(rolls) {<br>  let score = 0;<br>  let rollIndex = 0;<br><br>  for (let frame = 0; frame &lt; 10; frame++) {<br>    if (isStrike(rolls, rollIndex)) {<br>      score += 10 + strikeBonus(rolls, rollIndex);<br>      rollIndex += 1;<br>    } else if (isSpare(rolls, rollIndex)) {<br>      score += 10 + spareBonus(rolls, rollIndex);<br>      rollIndex += 2;<br>    } else {<br>      score += rolls[rollIndex] + rolls[rollIndex + 1];<br>      rollIndex += 2;<br>    }<br>  }<br><br>  return score;<br>}</pre><p>I call this language <strong><em>Exact Commands for Machine Agents</em></strong>, or “ECMA” for short. And it fixes all the problems with trying to communicate in natural language.</p><p>In my ECMA prompt, you can see that a roll is a “roll,” everywhere. Strike is clearly checked before spare, in order. The loop says exactly where it starts, when it stops, and how far to advance through the rolls after each kind of frame. The bonuses each have a name, so the agent doesn’t have to make sense of “the same way as before.”</p><p>And the whole paragraph about the tenth frame is gone. The bonus balls are simply extra entries at the end of the list. What was a special case is now another step in the flow. That’s what precision buys you.</p><h3>Even More Improvements</h3><p>Beyond just fixing the issues discussed above, ECMA brings a number of other improvements.</p><p>First, ECMA prompts are remarkably compact. In my testing, the program the agent produced was exactly the same length as the prompt, every single time.</p><p>Plus, you get deterministic results. Given the same ECMA prompt, agents will always produce the same program, with no temperature fluctuations and zero hallucinations.</p><p>Best of all, your monthly AI spend will plummet. I found that even the smallest, cheapest models can one-shot an ECMA prompt into correct working software, quickly and consistently. You can ditch your expensive frontier models, and run small local models for free.</p><h3>Next Steps</h3><p>I’m currently working on a v2 which will add optional type annotations. This will allow agents to know, for example, that rolls is a list of numbers, not strings. I’m thinking of naming that addition “TightSpec,” or TS for short.</p><p>I’ve also gotten some interest from colleagues about forming a standards committee to create a full specification. We’ll most likely name this after the language itself.</p><p>But you don’t have to wait to get started. Follow the example above and try using ECMA in your own prompts. I think you’ll be pleased with the results.</p><p>As our new tagline promises: “ECMA: <a href="https://www.commitstrip.com/en/2016/08/25/a-very-comprehensive-and-precise-spec/">Code. It’s called code.</a>&quot;</p><p><em>This is, admittedly, a bad idea. But Infinite Red has some good ideas about working with agents. Our team has been at the forefront of agentic coding since it first appeared on the scene, and we’ve helped our clients build tools and infrastructure to help them get the most out of what AI has to offer, without sacrificing quality, security, or maintainability. If you’d like to see what we can do for you, </em><a href="https://infinite.red/contact"><em>shoot us a message</em></a><em>, and let’s talk.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a4b538bee21" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/a-step-toward-prompting-agents-with-greater-precision-4a4b538bee21">A Step Toward Prompting Agents With Greater Precision</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You Don’t Need a Rewrite: Expo’s New Brownfield React Native Story]]></title>
            <link>https://shift.infinite.red/you-dont-need-a-rewrite-expo-s-new-brownfield-react-native-story-c072b4e971dd?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/c072b4e971dd</guid>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 21:28:40 GMT</pubDate>
            <atom:updated>2026-10-12T21:28:40.113Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IfRET4PadKEJRBZpHEVEnQ.png" /></figure><p>At the first Chain React conference in 2017, I was chatting with a developer named Tom.</p><p>He had been a native iOS developer almost from the very beginning, but he was attending Chain React because he was intrigued by what React Native had to offer, especially for the developer experience.</p><p>A single codebase for iOS and Android, live reloading, choice of editor, ease of switching web developers over to mobile: all of the these were strong enticements, even for someone as deeply entrenched in native development as he was.</p><p>But there was a problem: how to get from a fully-native codebase to a React Native codebase? This was possible in 2017, but it wasn’t easy or quick.</p><p>Fast-forward to today: things have changed.</p><p>As Expo’s Gabriel Donadel explained in <a href="https://www.youtube.com/watch?v=Yk5KjVx6i54">his talk at the 2026 Chain React conference</a>, there’s never been a better time to start integrating React Native into your native apps.</p><p>Starting with SDKs 54 and 55, Expo took a hard look at the brownfield problem. And they did what Expo has been doing ever since they first launched: identifying the pain points in the React Native ecosystem, and reducing or eliminating them entirely.</p><p>With the addition of <a href="https://docs.expo.dev/versions/latest/sdk/brownfield/">the official expo-brownfield package</a>, many of the challenges that used to hamper brownfield development are behind us, and things look very different than they did even just a couple of years ago.</p><p>So, armed with the knowledge that Gabriel provided at Chain React, let’s look at some myths and realities of brownfield app development with React Native.</p><p>And be sure to read to the end to find out how just five words can get you well on your way.</p><h4>Brownfield Myth vs Reality</h4><p><strong>MYTH</strong>: <em>Switching to React Native means doing a full rewrite of my app.</em></p><p><strong>REALITY</strong>: Screens built in React Native can sit comfortably side-by-side with fully native screens. In fact, this is how the first React Native apps got their start.</p><p>So you don’t need to start from scratch. You can start with just one screen, and build from there. And the expo-brownfield package makes this simpler than it’s ever been.</p><p><strong>MYTH</strong>: <em>I have to reorganize my app’s directory structure to accommodate React Native.</em></p><p><strong>REALITY</strong>: While this used to be true, as of Expo SDK 54, this is no longer a constraint. React Native integration is now much more flexible, so you don’t need to do any backflips to make room for React Native.</p><p>Now, React Native code adapts itself to your app, not the other way around.</p><p><strong>MYTH</strong>: <em>I want to be able to use Expo, but not all Expo packages support brownfield apps.</em></p><p><strong>REALITY</strong>: In SDK 54, the Expo team did a bug hunt to make sure that all Expo packages were brownfield-compatible. No more trade-offs needed.</p><p><strong>MYTH</strong>: <em>I would need to add a lot of new infrastructure to my app to start integrating React Native.</em></p><p><strong>REALITY</strong>: This is probably the biggest change in Expo SDK 55. Expo now supports two different ways to add React Native to a native app.</p><p><strong>Integrated:</strong> With the integrated approach, React Native code sits right inside your native app. This is traditionally how brownfield was handled, and it’s still a great option if you want to share native code with your React Native code, or if you have one development team working in a single codebase.</p><p><strong>Isolated:</strong> This is a new option with SDK 55. Instead of adding React Native code inside your native repo, you create a separate app with the functionality you want to add, and have it live inside its own codebase.</p><p>You develop the app using all the usual React Native tooling. When you’re ready to integrate it into the native app, you run a build command provided by expo-brownfield, which produces a fully native library containing your app’s functionality.</p><p>From there, you just add it to your native app like it was any other 3rd-party library. Your native engineers don’t even need to know that it was built with React Native!</p><p>Think of how you’d add any dependency that had its own UI, like a maps library. That’s exactly how the isolated approach works.</p><p>This is a great option if you have separate teams working on different parts of the app, and they would benefit from having their own release cadence.</p><p>It’s also a perfect way to get started if you’re just experimenting with adding React Native to see if you like it, as the changes to your native app are minimal, and easy to roll back.</p><p><strong>MYTH</strong>: <em>To start adding React Native, our native engineers would need to set up a full React Native environment on their dev machines.</em></p><p><strong>REALITY</strong>: Not any more. With the isolated approach, native engineers don’t need to worry about Node, yarn, Metro, or any other React Native underpinnings.</p><p>They just get the exported library from the React Native engineers, and add it directly to their Xcode or Android Studio projects. No muss, no fuss.</p><p><strong>MYTH</strong>: <em>I can get started with just 5 words</em></p><p><strong>REALITY</strong>: This one is actually not a myth! It’s 100% true.</p><p>Many of the steps needed to start integrating React Native are routine and can be automated. This makes them ideal for an agent to handle. The expo-brownfield team has made this even easier by developing an agent skill that does most of the work for you.</p><p>The skill:</p><ul><li>guides you through deciding whether the integrated or isolated approach is best for your use case</li><li>executes all the boilerplate integration steps</li><li>identifies and resolves any obstacles that come up one the way</li></ul><p>There’s a lot of hard-won knowledge built into that last point.</p><p>Gabriel and his team set an ambitious goal to use expo-brownfield to add React Native to <strong>100 open-source native apps</strong>. Each time they ran into an issue, they improved the package or added more knowledge to the skill. So your agent will have the benefit of all the bumps and bruises sustained by the Expo team, and will be ready for just about anything that comes up.</p><p>Just install the skill, and type this prompt: “add Expo to this app”. That’s it.</p><p>It’s definitely not 2017 anymore.</p><h4>Next Steps</h4><p>If you’ve been itching to start getting the benefits of React Native into your native app, now is the time. Expo is making sure that the process has never been easier.</p><p>Five words will get you started, so what are you waiting for?</p><p>For more info, watch Gabriel’s talk from Chain React, or <a href="https://docs.expo.dev/versions/latest/sdk/brownfield/">go straight to the docs</a>.</p><p>And if you need a little more help, or just want to talk through the trade-offs of native vs React Native, <a href="https://infinite.red/contact">please reach out to us</a>! Infinite Red has been deep into React Native and Expo for over a decade, and we have roots in native development going back even further than that. We’ve helped many companies integrate React Native and native development into their apps, and we can help you too. <a href="https://infinite.red/contact">Give us a call, or send us a message</a>, and we can get you going in the right direction.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FYk5KjVx6i54%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DYk5KjVx6i54&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FYk5KjVx6i54%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3779df0e4c28e294e6dcbaf0f8bb4d99/href">https://medium.com/media/3779df0e4c28e294e6dcbaf0f8bb4d99/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c072b4e971dd" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/you-dont-need-a-rewrite-expo-s-new-brownfield-react-native-story-c072b4e971dd">You Don’t Need a Rewrite: Expo’s New Brownfield React Native Story</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Legend State: The Fastest React State Library You’re Probably Not Using]]></title>
            <link>https://shift.infinite.red/legend-state-the-fastest-react-state-library-youre-probably-not-using-e791171a61b7?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/e791171a61b7</guid>
            <category><![CDATA[legend-state]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Mon, 14 Sep 2026 22:48:20 GMT</pubDate>
            <atom:updated>2026-09-14T22:48:20.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Illustration of a smart phone, with surrounding iconography suggesting speed and high-performance" src="https://cdn-images-1.medium.com/max/1024/1*alpsLPNIv6sbKesURpcYaA.png" /></figure><p>Jay Meistrich is on a mission.</p><p>He’s determined to get your React Native apps as fast as they can possibly be.</p><p>He first did this by creating Legend List, a super-optimized list component that <a href="https://github.com/LegendApp/legend-list#legend-list">boasts performance levels that rival even the venerable FlashList</a>.</p><p>But that wasn’t enough.</p><p>At <a href="https://www.youtube.com/watch?v=qcnqSldXZ08">his recent talk at Chain React 2026</a>, he explained that after working with multiple companies helping them improve performance, he realized that lists weren’t the biggest problem. It was something much more subtle.</p><p>It was state.</p><p>As it turned out, React’s built-in state support (useState, useContext) was often the source of serious performance problems.</p><p>The solution? As Jay said in his talk: “just use a state library”. There are many to choose from, and most will be an improvement over what ships with React.</p><p>But, Jay being Jay, he went out and built his own: <a href="https://legendstate.com">Legend State</a>, now in beta for version 3.0. In his talk, he discussed the problem with React state, and gave an impressive demo of how Legend State solves it.</p><h4>The Problem with useState</h4><blockquote>“The key to building the fastest apps is to minimize the amount of work that React and React Native do. That means having smaller renders, and rendering less often. useState and useContext are just fundamentally incompatible with that goal.” — Jay Meistrich</blockquote><p>The problem with useState is that it both creates <em>and</em> subscribes to state.</p><p>That sounds innocuous enough, but consider this example from Jay’s slides:</p><pre>function ChatScreen() {<br>  const [replyId, setReplyId] = useState(&#39;&#39;)<br><br>  return (<br>    &lt;View&gt;<br>      &lt;ChatMessages replyId={replyId} /&gt;<br>      &lt;ChatComposer replyId={replyId} /&gt;<br>    &lt;/View&gt;<br>  )<br>}<br><br>function ChatMessage({ id, replyId }) {<br>  const isReply = id === replyId<br><br>  // ...<br>}</pre><p>ChatScreen creates the replyId value, then passes it down to its children. But it’s now also <strong>subscribed</strong> to replyId. This means that it, and all its children, will have to re-render every time replyId changes, even though ChatScreen itself does nothing with replyId beyond passing the value.</p><p>ChatScreen doesn’t need to re-render when replyId changes; only the children that care about it need to re-render. But ChatScreen is forced to re-render regardless.</p><p>Compiler and memoizing can’t help, because the value is actually changing, and that forces the re-render.</p><p>useContext can sometimes help, but as Jay says “instead of going deep, it goes wide”. Every consumer of a context re-renders when any value inside it changes, whether or not the consumer uses the part that changed.</p><p>You can try to get around that by creating smaller, more-focused providers, but then you quickly end up with this all-too-familiar pattern:</p><pre>function App() {<br>  return (<br>    &lt;SomeProvider&gt;<br>      &lt;SomeOtherProvider&gt;<br>        &lt;YetAnotherProvider&gt;<br>          &lt;ThisWillBeTheLastOneProvider&gt;<br>            &lt;OkJustOneMoreProvider&gt;<br>              &lt;FinalFinalProvider&gt;<br>                &lt;SendHelpProvider&gt;<br>                  &lt;ActualApp /&gt;<br>                &lt;/SendHelpProvider&gt;<br>              &lt;/FinalFinalProvider&gt;<br>            &lt;/OkJustOneMoreProvider&gt;<br>          &lt;/ThisWillBeTheLastOneProvider&gt;<br>        &lt;/YetAnotherProvider&gt;<br>      &lt;/SomeOtherProvider&gt;<br>    &lt;/SomeProvider&gt;<br>  )<br>}</pre><h4>How Serious Of a Problem Is This Really?</h4><p>Potentially quite serious.</p><p>Jay ran a benchmark with three different implementations of a timer for a music app that updates four times a second.</p><p>In the first example, useState is called at the app root. In the second, it’s called in the middle of the tree, and in the third, in the leaf component:</p><pre>// App root<br>function App() {<br>  const [time, setTime] = useState(0)<br><br>  return (<br>    &lt;Window&gt;<br>      &lt;PlaybackArea time={time} /&gt;<br>      &lt;Playlist /&gt;<br>      &lt;BottomToolbar /&gt;<br>    &lt;/Window&gt;<br>  )<br>}<br><br>// Playback area:<br>function PlaybackArea() {<br>  const [time, setTime] = useState(0)<br><br>  return (<br>    &lt;View&gt;<br>      &lt;PlaybackTime time={time} /&gt;<br>      &lt;TheRestOfThePlaybackArea /&gt;<br>    &lt;/View&gt;<br>  )<br>}<br><br>// Leaf text:<br>function ElapsedText() {<br>  const [time, setTime] = useState(0)<br><br>  return (<br>    &lt;Text&gt;{time}&lt;/Text&gt;<br>  )<br>}</pre><p>In his benchmark, the “app root” version ran <strong>10 times slower</strong> than the “leaf text” version. So state is definitely something to consider when you’re thinking about performance.</p><h4>What Makes Legend State Different?</h4><p>To illustrate the difference, Jay showed a different example of a music app where the background color of a track in a playlist changes when it becomes the currently-playing track.</p><p>Here’s one solution that uses useState:</p><pre>function MusicApp() {<br>  const [playback, setPlayback] = useState(initialPlayback);<br><br>  return &lt;TrackList activeTrackId={playback.activeTrackId} /&gt;;<br>}<br><br>function TrackList({ activeTrackId }) {<br>  return tracks.map((track) =&gt; (<br>    &lt;TrackRowWrapper<br>      key={track.id}<br>      track={track}<br>      activeTrackId={activeTrackId}<br>    /&gt;<br>  ));<br>}<br><br>function TrackRowWrapper({ track, activeTrackId }) {<br>  const isActive = activeTrackId === track.id;<br><br>  return &lt;TrackRowView track={track} isActive={isActive} /&gt;;<br>}</pre><p>This example tries to mitigate the problem by computing the isActive boolean in the wrapper and passing that down instead. Assuming TrackRowView is memoized , the rows whose isActive didn’t change can then skip the render.</p><p>This helps, but there’s no avoiding that whenever setPlayback is called, MusicApp re-renders, TrackList re-renders, and so do all of the wrapper components in the list, even though all we really need to do is re-render two TrackRowView components: the one representing the previously-playing track, and the new one.</p><p>So how does Legend State handle this?</p><p>The fix Jay lands on is that <strong><em>state shouldn’t live in React at all</em></strong>.</p><p>In Legend State you create an observable (he notes some people call these “signals”), and the crucial difference is that <strong>creating state and subscribing to it are two separate operations</strong>:</p><pre>// creates the state<br>const playback$ = observable({<br>  tracks: [],<br>  activeTrackId: null,<br>});<br><br>function TrackRow({ track }) {<br>  const isActive = useValue(<br>    // subscribes *only* to playback$.activeTrackId<br>    () =&gt; playback$.activeTrackId.get() === track.id,<br>  );<br><br>  return (<br>    &lt;View style={[styles.row, isActive &amp;&amp; styles.activeRow]}&gt;<br>      &lt;Text&gt;{track.title}&lt;/Text&gt;<br>    &lt;/View&gt;<br>  );<br>}</pre><p>That $ suffix is just a naming convention meaning “this is an observable”. There’s no magic attached to it.</p><p>The observable (playback$ in this case) is stable. The nodes within it can be mutated by calling set() or assign(), but the observable itself does not change.</p><p>useValue is how we get notified when something in an observable changes, and consumers can subscribe to the specific parts of the observable that they care about:</p><pre>// ...<br><br>const isActive = useValue(<br>    () =&gt; playback$.activeTrackId.get() === track.id,<br>  );<br><br>// ...</pre><p>The passed-in function runs once at first, and the get() call subscribes us to future changes to playback$.activeTrackId.</p><p>When activeTrackId changes, the function is run again and isActive changes when the return value of the function changes. Only then does a re-render happen.</p><p>Consider a 500-track playlist. When activeTrackId changes, all 500 selector functions re-run, but each one is a single string comparison, executed outside of React. For 498 of them the result is unchanged, so React is never notified and no render is scheduled.</p><p>Only two components need to re-render: the old track and the new track, and nothing else. Legend State makes sure that’s exactly what happens.</p><h4>Going Even More Fine-Grained</h4><p>Then Jay pushes further, and this is where, by his own admission, things get strange.</p><p>In the previous example, when a track becomes active, a single background color changes, but the whole TrackRow re-renders to make that happen. And sometimes, even that is more than you want.</p><p>To solve this, Legend State ships reactive versions of the built-in components, prefixed with $, that accept reactive props:</p><pre>function TrackRow({ track }) {<br>  return (<br>    &lt;$View<br>      $style={() =&gt; [<br>        styles.row,<br>        playback$.activeTrackId.get() === track.id &amp;&amp; styles.activeRow,<br>      ]}<br>    /&gt;<br>  );<br>}</pre><p>Now TrackRow renders once, on mount, and never again.</p><p>When activeTrackId changes, only the $style function re-runs, inside a tiny wrapper component that Legend State inserts for you. Your component’s body doesn’t execute.</p><p>This approach changes the idea of what a component actually is. With this usage, it’s something that sets up the structure once but then never fully re-renders. Only smaller pieces within the component update themselves as specific pieces of data change over time.</p><p>Jay himself admits that the syntax of the high-performance features of Legend State “may look alien and very scary”, but it’s important to remember that the standard usage we saw in the last section is the default behavior, and it’s plenty fast.</p><p>But when you’ve got a hot-path component that needs more optimization, Legend State has options to help get you there.</p><h4>Going Further</h4><p>Beyond just performance, Legend State’s architecture enables a host of other features, which Jay touched on at the end of his talk:</p><ul><li>useObserveEffect is a replacement for useEffect that’s triggered by state updates, not renders. This makes your code easier to reason about, and gets rid of confusing and possibly performance-killing dependency arrays.</li><li>State changes carry not only the new value, but also the old value and the path into the state object where the change occurred. This enabled the addition of an undo/redo feature (added by Infinite Red’s own Jamon Holmgren!).</li><li>The detailed state changes also enabled the addition of a full offline-first sync engine, with your choice of backend. This is included in the library, with plugins for common backends, and very little code needed to set it up. But this, as Jay says, “is a whole other talk”.</li></ul><p>Jay goes into a lot more detail, so definitely check out the full talk below to get the big picture of what Legend State can do.</p><p>You may, like me, decide that Legend State will be a serious contender the next time you’re reaching for a state library.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FqcnqSldXZ08%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DqcnqSldXZ08&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FqcnqSldXZ08%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2e1c59ad512be40e4883dfea0fcd4e6/href">https://medium.com/media/f2e1c59ad512be40e4883dfea0fcd4e6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e791171a61b7" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/legend-state-the-fastest-react-state-library-youre-probably-not-using-e791171a61b7">Legend State: The Fastest React State Library You’re Probably Not Using</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Haptics in React Native: easier than you think]]></title>
            <link>https://shift.infinite.red/haptics-in-react-native-easier-than-you-think-2a6ecdcf078c?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a6ecdcf078c</guid>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[haptics]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Wed, 26 Aug 2026 18:58:17 GMT</pubDate>
            <atom:updated>2026-08-26T21:53:03.901Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Illustration of a smart phone vibrating. Around the phone are scattered notes and drawings with wave forms and concentric circles" src="https://cdn-images-1.medium.com/max/1024/1*9QfVxFTSkokqhskyEW9wow.png" /></figure><p>This post should probably come with a warning.</p><blockquote>WARNING: exploring haptics in React Native may lead to rabbit holes and excessive code tweaking.</blockquote><p>And yes, I’m speaking from experience here.</p><p>The truth is, before last month, I hadn’t spent much time working with haptics. I was aware of them, and I knew they were possible in React Native. I just hadn’t spent much time seeing what they could do.</p><p>But <a href="https://www.youtube.com/watch?v=GYQ85O7H_PQ">Kacper Kapuściak’s brilliant talk</a> at Chain React 2026 completely drew me in.</p><p>He demonstrated that haptics can have a big impact on your app, and it doesn’t take much effort to implement them. It’s a small-effort/big-reward feature, and we don’t get a lot of those in our business, so this is a topic worth exploring.</p><p>And Kacper provided a fantastic introduction.</p><h3>What are haptics?</h3><p>Haptic feedback provides physical responses on our devices, usually in the form of a small vibration, or series of vibrations.</p><p>Most of us are familiar with the obnoxious buzzing our phones emit when we get a phone call, but haptics on modern devices allow us to do much more. We can craft vibration patterns ranging from simple to complex, subtle to blaring, all of which help bring our apps to life.</p><p>When well-executed, haptics can even fool us. I was shocked when Kacper pointed out that the trackpad on recent Mac laptops don’t actually move down when you push for mouse clicks. The trackpad is solid: the clicking effect is done purely with haptics.</p><h3>And what are they good for?</h3><p>If all this sounds like some whiz-bang feature that’s all style and no substance, think again.</p><p>A <a href="https://academic.oup.com/jcr/article/52/5/1043/8120234">recent study</a> showed that adding a small amount of haptic feedback to an “add to cart” button in a grocery app led to a measurable increase in the number of items users added, and an increase in sales.</p><p>Other studies suggest that haptics can reduce errors when typing, and provide substantial help for users with visual, hearing, and motor impairments. Accessibility guidelines in the United States and Europe will likely increase their requirements for multi-modal feedback.</p><p>But the good news is that you can start getting all the benefits of haptics in your React Native apps today, with a lot less effort than you might think.</p><h3>Diving into haptics</h3><p>Kacper’s talk made me want to dig into this. So with the help of my trusty agent, I quickly assembled a small Expo app that would act as a haptics playground.</p><p>The app has a home screen that branches off to three mini-apps:</p><ul><li><strong>a simple counter</strong></li><li><strong>a todo list</strong></li><li><strong>a pong game</strong></li></ul><p>And if you’re thinking “ugh, these apps AGAIN?”, wait until you see how haptics give them new life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FVTi90-azMtVXdhYQCk_Ng.jpeg" /><figcaption>Screenshot of home screen of haptics demo app</figcaption></figure><p>You can find <a href="https://github.com/darinwilson/haptics-demo">the source code for this app on GitHub</a>. It includes a global switch so you can turn haptics on and off and see how it changes the end-user experience.</p><p>Once I had that working, it was time to start adding some buzzing and clicking and see what a difference they would make.</p><h3>Working with Pulsar</h3><p>Expo maintains its own haptics library, which provides platform-consistent access to the system haptic patterns provided by iOS and Android.</p><p>But I was intrigued by <a href="https://docs.swmansion.com/pulsar/">the Pulsar library</a> that Kacper described in his talk. Pulsar is a free, open-source, multi-platform library built and maintained by Software Mansion (Kacper’s employer, and the folks who brought you <a href="https://docs.swmansion.com/react-native-reanimated/">Reanimated</a>).</p><p>Pulsar gives you everything you get from Expo’s library, plus a lot more flexibility and customization. But these extras don’t introduce more complexity. Setting up Pulsar is as simple as it gets.</p><p>Just install the library using your preferred package manager (pnpm in my case):</p><pre>pnpm expo install react-native-pulsar</pre><p>Run prebuild (since we’ve just added a non-Expo package):</p><pre>pnpm expo prebuild</pre><p>And you’re ready to go.</p><p><strong>Note:</strong> To get the full experience of haptics, you’ll want to run the app on a physical device. Unfortunately, Expo Go is not an option, as Pulsar is not Expo-compatible, so you’ll need to create a development build. There are a few ways to do this, depending on your platform and how your dev environment is set up, but <a href="https://docs.expo.dev/get-started/set-up-your-environment/?mode=development-build">the official Expo docs</a> can walk you through it.</p><h3>Adding haptics to the counter</h3><p>The easiest way to get going with Pulsar is via their built-in presets. Let’s use this approach to add haptic feedback to the counter app.</p><p>Here are the two handlers for our increment and decrement buttons:</p><pre>// src/app/counter.tsx<br><br>// …<br><br>function incrementCount() {<br> setCount(count + 1);<br>}<br><br>function decrementCount() {<br> setCount(count - 1);<br>}<br><br>// …</pre><p>To add haptic feedback, we just import Presets from Pulsar and call the preset we’d like to use:</p><pre>// src/app/counter.tsx<br>import { Presets } from “react-native-pulsar”;<br><br>// …<br><br>function incrementCount() {<br> Presets.System.impactMedium();<br> setCount(count + 1);<br>}<br><br>function decrementCount() {<br> Presets.System.impactLight();<br> setCount(count - 1);<br>}<br><br>// …</pre><p>And that’s it.</p><p>The System module provides platform-specific feedback styles, common across iOS and Android. Here we’re using a slightly stronger pulse when incrementing.</p><p>But what about when we reset? We might want something a little more dramatic for that.</p><p>Fortunately, Pulsar gives us <strong><em>over 150 preset options</em></strong> beyond the standard system patterns. “Afterglow” feels like a good choice:</p><pre>// src/app/counter.tsx<br>import { Presets } from “react-native-pulsar”;<br><br>// …<br><br>function incrementCount() {<br> Presets.System.impactMedium();<br> setCount(count + 1);<br>}<br><br>function decrementCount() {<br> Presets.System.impactLight();<br> setCount(count - 1);<br>}<br><br>function resetCount() {<br> Presets.afterglow();<br> setCount(0);<br>}<br><br>// …</pre><p>With all these different preset options available out of the box, you might wonder: how do I choose which pattern to use? Pulsar has you covered.</p><p>The <a href="https://docs.swmansion.com/pulsar/presets-playground/">Presets Playground</a> gives you a list of all available presets, filterable by intensity, sharpness, shape, duration, and it even lets you feel each preset on your device if you download the accompanying app. Kudos to the documentation team for providing this level of detail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*6W6jj2weleS90C8AeTUDAw.jpeg" /></figure><p>So with that smorgasbord of options in front of us, let’s look at our pong game.</p><h3>Adding haptics to pong</h3><p>Here is where I got myself into trouble.</p><p>I knew I wanted a heavier tap when the ball hit the paddle compared to the wall. And I wanted to feel a real drop when I missed.</p><p>But I had a huge number of presets, and live reloading of the build on my phone with every save, so it’s not too surprising that I went down a rabbit hole of haptics options.</p><p>Is the wall bounce too soft? Maybe the paddle hit needs to be a little sharper. Maybe everything is heavier than it needs to be.</p><p>Tweak a line, save, feel the change on my phone. This was too much fun.</p><p>Here’s what I ended up with, just so I could move on and actually write this post. It’s not <em>exactly</em> right, and I’m sure I’m not done tweaking.</p><pre>// src/app/pong.tsx<br>import { Presets } from “react-native-pulsar”;<br><br>// …<br><br>useFrameCallback((frame) =&gt; {<br>  if (hitWall) {<br>    Presets.flick();<br>  }<br><br>  // …<br><br>  if (paddleHit) {<br>    Presets.push();<br>  }<br><br>  // …<br><br>  if (miss) {<br>    Presets.anvil();<br>  }<br>  <br>  // …<br>});<br><br>// …</pre><p><strong>Side note</strong>: if you’re familiar with Reanimated, this code might cause you to twitch involuntarily, but rest easy: all of Pulsar’s Presets functions are worklet-compatible, so it’s safe to run them within useFrameCallback.</p><h3>Going further</h3><p>This just gives you a small taste of what’s possible with Pulsar. To learn more about haptics in general, and to see some advanced capabilities of Pulsar (including how to make your own custom feedback patterns), check out Kacper’s talk from Chain React, linked below.</p><p>At the very least, try downloading and running the sample app to see what’s possible with adding touch to your app. Experiment with running the app with haptics on, then compare to having haptics off.</p><p>You may decide it’s the feature you never knew you needed.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FGYQ85O7H_PQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DGYQ85O7H_PQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FGYQ85O7H_PQ%2Fhqdefault.jpg&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbfc714a0d74526f38456bd51bd499b8/href">https://medium.com/media/bbfc714a0d74526f38456bd51bd499b8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a6ecdcf078c" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/haptics-in-react-native-easier-than-you-think-2a6ecdcf078c">Haptics in React Native: easier than you think</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Phoenix LiveView Round-Up: The Story So Far]]></title>
            <link>https://shift.infinite.red/phoenix-liveview-round-up-the-story-so-far-3cbb1648e940?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cbb1648e940</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[liveview]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Fri, 03 May 2019 17:53:15 GMT</pubDate>
            <atom:updated>2019-05-09T13:41:42.362Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NrP3-mWzENkrO1-wXoqHOg.png" /></figure><p>At last year’s ElixirConf, <a href="https://twitter.com/chris_mccord">Chris McCord</a> stunned the keynote audience when he announced <a href="https://github.com/phoenixframework/phoenix_live_view">LiveView</a>: a library for the Phoenix web development framework that would allow developers to perform real-time client-side updates using server-side Elixir.</p><p>Building upon the robust real-time communication provided by Phoenix channels, and the blazingly fast template rendering on the server, LiveView makes it possible to create user experiences that previously could only be accomplished with JavaScript. But now we can do it entirely with Elixir.</p><p>(If you need a refresher on LiveView, see <a href="https://shift.infinite.red/phoenixs-liveview-client-side-elixir-at-last-2280716ae791">this blog post</a> that sums up the ElixirConf announcement).</p><p>LiveView was still in development at the time, but six weeks ago, Chris finally made the repo public, apparently succumbing to the throngs of developers who were eager to try it out:</p><h3>Chris McCord on Twitter</h3><p>Phoenix LiveView is now public as we work towards our first release! I don&#39;t think my inbox could take any more messages asking for access :D https://t.co/EhV2hKlWrI</p><p>Folks jumped on it quickly, and in a few short weeks, we’ve seen an impressive array of demos and tutorials that more than deliver on the potential we saw at ElixirConf.</p><p>In this post, we’ll take a look at a few of the projects that have popped up in these early days of this promising new tech.</p><p>And as you’re looking these over, bear in mind that <strong><em>the developers wrote absolutely no JavaScript to make them work!</em></strong></p><h3>Demos</h3><p>A lot of fun demos started appearing shortly after the first release.</p><p><a href="https://github.com/bigardone">Ricardo García Vega</a> created an ant farm consisting of 500 server-rendered ants:</p><figure><a href="https://phoenix-liveview-ant-farm.herokuapp.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a47Mi-XWPcAoXfZff5NwoQ.png" /></a></figure><p><a href="https://twitter.com/mmmries">Michael Ries</a> built an SVG editor that renders the image in real-time as you type:</p><h3>Michael on Twitter</h3><p>Built an SVG tool with @elixirphoenix LiveView with renders as you type. Handling user updates and server-side updates in the same module makes the code really cohesive. https://t.co/IQkNK6Jfae #myelixirstatus https://t.co/hvZClPfUqD</p><p>Erlang’s observer tool (which shows you the internals of an app running on the BEAM) got a fresh new look from <a href="https://twitter.com/_zorbash/">Dimitris Zorbas</a>:</p><h3>Dimitris Zorbas on Twitter</h3><p>I made a port of observer_cli for the web using LIveView. Demo: https://t.co/cvFS7QWWiW Source: https://t.co/ArYuKvEUkz #phoenix #liveview #myelixirstatus https://t.co/GYkUwCnzJP</p><p>And <a href="https://github.com/nickdichev">Nick Dichev</a> put together a real-time markdown editor:</p><figure><a href="http://markdown.dichev.io/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfFZFu1vBNYY-wq_vx_kJA.png" /></a></figure><h3>Games</h3><p>Thanks to the efficiency of Phoenix’s channels and rendering engine, LiveView has proven to be performant enough to create simple games.</p><p>Richard Taylor implemented a Flappy Bird clone:</p><h3>Richard Taylor on Twitter</h3><p>Had fun making this Flappy Bird clone using @elixirphoenix LiveView. UI updates render in real time from the server. #myelixirstatus https://t.co/9H1jzPx4Zy</p><p>And <a href="https://github.com/neslinesli93">Tommaso Pifferi</a> recreated the classic Breakout game:</p><figure><a href="https://breakoutex.tommasopifferi.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XbQjtbvztIzm-J7RyIqWbw.png" /></a></figure><p>The programming model for LiveView appears to be quite straight-forward, as even self-proclaimed “Elixir newbies” are getting in on the fun.</p><p>Like Dan Carlo Maglasang with his multi-player Black Jack game…</p><h3>Dan Carlo Maglasang on Twitter</h3><p>Built a BlackJack game without using javascript! My first stab at using @elixirphoenix #LiveView. Just a POC so there may bugs :P . #myelixirstatus https://t.co/B4myOnEUHA</p><p>…and Milada Majáková with her Hippo game:</p><h3>Milada on Twitter</h3><p>my first project in #PhoenixFramework and #LiveView: https://t.co/uy3zAMQG2v https://t.co/UsJGMA7k0s #MyElixirStatus @ElixirPhoenix https://t.co/tgSMyoAqG4</p><h3>Tutorials</h3><p>If these demos have inspired you to give LiveView a try, there are some great tutorials to help get you started.</p><p><a href="https://twitter.com/dnsbty">Dennis Beatty</a> has two tutorials available, <a href="https://dennisbeatty.com/2019/03/19/how-to-create-a-counter-with-phoenix-live-view.html">one which shows just the basics with a simple counter example</a>:</p><figure><a href="https://dennisbeatty.com/2019/03/19/how-to-create-a-counter-with-phoenix-live-view.html"><img alt="" src="https://cdn-images-1.medium.com/max/480/1*a0Fp2ZAg8JbJGZkhAnRZGg.gif" /></a></figure><p>And another <a href="https://dennisbeatty.com/2019/04/24/how-to-create-a-todo-list-with-phoenix-liveview.html">more detailed tutorial that creates a multi-client todo list</a>:</p><figure><a href="https://dennisbeatty.com/2019/04/24/how-to-create-a-todo-list-with-phoenix-liveview.html"><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uITU42APGrkXbMEStK-YDQ.gif" /></a></figure><p>ElixirCasts also has a <a href="https://elixircasts.io/phoenix-live-view">3-part series on LiveView</a> (the first two are free, but the third requires a subscription):</p><figure><a href="https://elixircasts.io/phoenix-live-view"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfQ6DtuUSOawA9KSICFbtA.png" /></a></figure><h3>More?</h3><p>This is by no means an exhaustive list of what’s out there. If you want even more examples, <a href="https://twitter.com/leandrocesquini">Leandro Cesquini Pereira</a> is maintaining <a href="https://github.com/leandrocp/phoenix-liveview-collection">a Github repo with a list of demos and repos</a> that put LiveView through its paces.</p><p><strong>Edit: </strong>In the comments, <a href="https://medium.com/@dimitrisplusplus/awesome-write-up-6af5020adbab?source=post_info_responses---------2---------------------">Dimitris</a> Zorbas (creator of Observer Live, shown above), mentioned that he’s also curating <a href="https://tefter.io/zorbash/lists/phoenix-liveview-examples">a list of examples and demos</a> so be sure to check those out as well.</p><p>And finally, I strongly recommend watching Chris McCord’s keynote from the recent ElixirConf EU conference. He goes into more specifics about LiveView’s programming model, and how it’s implemented under the hood. The details are fascinating and possibly even more impressive than the demos themselves.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8xJzHq8ru0M%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8xJzHq8ru0M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8xJzHq8ru0M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/babe9c52e2e7f68bc6143726d5e2bd4e/href">https://medium.com/media/babe9c52e2e7f68bc6143726d5e2bd4e/href</a></iframe><p>We’re still in the early days of LiveView. It is not yet at a 1.0 release, and much could change before it does. But what we’re seeing so far is really exciting.</p><p>Ready to dive in? Check out the Github repo and have at it. And be sure to post a link to your creation in the comments!</p><p><a href="https://github.com/phoenixframework/phoenix_live_view">GitHub - phoenixframework/phoenix_live_view: Rich, real-time user experiences with server-rendered HTML</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*oItsIkZCCVCtsLo6Z3xyxA.jpeg" /></figure><p>Darin Wilson is a principal software developer at <a href="https://infinite.red/">Infinite Red</a>, a web and mobile application company, and the co-author of <a href="https://pragprog.com/book/wmecto/programming-ecto">Programming Ecto, published by Pragmatic Bookshelf</a>. You can find him as <a href="http://twitter.com/darinwilson">@darinwilson</a> on Twitter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cbb1648e940" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/phoenix-liveview-round-up-the-story-so-far-3cbb1648e940">Phoenix LiveView Round-Up: The Story So Far</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing “Progamming Ecto”: Your Tour Guide for the Ecto Database Library]]></title>
            <link>https://shift.infinite.red/introducing-progamming-ecto-your-tour-guide-for-the-ecto-database-library-949f97e2fc2e?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/949f97e2fc2e</guid>
            <category><![CDATA[books]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[ecto]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Mon, 22 Apr 2019 16:36:58 GMT</pubDate>
            <atom:updated>2019-04-22T16:36:58.133Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introducing “Programming Ecto”: Your Tour Guide for the Ecto Database Library</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bv3mEtg57Nm9WbR2sPMTUw.jpeg" /></figure><p>I am pleased and proud to announce that <em>Programming Ecto</em>, the book I co-authored with <a href="https://twitter.com/emjii">Eric Meadows-Jönsson</a>, is officially complete and available through <a href="https://pragprog.com/book/wmecto/programming-ecto">Pragmatic Bookshelf</a>!</p><p>Wondering what’s it all about? Read on to find out how the book came to be, and what you can expect to find inside.</p><h3>Where It All Began</h3><p><a href="https://github.com/elixir-ecto/ecto">Ecto</a> is a database library for the Elixir programming language. It’s included with the <a href="https://phoenixframework.org/">Phoenix web development framework</a>, so that’s where a lot of developers (including me) first encounter it, but it’s independent of Phoenix and you can use it in any Elixir application that needs to access a relational database.</p><p>When I first starting learning Ecto, I felt like there was a gap in the learning materials I found at the time. There were some talks online, but they were high-level and talked about Ecto’s capabilities in a general way.</p><p>I started reading through the excellent documentation that ships with Ecto, but looking over the alphabetical listing of modules, I couldn’t quite figure out the best place to start.</p><p>I realized I was looking for something in between: something that gave me the rooftop view of how all the pieces fit together, and guided me toward using Ecto in the most optimal way.</p><p>As I started to wrap my head around Ecto, I decided to try to help fill that gap. Armed with my 20/20 hindsight, <a href="https://www.youtube.com/watch?v=QE7bpqpDoKo">I gave a talk at ElixirConf</a> that presented the learning path I had taken, in the hopes that other folks might find it useful.</p><p>Apparently, it worked. After the talk, I got an email from Bruce Tate, the series editor for the Elixir books at <a href="https://pragprog.com/">Pragmatic Bookshelf</a>, asking if I might be interested in expanding the talk out to a book.</p><p>I was bowled over, and, to be honest, a little intimidated. But I decided to give it a shot, and I set a goal: to try to produce the book that I would have wanted to read when I first started learning Ecto.</p><h3>The Newbie And The Expert</h3><p>I was nervous about trying to write the book on my own, so Bruce very wisely suggested that we invite Eric Meadows-Jönsson, the creator of Ecto and member of the Elixir core team, to come onboard as co-author. I was excited and relieved when Eric said yes, and the two of us chatted over video calls to work out a book structure we could pitch to Pragmatic.</p><p>Eric and I had widely different experiences with Ecto at that point, but in retrospect I think those differences helped the book immensely.</p><p>I brought the newcomer’s perspective, as the memory of trying to learn Ecto was still fresh in my mind. Eric, on the other hand, had been working on Ecto since the beginning, so he had deep knowledge of all the nooks and crannies, and how they were designed to work.</p><p>He brought another important insight: he had been providing support for Ecto through Github issues, mailing list questions, forum posts and the like, so he knew what kinds of things developers usually tripped over, and the questions that got asked most often.</p><p>With those two perspectives put together, we got to work.</p><h3>What’s Inside</h3><p>We eventually settled on a two-part structure. Part 1 is all about giving you a solid foundation in Ecto’s fundamentals. We walk you through each of the major modules one-by-one and explain what they’re for, how they work, and how they fit together.</p><ul><li>Repo</li><li>Query</li><li>Schema</li><li>Changeset</li><li>Transactions and Multi</li><li>Migration</li></ul><p>Each chapter builds on the previous one, and we build up your knowledge piece by piece.</p><p>We start with the Repo module and show what can be done with just that module alone. Then we add the Query module, and work with just those two. We then integrate the rest of the modules one at a time, so you can see how the pieces fit together without having to keep too many new things in your head at once.</p><p>Every step of the way, you’re learning in the most effective way possible: by writing code yourself. The book comes with a sample application that works right out of the box and tons of code examples you can type right into IEx while you read. This helps you get Ecto’s API into your fingers right from the get-go.</p><p>And if you’ve used Ecto before, some of this might feel like review, but many of our beta readers mentioned that they picked up some new tricks reading through this section, so you might be surprised!</p><p>Part 2 is, as one reviewer put it, a “choose your own adventure”. We look at number of different use cases that often come up in database programming and show you how to take the tools you learned in Part 1 to make these use cases work.</p><p>We look at things like asynchronous testing, custom database types, polymorphic associations, working with JSON columns, Phoenix integration, and many others (see <a href="https://pragprog.com/book/wmecto/programming-ecto">the table of contents</a> for a complete list).</p><p>This section is much less sequential than Part 1, so you can skip around and tackle the problems that are most relevant to what you’re working on right now.</p><h3>But, why not just read the docs?</h3><p>A number of people have asked me this over the course of the project, and it’s a fair question, given that the docs for Ecto are about as good as you’ll find anywhere.</p><p>I think that answer has to do with what the docs are focused on, as well as the sheer size of Ecto. The docs are great at answering the question “What does this function do?” but not necessarily “Where do I start?” or “How does this all fit together?”</p><p>If we were to compare learning Ecto to learning your way around a new city, the docs are sort of like a phone book: very useful, but not necessarily the first thing you’d reach for when you arrived on your first day.</p><p><em>Programming Ecto</em> is more like a tour guide: someone who can show you around, explain how everything is laid out, and help you get the most out of your time spent there.</p><p>And once you’ve acquired all of that knowledge, the phone book starts to be a lot more useful.</p><h3>Check It Out</h3><p>The book is available for sale now at the <a href="https://pragprog.com/book/wmecto/programming-ecto">PragProg website</a>, and <a href="https://www.amazon.com/Programming-Ecto-Database-Scalability-Performance/dp/1680502824/ref=sr_1_1?keywords=programming+ecto&amp;qid=1555611727&amp;s=gateway&amp;sr=8-1">Amazon</a>.</p><p>And if you’d like to get more details, head over to the <a href="https://pragprog.com/book/wmecto/programming-ecto">book’s web page</a>. There you’ll find a detailed chapter listing, reviews, and some excerpts from the book that you can download and read for yourself.</p><p>If you have any questions, you can find <a href="https://twitter.com/emjii">Eric</a> and <a href="https://twitter.com/darinwilson/">me</a> on Twitter, and there’s <a href="https://elixirforum.com/t/programming-ecto-pragprog/13287/32">a dedicated topic page for the book on the Elixir Forum web site</a>.</p><p>Whether you’re brand new to Ecto, or you’d just like to learn how to use it more effectively, we’re hoping that <em>Programming Ecto</em> will give you what you need to take your Ecto skills to the next level.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6lA17JF_q9eM1C2SYunYQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=949f97e2fc2e" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/introducing-progamming-ecto-your-tour-guide-for-the-ecto-database-library-949f97e2fc2e">Introducing “Progamming Ecto”: Your Tour Guide for the Ecto Database Library</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Phoenix’s LiveView: Client-Side Elixir At Last?]]></title>
            <link>https://shift.infinite.red/phoenixs-liveview-client-side-elixir-at-last-2280716ae791?source=rss-19a644648b55------2</link>
            <guid isPermaLink="false">https://medium.com/p/2280716ae791</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[phoenix-framework]]></category>
            <dc:creator><![CDATA[Darin Wilson]]></dc:creator>
            <pubDate>Tue, 11 Sep 2018 20:46:29 GMT</pubDate>
            <atom:updated>2018-09-12T23:57:36.771Z</atom:updated>
            <content:encoded><![CDATA[<h4>Well, not exactly. But what they <em>have</em> done is pretty freaking amazing, so read on.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NrP3-mWzENkrO1-wXoqHOg.png" /></figure><p>In his <a href="https://www.youtube.com/watch?v=Z2DU0qLfPIY">keynote at ElixirConf last week</a>, Chris McCord announced a new feature for the <a href="https://phoenixframework.org/">Phoenix web framework</a> that caused many jaws to hit the floor, and had the hall buzzing when the talk was over.</p><p>The new feature, tentatively called “LiveView”, allows developers to add dynamic, client-side interactions to web pages, using code that runs in Elixir on the server.</p><h3>Wait…what?</h3><p>If that doesn’t immediately make sense, let’s take a step back and consider the problem.</p><p>Think of a registration form on a web page. We want to provide immediate feedback to our users when the information they’re providing is missing or incorrect. We don’t want them to have to fill out the entire form, submit it to the server, then wait for a complete page re-render to discover they made an error. We’d like to provide feedback right away.</p><p>Nowadays to do that, we turn to JavaScript. And for many developers, this quickly turns into a bewildering array of questions: should we use a framework for this? If so, which one? How should we bundle up the JavaScript: webpack, or some other tool? And everyone is saying we should be using ES6, so how do we set that up?</p><p>That seems like an awful lot of work just to be able to say “Email address is required.”</p><p>And even if we do all that work, we can’t rely solely on client-side validation to maintain data integrity. So we have to duplicate the validation logic on the server to protect against an attacker sneaking in bad data.</p><p>To work around <em>that</em>, we’re told to put the whole app logic into the front end, and simply have the back end expose an API. But not everyone is going to want to do that. For those of us who love Elixir, we’d like to be spending more time in Elixir, not less.</p><p>Of course there are some apps that need, or would greatly benefit from, a front end implemented completely in JavaScript. But that’s not every app. Many (possibly most) work well with pages rendered on the server, with realtime interaction added where it makes sense.</p><p>For these apps, LiveView looks like it would be a perfect fit. In our experience at Infinite Red, just about every web app we’ve built that used Ember or React could instead have used LiveView, and it might have saved a mountain of work.</p><h3>So What Is It Exactly?</h3><p>The project hasn’t been released yet, so we don’t have any code to look at, other than what Chris showed in the presentation. But as near as I can tell, a LiveView is lot like a <a href="https://reactjs.org/">React component</a> running in a <a href="https://hexdocs.pm/elixir/GenServer.html">GenServer</a> — it even has a render function! And with the EEx sigil (which I didn’t know was a thing) the code feels a lot like JSX:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKGq2VW1JYEVS8Suh6TA8A.png" /><figcaption>Server-side clock demo — the ~E sigil provides HTML-safe EEx</figcaption></figure><p>A LiveView has a persistent connection to the web page via <a href="https://hexdocs.pm/phoenix/channels.html">Phoenix channels</a>, and it can respond to events coming from the client, or from the server. Changing any part of the LiveView’s state triggers a call to the render function, and the LiveView pushes the updated view code down the wire to the client. LiveView uses DOM diffing, so the updates are as efficient as possible.</p><p>The demos included the classic React-style Clock app (shown above), but instead of the timer running on the client, it ran in a LiveView on the server, and pushed the updated time to the client every second.</p><p>Chris also showed the form validation example discussed earlier, but in this example, the LiveView responded to the key press events, and the server handled validation and sent error messages back down to the client.</p><p>This means that <strong>we can take the same changesets we use in our contexts and controllers to perform realtime client-side form validation.</strong> That’s pretty amazing.</p><h3>Can This Actually Scale?</h3><p>Time will tell, of course, but LiveView is built on solid ground. Phoenix channels have been part of the framework for a few years. And stateful processes running on a server has been OTP’s bread and butter for the past two decades. Once again, Elixir benefits greatly from all the amazing tools that Erlang and the BEAM provide.</p><h3>But Is It Fast Enough?</h3><p>Oh my, yes.</p><p>The Phoenix channels implementation is super efficient, and Phoenix’s template rendering is blazingly fast. With these two working together, updates on the client appeared instantaneously during the demos.</p><p>But the real “are-you-kidding-me” moment happened when Chris showed off an animation that ran at 60FPS, <em>completely driven by the server.</em> He set a timer in the LiveView that went off every 16ms and pushed updated div tags down to the client. It worked perfectly, and the animation was completely smooth.</p><p>Chris was quick to point out that this is not something that you’d actually want to do, but this definitely helps validate the scaling story. If you watch nothing else in this keynote, <a href="https://youtu.be/Z2DU0qLfPIY?t=2445">watch this section</a> (it starts around 40:45).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*T_fR6E-NywaQUXMXSjAOPA.gif" /></figure><h3>So Is Phoenix Trying To Kill JavaScript?</h3><p>Not at all.</p><p>Chris stated several times that there are some types of apps that LiveView won’t be good at. For things like SPAs, apps with offline support, apps that rely on native browser features, etc you’ll still want to use JavaScript.</p><p>But for apps that rely mostly on the server and just need realtime feedback for certain interactions, LiveView presents an option we didn’t have before. We’ll be able to provide users with a rich, responsive experience, without having to split our logic into two different platforms. I can only imagine that this will make code easier to write, easier to reason about, and much easier to test.</p><h3>Can I Start Using This Now?</h3><p>Nope. Nothing is publicly available yet. The Phoenix team is currently focused on getting Phoenix 1.4 released, so we probably won’t see anything until sometime after that.</p><p>Currently, the plan is that LiveView will not be part of the Phoenix core. It will be a separate package and have separate versioning. The name and implementation are all subject to change, so it could end up looking very different than what I’ve described here.</p><p>In the meantime, you should definitely check out Chris’ keynote. My descriptions don’t do this feature justice — when you see it in action, you’ll likely be as excited as I am to start putting it to work.</p><p><strong>[UPDATE]:</strong> Some readers correctly pointed out that LiveView is very close to <a href="https://tg.pl/drab">Drab</a>, which is already quite mature, but takes a slightly different approach. There’s <a href="https://elixirforum.com/t/drab-and-liveview-community-oddities/16483/11">a great discussion of both these libraries on ElixirForum</a>, which includes José Valim and Tomek Gryszkiewicz (the creator of Drab).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FZ2DU0qLfPIY%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DZ2DU0qLfPIY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FZ2DU0qLfPIY%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e96a3dd8c124f5a2a0e62092612c7d8/href">https://medium.com/media/2e96a3dd8c124f5a2a0e62092612c7d8/href</a></iframe><p><strong>Need help with your Phoenix project?</strong> Infinite Red has three years of production Elixir experience. Go to <a href="https://infinite.red/elixir-phoenix">https://infinite.red/elixir-phoenix</a> to learn more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/120/1*-0BcD5o1PB7Gjns6x1KBQw.jpeg" /><figcaption><a href="https://medium.com/u/19a644648b55">Darin Wilson</a> is a web and mobile developer at <a href="https://infinite.red">Infinite Red</a>, and co-author of the book <a href="https://pragprog.com/book/wmecto/programming-ecto">Programming Ecto</a>, published by Pragmatic Bookshelf. You can reach him as @darinwilson in all the usual places.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2280716ae791" width="1" height="1" alt=""><hr><p><a href="https://shift.infinite.red/phoenixs-liveview-client-side-elixir-at-last-2280716ae791">Phoenix’s LiveView: Client-Side Elixir At Last?</a> was originally published in <a href="https://shift.infinite.red">Red Shift</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>