<?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 Sindre Osen Aarsaether on Medium]]></title>
        <description><![CDATA[Stories by Sindre Osen Aarsaether on Medium]]></description>
        <link>https://medium.com/@sindreaars?source=rss-f454c04513a0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*l_FU5DkX2dUaLT1O.jpg</url>
            <title>Stories by Sindre Osen Aarsaether on Medium</title>
            <link>https://medium.com/@sindreaars?source=rss-f454c04513a0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 03:18:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sindreaars/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Virtual DOM is slow. Meet the Memoized DOM]]></title>
            <link>https://medium.com/free-code-camp/the-virtual-dom-is-slow-meet-the-memoized-dom-bb19f546cc52?source=rss-f454c04513a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb19f546cc52</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Sindre Osen Aarsaether]]></dc:creator>
            <pubDate>Sun, 18 Nov 2018 13:01:37 GMT</pubDate>
            <atom:updated>2018-11-19T10:11:56.672Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Virtual DOM is slow. Meet the Memoized DOM.</h3><h4>Moving beyond the Virtual DOM and State Management</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pVZO0k-L4J2H2q--LXiTfA.jpeg" /></figure><p>The virtual DOM was a fantastic innovation. It brought about a much more productive way of writing web applications by allowing us to write our views in a declarative manner.</p><p>This big benefit has little to do with performance of the initial render. Instead, it is the process of updating the DOM to reflect changes in your state has become much faster.</p><p>This process of bringing the DOM in sync with the state is often referred to as <a href="https://reactjs.org/docs/reconciliation.html">DOM reconciliation</a>.</p><p>If we had an infinitely fast reconciler, we could vastly simplify our applications by <strong>rendering everything on every single frame</strong>. The state layer would never need to know about views at all — much less send out events and track which views need to react when certain parts of the state change. The view would always be in sync with the data, no matter what you threw at it.</p><p>Sadly, virtual DOM implementations are <em>not</em> infinitely fast. They are, in fact, surprisingly slow. Thankfully, many have jumped on the Immutability™ bandwagon, in which case the virtual DOM thanks you! Others wrap all state in observables (e.g. mobx), and keep track of which view depends on what state. This allows you to reconcile only parts of your view, but comes with its own set of drawbacks.</p><p>The biggest issue is that we tend to decide how to manage our application state based on our view layer. What if we could get <strong>better</strong> performance in a world where the data layer and view layer don’t really know or care about each other?</p><h3>Meet the Memoized DOM</h3><p><a href="https://github.com/somebee/imba">Imba</a> is a programming language for the web. It powers the interactive screencasting platform <a href="https://scrimba.com/">scrimba.com</a>, of which I am the lead developer. Imba was born to make developing web applications fun again. It features a clean and readable syntax inspired by Ruby. It compiles to readable and performant JavaScript, and works inside the existing ecosystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwD6vakbORJiYCsD0NppHw.png" /><figcaption>The whole stack of scrimba.com is written in <a href="http://imba.io/guides">Imba</a>, but the language can easily be used just for the view layer.</figcaption></figure><p>Besides a clean and readable syntax, the biggest benefit of Imba is that it truly treats DOM elements as first-class citizens, on a much deeper level than JSX. It allows you to write views declaratively, yet it <strong>does not use a virtual DOM. </strong>Instead, Imba compiles views to a <strong>memoized DOM, </strong>which turns out to be <strong>an order of magnitude faster</strong>.</p><h4>How it works</h4><p>The general idea is that we create lightweight wrappers around DOM elements, and compile declarative views to chains of setters, each modifying the underlying DOM directly.</p><pre>tag AppView<br>    def render<br>        &lt;self&gt;<br>            &lt;h1.title&gt; &quot;Welcome&quot;<br>            &lt;p.desc .red=(Math.random &gt; 0.5)&gt; &quot;Roulette&quot;</pre><p>The Imba view above will roughly compile into the following javascript:</p><pre>class AppView extends Imba.Tag {<br>  render() {<br>    var $ = this.$; // inline cache for tag<br>    return this.setChildren($.$ = $.$ || [<br>      Imba.tag(&#39;h1&#39;,$).flag(&#39;title&#39;).setText(&quot;Welcome&quot;),<br>      Imba.tag(&#39;p&#39;,$).flag(&#39;desc&#39;).setText(&quot;Roulette&quot;)<br>    ]).synced(<br>      $[1].flagIf(&#39;red&#39;,Math.random() &gt; 0.5)<br>    );<br>  }<br>}</pre><p>This is a <em>very</em> simple example to illustrate the basic concept. During compilation we split creation and updates into separate branches. The first time render is called for an &lt;AppView&gt; the children will be created and static attributes will be set. On all subsequent calls the only real work we do is flip the className of our &lt;p&gt;. Albeit much more complex, the same concept is used for conditionals, loops, and everything else inside tag trees.</p><p>If you’re interested in how it really works I recommend reading <a href="http://imba.io/guides/advanced/performance#performance">this intro</a>.</p><h3>Benchmark</h3><blockquote>React is fast, they said. React is fast enough, they said. React Fiber will be fast enough, they said.</blockquote><p>Most benchmarks test things like “insert/shuffle/remove 1000 rows”. This gives little indication about real-world performance. When there are hundres of changes, most of the difference is eaten up by actual DOM mutations, repainting, etc. It fails to measure the most important metric.</p><p>If you truly want to test the performance of DOM reconciliation, you need to look at how quickly the implementation brings the DOM in sync with the state, <strong><em>especially</em> when there are few/no changes</strong>.</p><p>So, to capture a realistic view of the reconciler performance, we could change a small part of the application state in each iteration, and then measure the time it takes to forcefully bring the view in sync with this changed state. The view should not be listening to any part of the state, and the state should not need to notify anyone whether it has changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5xZq9eRVzoPHlOhGwq5JDQ.png" /><figcaption>Screenshot from <a href="https://somebee.github.io/dom-reconciler-bench/index.html">dom-reconciler-bench</a></figcaption></figure><p><a href="https://somebee.github.io/dom-reconciler-bench/index.html">This benchmark</a> steps through a deterministic sequence of state alterations, doing at most <strong>one change per iteration</strong>. We are measuring the time it takes to reconcile <em>the whole application view </em>after:</p><ol><li>Toggling the completion of a task</li><li>Removing a task</li><li>Inserting a task</li><li>Renaming a task</li><li>Doing nothing</li></ol><h3>Results</h3><p>Running the benchmark on an iMac (4GHz i7) yields the following results:</p><h4>Safari 11</h4><ul><li>Imba 1.3: <strong>360458</strong> ops / sec</li><li>React 16.2: <strong>9752</strong> ops / sec — <strong>36.96x slower</strong></li><li>Vue 2.5: <strong>8719</strong> ops / sec —<strong> 41.34x slower</strong></li></ul><h4>Chrome 65</h4><ul><li>Imba 1.3: <strong>282484</strong> ops / sec</li><li>React 16.2: <strong>8882</strong> ops / sec —<strong> 31.81x slower</strong></li><li>Vue 2.5: <strong>8103</strong> ops / sec — <strong>34.86x slower</strong></li></ul><h4>Firefox 58</h4><ul><li>Imba 1.3: <strong>234334</strong> ops / sec</li><li>React 16.2: <strong>5075</strong> ops / sec — <strong>46.17x slower</strong></li><li>Vue 2.5: <strong>3119</strong> ops / sec — <strong>75.13x slower</strong></li></ul><p>This seems outrageous right? Surely, it cannot be right.</p><ul><li>All implementations are <em>really</em> reconciling on every step.</li><li>All implementations are blocking, synchronous, and deterministic.</li><li>All implementations are performing the same amount of DOM mutations.</li><li>Yes, we are using the minified production build of React. The development version is <strong>200x slower</strong> than Imba on the same test.</li><li>The memoized DOM creates practically no garbage during an iteration, uses less memory overall, and is conceptually very simple.</li></ul><p>All the implementations can probably be optimized more. I’m very happy to accept pull-requests at <a href="https://github.com/somebee/dom-reconciler-bench">GitHub</a>. To be clear, I have tremendous respect for what React has achieved, and I truly love Vue. Imba has taken a lot of inspiration from it. I suspect it should be possible to compile Vue templates using a similar approach, and would love for someone to give it a go!</p><h3>Profiling</h3><p>Let’s test the raw reconciler performance when there aren’t even any changes. This removes the time spent doing actual DOM mutations from the equation, and gives us a good picture about how much work is going on during reconciliation. The charted CPU profile from Chrome gives a visual indication of how much less work is done with the memoized DOM technique.</p><h4>Imba 1.3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ej_xIBOEvBknOe_vyUebQ.png" /><figcaption>Imba completes 100000 iterations in 99.7ms — 5.1ms spent in GC</figcaption></figure><h4>React 16.2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7EH_HuGC3bc3vUut5MKNWA.png" /><figcaption>React completes 100000 iterations in 8312.7ms (83.4x slower) — 100.4ms spent in GC</figcaption></figure><h4>Vue 2.5</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjv3cwNr_ZcFQEVhAX3u6Q.png" /><figcaption>Vue completes 100000 iterations in 8514.7ms (85.4x slower) — 308.4ms spent in GC</figcaption></figure><h3>Does it scale?</h3><blockquote>“There are A LOT, and I mean, A LOT of small little projects that claim more speed, easier development, but on closer inspection usually lack very important features (such as module life cycle hooks) and, of course without them the performance is higher, but the flexibility to use those libraries beyond a todo list application is limited.”</blockquote><p>This is a quote from someone who read through an early draft of this article, and I would like to tackle it head on. The performance difference is not limited to a simple test, quite the contrary. <a href="http://imba.io/">Imba</a> has been used in production for several years at <a href="https://scrimba.com/">scrimba.com</a>, but it is still not for the faint of heart. For most developers the massive ecosystems for Vue and React will be hard (and probably unwise) to leave behind. The <a href="http://imba.io/guides/essentials/introduction">Imba documentation</a> still leaves a lot to be desired, but we are improving it every day.</p><h3>Does it matter?</h3><p>I’m sure you’ve heard that React is fast enough. But fast enough for what? It doesn’t really matter if React was 15% faster, but with an order of magnitude improvement we can start to explore simpler ways to build applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ql3LKXM42c1SznIkkr2fiA.png" /></figure><p>It’s not about the <em>perceived</em> speed, but about what it lets you do. At <a href="https://scrimba.com/">scrimba.com</a> we don’t worry about keeping the view in sync with the state. We don’t worry about tracking when state has changed. Our data models are not observable. We just render. Whenever. <strong>And it’s liberating.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb19f546cc52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/free-code-camp/the-virtual-dom-is-slow-meet-the-memoized-dom-bb19f546cc52">The Virtual DOM is slow. Meet the Memoized DOM</a> was originally published in <a href="https://medium.com/free-code-camp">We’ve moved to freeCodeCamp.org/news</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s new at Scrimba]]></title>
            <link>https://medium.com/scrimba/whats-new-at-scrimba-e38b9fd5ab7b?source=rss-f454c04513a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e38b9fd5ab7b</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[learn-to-code]]></category>
            <category><![CDATA[scrimba]]></category>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[release-notes]]></category>
            <dc:creator><![CDATA[Sindre Osen Aarsaether]]></dc:creator>
            <pubDate>Thu, 05 Apr 2018 10:01:08 GMT</pubDate>
            <atom:updated>2018-04-05T12:27:50.292Z</atom:updated>
            <content:encoded><![CDATA[<h4>Google slides support, better Q&amp;A section, updated design and much more!</h4><p>As we haven’t written an update like this since November, some of you have probably already seen some of these features. However, we still want to sum up the stuff we’ve released so far this year.</p><p>We’ve had amazing progress so far this year, both technically and business wise. 40K developers have signed up to <a href="https://scrimba.com/">Scrimba</a> to date, which we are super happy about, given that we had 5K users in December.</p><p>Let’s have a look at all the new awesome features.</p><h3>1. Import slides to your screencast</h3><p>We’re very excited to finally allow people to create slides. Just click <em>Import from Google slides </em>in the top right corner, and you’ll get your slideshow added to the screencast. This enhances the experience for students, as there are many concepts that are better explained through slides than by looking at code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56xj-mdKBaY0mrnAxEivAA.gif" /></figure><blockquote>This is actually the easiest way ever to record and publish a slide show with a voice over.</blockquote><p>We’re tracking the cursor inside the slideshow, so you can explain things in detail.</p><h3>2. Ask questions about specific code snippets</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HwA4GRLmlpAkn7kQwXfr7Q.gif" /></figure><p>This one is super cool. You can now ask questions directly related to specific lines of code. Just click ‘Ask a question’, select the code and write your question.</p><h3>3. Design brushup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rF8FHQLMSO_AAR4Luyk8IQ.png" /></figure><p>We’ve brushed up the overall design, especially on the front page, course pages and profile pages. There are still tons of things to fix on these, and this is just the first step in the direction we want to go.</p><h3>4. Download the project as a zip</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cKrCxzidIaJEeVqWc4TQWg.png" /></figure><p>A lot of users want to be able to play with the code locally as well, so we’ve added the ability to download a zip of the screencasts.</p><p>Note that we’re doing some webpack magic on NPM projects, so if we’re using NPM libraries, you’ll get a README which explains how to run it locally. This requires that you have Node installed, as you’ll need to do npm start.</p><p>We’ve added the toggling of console and browser at the left sidebar. This makes is easier for you to open and close them.</p><h3>6. Quick logging from the console</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SHSHP53xV_lsPR58qhc4nw.png" /></figure><p>We’re thinking a lot about how to give the best teaching experience here at Scrimba. And one of our constant concerns is how to make sure the teacher has enough space to display their code. This space is constantly being threatened by the console, the browser window and the sidebars. So we’ve added a feature which allows you to have your console closed while still seeing the values you log to it.</p><h3>7. Sidebar with metadata</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tr16g2TQt2PFgmjRfuBQSQ.png" /></figure><p>We’ve added a sidebar at the right hand side, which you can open and close as you want. It includes info about the creator, a description of the cast, your notes and the Q&amp;A section.</p><p>If you’re watching a course or a playlist, you’ll also see an overview of the other screencasts in the list here.</p><h3>8. Sign up via email</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAZkOGszHkRiH02ER1c91A.png" /></figure><p>A lot of people requested this, as not everybody use GitHub.</p><h3>9. Adjust font size</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8JJYzqn3fAbRnEoxbLgLdQ.png" /></figure><p>You can now adjust the font size on the screencast. This is perfect for people with bad vision, or if you’d simply prefer having larger fonts. Note that this isn’t just for the creator, but for the viewer as well. And the recorded cursor will still work properly in the editor as well, even though you’ve completely changed the size of the code. Magic, or what?</p><p>And that’s is! Thanks a lot for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e38b9fd5ab7b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/scrimba/whats-new-at-scrimba-e38b9fd5ab7b">What’s new at Scrimba</a> was originally published in <a href="https://medium.com/scrimba">Scrimba</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>