<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>that one thing that one time</title>
        <link>https://blog.anp.lol</link>
        <description>ramblings by Adam Perry</description>
        <generator>Zola</generator>
        <language>en</language>
        <atom:link href="https://blog.anp.lol/rss.xml" rel="self" type="application/rss+xml"/>
        <lastBuildDate>Mon, 02 Dec 2019 00:00:00 +0000</lastBuildDate>
        
            <item>
                <title>moxie: incremental declarative UI in Rust</title>
                <pubDate>Mon, 02 Dec 2019 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/moxie-intro/</link>
                <guid>https://blog.anp.lol/rust/moxie-intro/</guid>
                <description>&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;moxie.rs&quot;&gt;moxie&lt;&#x2F;a&gt; is a small incremental computing runtime focused on efficient declarative UI, written in
Rust. moxie itself aims to be platform-agnostic, offering tools to higher-level crates that work on
specific platforms. Most applications using moxie will do so through bindings between the runtime
and a concrete UI system like the web or a consumer desktop platform.&lt;&#x2F;p&gt;
&lt;p&gt;The general goal of moxie is to empower Rustaceans to write UI code &amp;quot;generically with respect to
time,&amp;quot; describing the state of the UI &lt;em&gt;right now&lt;&#x2F;em&gt; for any value of now. This can be seen in some
code samples below, and I&#x27;ll discuss how this works further down.&lt;&#x2F;p&gt;
&lt;p&gt;This post has been forming for a while, and I find myself finally getting to it thanks to Raph&#x27;s
&lt;a href=&quot;https:&#x2F;&#x2F;raphlinus.github.io&#x2F;ui&#x2F;druid&#x2F;2019&#x2F;11&#x2F;22&#x2F;reactive-ui.html&quot;&gt;thought-provoking post on reactive UI&lt;&#x2F;a&gt;. I&#x27;ll discuss a bit of how I view &lt;a href=&quot;https:&#x2F;&#x2F;moxie.rs&quot;&gt;moxie&lt;&#x2F;a&gt;&#x27;s approach to 
declarative UI in Rust and how the project fits into the mental model Raph explores in his post.&lt;&#x2F;p&gt;
&lt;p&gt;A few months before writing this I &lt;a href=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=tmM756XZt20&quot;&gt;gave a talk at RustConf 2019&lt;&#x2F;a&gt; which covers many
similar concepts and subjects, and a &lt;a href=&quot;https:&#x2F;&#x2F;youtu.be&#x2F;QKbdBwjra5o?t=1299&quot;&gt;version of it with Q&amp;amp;A at the SF meetup&lt;&#x2F;a&gt;. If 
you&#x27;re reading this you may also find them interesting.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;bindings&quot;&gt;Bindings&lt;a href=&quot;#bindings&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;h2 id=&quot;moxie-dom-demo&quot;&gt;moxie-dom demo&lt;a href=&quot;#moxie-dom-demo&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The most mature user of it today is &lt;a href=&quot;https:&#x2F;&#x2F;crates.io&#x2F;crates&#x2F;moxie-dom&quot;&gt;moxie-dom&lt;&#x2F;a&gt;, a crate for defining web applications in pure Rust
using WebAssembly.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#maturity&quot;&gt;1&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;The web is pretty cool. Here is a counter built with moxie-dom, embedded into an iframe. You can 
click the button and watch the count climb! Wow! &lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#forget-iframe&quot;&gt;2&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; &lt;&#x2F;p&gt;
&lt;iframe src=&quot;https:&#x2F;&#x2F;moxie.rs&#x2F;dom&#x2F;examples&#x2F;hacking&#x2F;index.html&quot;&gt;&lt;&#x2F;iframe&gt;
&lt;p&gt;Here&#x27;s &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;anp&#x2F;moxie&#x2F;blob&#x2F;0faa65f7bd6d32670c1c42242a5bcfbb8e86dd84&#x2F;dom&#x2F;examples&#x2F;hacking&#x2F;src&#x2F;lib.rs#L12-L25&quot;&gt;the code&lt;&#x2F;a&gt; for that:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#ffffff;&quot;&gt;
&lt;span style=&quot;color:#4d4d4c;&quot;&gt;moxie_dom::boot(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;document&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;().&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;body&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;().&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(), || {
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; count &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;state!(|| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;);

    mox! {&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&amp;gt;
        &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;div&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;% &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;hello world from moxie! ({})&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;count }&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;div&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;

        &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;button &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;type&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;button&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; 
          on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;move &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;|_&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;: event::Click&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; count.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;update&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;c&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c99e00;&quot;&gt;Some&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(c &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;+ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;))}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;increment&amp;quot;
        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;button&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
    &amp;lt;&#x2F;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;};

    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;for&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; t &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;in &amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;first&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;second&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;third&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;] {
        mox! { &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;div&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;% &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;{}&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;, t }&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;div&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;};
    }
});
&lt;&#x2F;span&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In this example, the &lt;code&gt;state!&lt;&#x2F;code&gt; variable on the second line and the &lt;code&gt;mox!&lt;&#x2F;code&gt; macro with quasi-XML syntax
are both provided by the core moxie crate and can be shared between arbitrary UI &amp;quot;backends.&amp;quot;&lt;&#x2F;p&gt;
&lt;p&gt;Each time the button is clicked, the closure in &lt;code&gt;boot&lt;&#x2F;code&gt; runs in entirety but if you open your
browser&#x27;s devtools on the iframe, you should see that only the necessary DOM nodes are seeing
updates:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;video controls muted src=&quot;&#x2F;img&#x2F;moxie-dom-counter.mp4&quot;&gt;&lt;&#x2F;video&gt;&lt;&#x2F;p&gt;
&lt;p&gt;In addition to &lt;code&gt;moxie-dom&lt;&#x2F;code&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rebo&quot;&gt;rebo&lt;&#x2F;a&gt; has been working on an interesting experiment to reuse a portion
of moxie&#x27;s core logic to add &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rebo&#x2F;proof_of_concept_seed_hooks&quot;&gt;hooks to the Seed web framework&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;moxie-native&quot;&gt;moxie-native&lt;a href=&quot;#moxie-native&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;My earlier experiments with moxie were aimed at desktop applications without any web dependency, and
this is something I know many in the Rust community are eager to see come together. In that vein, 
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tiffany352&quot;&gt;Tiffany&lt;&#x2F;a&gt; Bennett has a very new project called &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tiffany352&#x2F;moxie-native&quot;&gt;moxie-native&lt;&#x2F;a&gt; which is exploring the use of moxie 
and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;servo&#x2F;webrender&quot;&gt;WebRender&lt;&#x2F;a&gt; to create desktop UI. These Windows and Linux screenshots:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;img src=&quot;&#x2F;img&#x2F;moxie-native-calc-demo-linwin.png&quot; 
     alt=&quot;WIP screenshots of moxie-native on windows and linux from nov 2019&quot;&gt;&lt;&#x2F;p&gt;
&lt;p&gt;are produced from &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tiffany352&#x2F;moxie-native&#x2F;blob&#x2F;630801c764eaf92a4e2f4f4b811347f6d88ad5f8&#x2F;examples&#x2F;calc.rs#L129-L196&quot;&gt;this code&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#ffffff;&quot;&gt;
&lt;span style=&quot;color:#8959a8;&quot;&gt;use &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;moxie_native::prelude::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;*&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;;

&lt;&#x2F;span&gt;&lt;span style=&quot;color:#999999;&quot;&gt;&#x2F;&#x2F; eliding definitions for CalcState, Message, etc...

&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;topo&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;nested&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;]
#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;illicit&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;from_env&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(state: &amp;amp;Key&amp;lt;CalcState&amp;gt;)]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;calc_function&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;message&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;: Message) -&amp;gt; Node&amp;lt;Button&amp;gt; {
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;clone&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;();
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; on_click &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;move &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;_event: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;ClickEvent&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;update&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(|&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;state&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#c99e00;&quot;&gt;Some&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;process&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(message)));

    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; text &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;match&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; message {
        Message::Cls &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;C&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Equ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;=&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Digit(digit) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; digit.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_string&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Op(Op::Add) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;+&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Op(Op::Sub) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;-&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Op(Op::Mul) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;*&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
        Message::Op(Op::Div) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;&#x2F;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;to_owned&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(),
    };

    mox!(
        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;button style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;BUTTON_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;} on&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{on_click}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
            &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;span&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{text}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;span&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
        &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;button&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)
}

#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;topo&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;nested&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;]
#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;illicit&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;from_env&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(state: &amp;amp;Key&amp;lt;CalcState&amp;gt;)]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;calculator&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;() -&amp;gt; Node&amp;lt;App&amp;gt; {
    mox! {
        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;app&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
            &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;window title&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;Moxie-Native Calculator&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;ROW_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;span&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;% &lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;{}&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;, state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;display&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;()}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;span&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;ROW_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;7&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;8&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;9&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Op(Op::Mul)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;ROW_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;5&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;6&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Op(Op::Div)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;ROW_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;2&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;3&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Op(Op::Add)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view style&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;{&lt;&#x2F;span&gt;&lt;span style=&quot;color:#666969;&quot;&gt;ROW_STYLE&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Digit(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Equ) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Cls) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                    &amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;calc_function &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;_=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Message::Op(Op::Sub)) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&#x2F;&amp;gt;
                &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;view&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
            &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;window&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
        &amp;lt;&#x2F;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;app&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;gt;
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}
}

&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;main&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;() {
    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; runtime &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;moxie_native::Runtime::new(|| {
        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;state!(|| CalcState::new());
        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; with_state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;illicit::child_env&lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;!&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(Key&amp;lt;CalcState&amp;gt; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;=&amp;gt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; state);
        with_state.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;enter&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(|| calculator!())
    });
    runtime.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;start&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;();
}
&lt;&#x2F;span&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, it&#x27;s still early days but (for me at least) it&#x27;s extremely exciting! It&#x27;s also
worth noting that it&#x27;s possible to write all of this functionality without the &lt;code&gt;mox&lt;&#x2F;code&gt; macro, even if
it&#x27;s not yet pleasant -- I have some thoughts for that too. Full disclosure: Tiffany is also using a
small fork of the macro that allows for statically-checked DOM mount-points, we should be able to
reconverge soon but in the meantime the macro code in these snippets isn&#x27;t &lt;em&gt;exactly&lt;&#x2F;em&gt; identical.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;and-more&quot;&gt;And more!&lt;a href=&quot;#and-more&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;I am eager to see moxie powering apps on top of many underlying frameworks in the future, including
those written using moxie as the main incremental tool (for the extremely adventurous only!). If 
you&#x27;re interested in using moxie to write bindings to the framework of your choice, please come join
the &lt;a href=&quot;https:&#x2F;&#x2F;moxie.rs&#x2F;#chat&quot;&gt;chat&lt;&#x2F;a&gt;! Because the core crates aren&#x27;t &lt;em&gt;that&lt;&#x2F;em&gt; stable yet I think the chat channel is best but in
the future I expect we&#x27;ll have guides for writing bindings &amp;amp; integrations.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;mental-model&quot;&gt;Mental Model&lt;a href=&quot;#mental-model&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;After the initial setup of any interactive UI, further changes are primarily driven by some kind of 
event. Once that event occurs, the program is responsible for computing what must change in the 
state of the application, deciding how the application&#x27;s interface should be changed as a result, 
and then performing that update accordingly. Along the way it&#x27;s typical to request future 
notifications of hardware inputs, timers, network events, or results from internal asynchronous 
tasks.&lt;&#x2F;p&gt;
&lt;p&gt;These events are usually handled in a loop, receiving information from the outside world and
eventually generating changes in the presented interface. In this way, interactive applications
resemble (meta-) &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Control_loop&quot;&gt;control loops&lt;&#x2F;a&gt;, constantly attempting to reconcile the external state of the
interface with the &amp;quot;set value&amp;quot; defined by the application&#x27;s logic.&lt;&#x2F;p&gt;
&lt;p&gt;moxie views the &amp;quot;control loop&amp;quot; code in UI applications as defining &lt;strong&gt;relations maintained over 
time&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#ffffff;&quot;&gt;
&lt;span style=&quot;color:#4d4d4c;&quot;&gt;             +-------------+
  events ----&amp;gt;             |
             |   program   |---&amp;gt; outputs
 initial ----&amp;gt;             |
 inputs      +-------------+
&lt;&#x2F;span&gt;&lt;&#x2F;pre&gt;&lt;h2 id=&quot;declarative-ui&quot;&gt;&amp;quot;Declarative&amp;quot; UI&lt;a href=&quot;#declarative-ui&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;Our goal is to allow one to &amp;quot;declare&amp;quot; these relations directly in the program source. When we 
declare the shape of our UI in code, we are writing a program which will run repeatedly,
each time computing a minimal update with minimal side effects while ensuring that the output 
matches the snapshot captured by the declaration.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#min-fixed&quot;&gt;3&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;To make snapshots efficient, moxie recognizes that &amp;quot;declarative UI&amp;quot; must be what &lt;a href=&quot;http:&#x2F;&#x2F;adapton.org&#x2F;&quot;&gt;Adapton&lt;&#x2F;a&gt; calls 
&amp;quot;incremental computation&amp;quot;:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;A program P is incremental if repeating P with a changed input is faster than from-scratch
recomputation.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This means making decisions about how to structure our declarative applications in such a way as to
reuse as much work as we can. Ideally we can do this while preserving other desired properties. We&#x27;d
like to have generally portable semantics for our declarative runtime, so that Rustaceans can use it
on a wide variety of targets and platforms. Expressing the computation incrementally should not undo
the benefits of having a single declaration for all instances of the application -- it must still be
pleasant enough to write.&lt;&#x2F;p&gt;
&lt;p&gt;Most existing UI systems have a way of dividing the output space of the application into nested
hierarchies, each one containing 0 or more of its own sub-divisions. These subdivisions form a tree,
with the root of the tree owning the total output space, its children owning their own portion each
of that, and so on.&lt;&#x2F;p&gt;
&lt;p&gt;Assuming you&#x27;re familiar with Rust&#x27;s ownership model, this is more or less how Rust encourages
viewing execution and dataflow within a thread. Everything descends from &lt;code&gt;main()&lt;&#x2F;code&gt;, receiving smaller
inputs at each lower stage of decomposing the program into smaller function calls, accumulating 
results on the way back up, informing later siblings and perhaps the final output.&lt;&#x2F;p&gt;
&lt;p&gt;In my opinion, regular function calls are the most &amp;quot;naturally Rustic&amp;quot; tools for modelling dynamic 
hierarchies. They have a very clear relationship to the ownership and reference models, are the
default abstraction chosen when decomposing a solution to a problem, and underly Rust&#x27;s uniform
execution model. So &lt;strong&gt;moxie offers tools to declare outputs incrementally according to the shape of 
a callgraph.&lt;&#x2F;strong&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;generic-incrementality&quot;&gt;Generic Incrementality&lt;a href=&quot;#generic-incrementality&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;It needs to be efficient to capture a snapshot of the declared output, since it happens in a loop 
quite frequently. The primary tool that moxie offers for this is &lt;strong&gt;memoization of nested tree 
values&lt;&#x2F;strong&gt; which are stored by the runtime in-between calls of the program.&lt;&#x2F;p&gt;
&lt;p&gt;The simplest form of memoization is the &lt;code&gt;once!&lt;&#x2F;code&gt; macro, which never reinitializes its contents
after the first time:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#ffffff;&quot;&gt;
&lt;span style=&quot;color:#8959a8;&quot;&gt;let&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt; first &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;once!(|| Arc::new(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c99e00;&quot;&gt;String&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::new(include_str!(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#718c00;&quot;&gt;&amp;quot;...&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;))));
               &lt;&#x2F;span&gt;&lt;span style=&quot;color:#999999;&quot;&gt;&#x2F;&#x2F; ^ only runs once for this location in the tree
               &#x2F;&#x2F; subsequent runs at this location will clone the Arc
&lt;&#x2F;span&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Much of the time, expensive operations take a value as input which sometimes varies but is often
stable. In those cases, we&#x27;d like to reuse the prior work whenever possible:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#ffffff;&quot;&gt;
&lt;span style=&quot;color:#999999;&quot;&gt;&#x2F;&#x2F;&#x2F; Reads the contents of the provided path as a string, returning a reference
&#x2F;&#x2F;&#x2F; to it. The I&#x2F;O is performed only when this is first called or when it has 
&#x2F;&#x2F;&#x2F; the contents of a different path cached.
&#x2F;&#x2F;&#x2F;
&#x2F;&#x2F;&#x2F; I don&amp;#39;t recommend writing this function in your projects! So many reasons.
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;#[&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;topo&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;::&lt;&#x2F;span&gt;&lt;span style=&quot;color:#c82829;&quot;&gt;nested&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8959a8;&quot;&gt;fn &lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;intern_file_contents&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;path&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#3e999f;&quot;&gt;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;Path) -&amp;gt; Arc&amp;lt;String&amp;gt; {
    memo!(path, |&lt;&#x2F;span&gt;&lt;span style=&quot;color:#f5871f;&quot;&gt;p&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;| Arc::new(std::fs::read_to_string(p).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4271ae;&quot;&gt;unwrap&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;()))
              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#999999;&quot;&gt;&#x2F;&#x2F; ^ touches disk only when p changes
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#4d4d4c;&quot;&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Here, &lt;code&gt;memo!&lt;&#x2F;code&gt; takes the &lt;strong&gt;capture argument&lt;&#x2F;strong&gt; &lt;code&gt;path&lt;&#x2F;code&gt;, and runs the initialization closure whenever
&lt;code&gt;path&lt;&#x2F;code&gt; changes. If it&#x27;s able to reuse a previous result, then it will &lt;code&gt;Clone&lt;&#x2F;code&gt; that and return it.
There are non-&lt;code&gt;Clone&lt;&#x2F;code&gt; options too, it&#x27;s just the most straightforward for an example.&lt;&#x2F;p&gt;
&lt;p&gt;The storage is local to that callsite within that function, relative to the current location in the
call tree. It holds values across snapshots, which allows our code to be written for &amp;quot;right now,&amp;quot;
regardless of prior executions. At the end of each snapshot, the runtime drops all values which were
not referenced in the latest &amp;quot;revision.&amp;quot; The initialization and destruction of each memoized value
can therefore be used to model mount&#x2F;unmount style lifecycle events -- a subject for another post.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;identifying-storage-locations&quot;&gt;Identifying Storage Locations&lt;a href=&quot;#identifying-storage-locations&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;p&gt;This memoization tool isn&#x27;t very useful unless we can call it multiple times in a given snapshot,
storing different values in different parts of the tree without interference between them.&lt;&#x2F;p&gt;
&lt;p&gt;In order to differentiate the usages of &lt;code&gt;intern_file_contents!&lt;&#x2F;code&gt; within two different callers, it is 
annotated with &lt;code&gt;#[topo::nested]&lt;&#x2F;code&gt;. A unique &lt;code&gt;topo::Id&lt;&#x2F;code&gt; is constructed at the invocation of functions
annotated this way, which can be retrieved with &lt;code&gt;topo::Id::current()&lt;&#x2F;code&gt;. The &lt;code&gt;Id&lt;&#x2F;code&gt; is unique to the 
parent &lt;code&gt;Id&lt;&#x2F;code&gt; which was active when the current function was called, the source location at which it 
was created (so we can identify multiple calls within a parent function), and some runtime data we 
call a &amp;quot;slot.&amp;quot;&lt;&#x2F;p&gt;
&lt;p&gt;By default the slot used is the number of times that source location has already been called 
during the parent &lt;code&gt;Id&lt;&#x2F;code&gt;. This provides a nice default behavior for looping over collections,
recursion, etc. The slot can always be overridden with a user-provided slot in cases where the 
identity shouldn&#x27;t be tied to execution order within the collection, for example in a list where the
contents are shuffled but individual list items remain intact.&lt;&#x2F;p&gt;
&lt;p&gt;With these combined, each &lt;code&gt;Id&lt;&#x2F;code&gt; refers to a stable location within our incremental program&#x27;s call
tree. When we run our code multiple times, functions with the same &amp;quot;location&amp;quot; in the call tree will
receive &lt;code&gt;Id&lt;&#x2F;code&gt;s the same as their previous executions, allowing for a rendezvous with the output of
previous invocations.&lt;&#x2F;p&gt;
&lt;p&gt;Tying this together, each call to &lt;code&gt;memo!&lt;&#x2F;code&gt; during a given snapshot will receive a different &lt;code&gt;Id&lt;&#x2F;code&gt;
depending on tree location, and we use &lt;em&gt;that&lt;&#x2F;em&gt; as the index into our persistent cross-snapshot
storage. Future iterations of the snapshot process will be able to see that data provided their
execution takes the same path.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;driving-forward&quot;&gt;Driving Forward&lt;a href=&quot;#driving-forward&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;The other main primitive in moxie is the &lt;strong&gt;state variable&lt;&#x2F;strong&gt;, which forms the interface between 
the moxie runtime and underlying event-generating systems. State variables are memoized values
created with &lt;code&gt;state!&lt;&#x2F;code&gt;. They are mutated through the &lt;code&gt;Key&amp;lt;T&amp;gt;&lt;&#x2F;code&gt; returned from &lt;code&gt;state!&lt;&#x2F;code&gt;. Mutations 
notify the embedding environment that the runtime must be scheduled for execution. Each time that 
happens, another iteration of the control loop is entered and we snapshot the current interface
state.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;ask-not-what-you-must-do-for-moxie&quot;&gt;Ask not what you must do for moxie,&lt;a href=&quot;#ask-not-what-you-must-do-for-moxie&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
&lt;p&gt;This overall approach offers users of the core runtime many degrees of freedom in terms of how they
express a UI system on top:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;moxie-dom incrementally mutates concrete DOM nodes during a declaration, binding them to a &amp;quot;scoped 
singleton&amp;quot; parent. The currently-mutating-node is then offered as the parent to child function 
calls.&lt;&#x2F;li&gt;
&lt;li&gt;moxie-native components return memoized copy-on-write values which are incrementally evaluated in
later stages of the pipeline.&lt;&#x2F;li&gt;
&lt;li&gt;Previous experiments of mine have directly accumulated linear display lists for &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;servo&#x2F;webrender&quot;&gt;WebRender&lt;&#x2F;a&gt; during
the course of execution, and I expect that in the future I&#x27;ll write some moxie bindings for Dear
ImGui or another similarly &amp;quot;linearized snapshot&amp;quot; system.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;There are still some admittedly serious restrictions that moxie imposes on users (like transforming
functions that create nodes in the tree into macros! or my quick&#x27;n&#x27;dirty use of hashing to create
&lt;code&gt;topo::Id&lt;&#x2F;code&gt;s turning out to be unsound), but I think we have paths to resolve all of them within a 
few months.&lt;&#x2F;p&gt;
&lt;p&gt;Please &lt;a href=&quot;mailto:opine@anp.lol&quot;&gt;email me&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;anp&#x2F;moxie&#x2F;issues&quot;&gt;file an issue&lt;&#x2F;a&gt;, or hop in the &lt;a href=&quot;https:&#x2F;&#x2F;moxie.rs&#x2F;#chat&quot;&gt;chat&lt;&#x2F;a&gt; if you&#x27;re trying things out and have 
questions or feedback. I&#x27;m eager to hear from you! It highlights places I can learn to improve my
communication&#x2F;process&#x2F;design&#x2F;etc, and helps me prioritize efforts! Plus, it&#x27;s nice to hear about
everyone&#x27;s projects :D.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h1 id=&quot;moxie-and-the-levien-unified-topology&quot;&gt;moxie and the Levien unified topology&lt;a href=&quot;#moxie-and-the-levien-unified-topology&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;So that&#x27;s moxie &lt;em&gt;qua&lt;&#x2F;em&gt; moxie, or as well as I&#x27;m able to represent it right now.&lt;&#x2F;p&gt;
&lt;p&gt;If you haven&#x27;t read Raph&#x27;s excellent and &lt;a href=&quot;https:&#x2F;&#x2F;raphlinus.github.io&#x2F;ui&#x2F;druid&#x2F;2019&#x2F;11&#x2F;22&#x2F;reactive-ui.html&quot;&gt;thought-provoking post on reactive UI&lt;&#x2F;a&gt;, I recommend
either doing so first or skimming the rest of this post. Assuming you&#x27;ve read it, I&#x27;ll be quoting 
liberally from it to add moxie-specific color to the ideas and to offer a few replies since I&#x27;ve
built such a nice soapbox for myself here. True to Raph&#x27;s inspiration, I&#x27;m following his walk 
through ideas since the satisfying narrative conclusion already happened up above.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;there are two fundamental ways to represent a tree. First, as a &lt;em&gt;data structure&lt;&#x2F;em&gt;, ... Second, as a
&lt;em&gt;trace of excecution,&lt;&#x2F;em&gt; ...&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I think about this in terms of the shape of &amp;quot;tree snapshot&amp;quot; structure(s) captured and how. The 
spectrum of shapes of those data structures is quite broad, as Raph rightly notes. Garbage-collected
heap references, identifers stored in ECS-style linear storage, vertex buffers, raw GPU command 
buffers, intermingled layers of some or all of these, etc.&lt;&#x2F;p&gt;
&lt;p&gt;The shapes of these structures determine which kinds of analyses a runtime or framework can perform 
to calculate e.g. layout, as well as the efficiency of capturing the snapshot of the application&#x27;s 
visual state in the first place (what Raph calls app data -&amp;gt; widget tree and I tend to think of as 
the &amp;quot;capture&amp;quot; or &amp;quot;extraction&amp;quot; phase of application logic).&lt;&#x2F;p&gt;
&lt;p&gt;moxie&#x27;s approach here is to use callsite-based IDs for identifying incremental storage, but to use
initialization of that storage as a tool for memoizing mutations. You can call methods on a builder
context, or manipulate tree nodes and connect them together. The goal of the core runtime is to 
allow for any strategy here, as long as it can fit in an initialization closure.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#push-vs-pull&quot;&gt;4&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Raph goes on to describe a model of producing these trees in pipelined stages, with nice diagrams:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;There are a number of reasons to analyze the problem of UI as a pipeline of tree stages. 
Basically, the end-to-end transformation is so complicated it would be very difficult to express 
directly. So it&#x27;s best to break it down into smaller chunks, stitched together in a pipeline.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;...you want these tree-to-tree transformations to be &lt;em&gt;incremental.&lt;&#x2F;em&gt; In a UI, you&#x27;re not dealing 
with one tree, but a time sequence of them, and most of the tree is not changing, just a small 
&lt;em&gt;delta.&lt;&#x2F;em&gt; One of the fundamental goals of a UI framework is to keep the deltas flowing down the 
pipeline small.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;In my opinion this nicely sets the stage for the comparison between the architectures of 
contemporary &amp;quot;declarative UI pipelines&amp;quot; and those of today&#x27;s optimizing compilers. Without going
into too much depth, I&#x27;d argue that there is a similar trend at play with other tools undergoing 
batch -&amp;gt; interactive re-architectures or re-writes:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;incremental compilers built for IDE usage (Roslyn, rustc, the &lt;a href=&quot;http:&#x2F;&#x2F;skiplang.com&#x2F;&quot;&gt;Skip&lt;&#x2F;a&gt; research language was built 
around a very cool self-hosting incremental toolchain, etc.)
&lt;ul&gt;
&lt;li&gt;I quite like &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;salsa-rs&#x2F;salsa&quot;&gt;salsa&lt;&#x2F;a&gt; as a generic tool in this space, and had tried a couple of times to
implement moxie on top of it&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;megabuild systems with strict DAG-based builds (e.g. Bazel)&lt;&#x2F;li&gt;
&lt;li&gt;databases materializing synthetic views&#x2F;tables&#x2F;etc in response to writes to concrete tables&lt;&#x2F;li&gt;
&lt;li&gt;streaming frameworks like &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;TimelyDataflow&#x2F;differential-dataflow&quot;&gt;differential dataflow&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
&lt;li&gt;etc&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;It seems to me that &lt;strong&gt;computing ecosystems prioritizing latency&lt;&#x2F;strong&gt; trend toward having 
&amp;quot;incremental computing engines&amp;quot; at their hearts.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#sidebar&quot;&gt;5&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; It&#x27;s been identified by research projects
like &lt;a href=&quot;http:&#x2F;&#x2F;adapton.org&#x2F;&quot;&gt;Adapton&lt;&#x2F;a&gt; and others for a while now. I&#x27;m not terribly well-versed in the research in this 
niche, but it seems likely to be a fruitful place to learn.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;This is especially true when the transformation is stateful, as it makes sense to attribute that 
state to a particular stage in the pipeline.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I agree, and this is one of the main ways in which the comparison between UI systems and compilers
breaks down. Typical incremental compiler pipelines don&#x27;t have to consume different types of events,
just project updates.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Pulling from a tree basically means calling a function to access that part of the tree.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;IIUC, another important implication of pull-based APIs in Rust is that you generally need concrete 
return types, intermediate iterator structs, and lifetimes&#x2F;generics&#x2F;etc require more effort.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;One more thing to say about the interplay between sequence iterators and trees: it&#x27;s certainly 
possible to express a tree as its &lt;em&gt;flattening&lt;&#x2F;em&gt; into a sequence of events, particularly &amp;quot;push&amp;quot; and 
&amp;quot;pop&amp;quot; (also commonly &amp;quot;start&amp;quot; and &amp;quot;end&amp;quot; in parser lingo) to represent the tree structure.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is the structure that &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;ocornut&#x2F;imgui&quot;&gt;Dear ImGui&lt;&#x2F;a&gt; uses, with &lt;code&gt;ImGui::Begin(...)&lt;&#x2F;code&gt; and &lt;code&gt;ImGui::End()&lt;&#x2F;code&gt; calls.
This is also the basic structure that I used in a demo I made in early 2019 with proto-moxie and
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;servo&#x2F;webrender&quot;&gt;WebRender&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;...a change to some node on the input can have nontrivial effects on other nodes in the output. 
This is the problem of &amp;quot;tracking dependencies&amp;quot; and probably accounts for most of the variation 
between frameworks.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I think one of the most general and useful strategies is &lt;em&gt;diffing&lt;&#x2F;em&gt;, ...you do a traversal (of some 
kind) of the output tree, and at each node you keep track of the &lt;em&gt;focus,&lt;&#x2F;em&gt; specifically which subtree 
of the input can possibly affect the result.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;moxie does this, but at the level of individual &lt;code&gt;let&lt;&#x2F;code&gt; binding assignments, and the caller must
provide the &amp;quot;focus&amp;quot; (which moxie calls the &amp;quot;capture&amp;quot;) value(s) that will be used to determine
whether to re-initialize the memoized value.&lt;&#x2F;p&gt;
&lt;p&gt;My hope here is that by keeping diffing, lifecycle, and updates local to specific variables, moxie
can provide &amp;quot;incremental connective tissue&amp;quot; without requiring specific tree structures of its users.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Diffing is also available in a less clever, more brute-force form, by actually going over the 
trees and comparing their contents. This is, I think, quite the common pattern in JS reactive 
frameworks...&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I &lt;em&gt;think&lt;&#x2F;em&gt; that most diffing strategies in JS-land compare virtual DOM trees against one another,
rather than comparing directly with the DOM. I could be wrong. A good thing to look closely at if
someone were to write more summary content!&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;I&#x27;m not going to spend a lot of words on other incremental strategies, as it&#x27;s a huge topic. But 
besides diffing, the other major approach is explicit deltas, most commonly (but not always) 
expressed as mutations. Then, you annotate the tree with &amp;quot;listeners,&amp;quot; which are called when the 
node receives a mutation... &lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Interestingly, moxie combines these two approaches. Memoized values could be said to be &amp;quot;diffed&amp;quot; by
checking the arguments against the existing storage. Updates are only visible to the runtime via
state variables which require calling &lt;code&gt;update(...)&lt;&#x2F;code&gt; or &lt;code&gt;set(...)&lt;&#x2F;code&gt; on them to cause a state
transition.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;bookkeeping to identify a subtree of the output that can change, and causes recomputation of that.
There&#x27;s a choice of &lt;em&gt;granularity&lt;&#x2F;em&gt; there, and a pattern I see a lot (cf &lt;a href=&quot;https:&#x2F;&#x2F;developer.android.com&#x2F;reference&#x2F;kotlin&#x2F;androidx&#x2F;compose&#x2F;package-summary#recompose&quot;&gt;Recompose&lt;&#x2F;a&gt; in Jetpack 
Compose) is to address a node in the output tree and schedule a pull-based computation of that 
node&#x27;s contents.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;moxie assumes that the program will enter from the &amp;quot;top&amp;quot; of the tree each time. I think that lower
level re-entry may be interesting, but the implementation details for moxie would be quite
challenging and may not be feasible without language extensions.&lt;&#x2F;p&gt;
&lt;p&gt;My suspicion is that Rust may be fast enough along with the right memoization strategies to never
worry about the time spent getting from the root of the tree to nodes with changes. We&#x27;ll see!&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;And this brings us to one of the fundamental problems in any push-based incremental approach: it 
becomes necessary to &lt;em&gt;identify&lt;&#x2F;em&gt; nodes in the output tree, so that it&#x27;s possible to push content to 
them. &lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;This is important! In Raph&#x27;s model, moxie is push-based and moxie-dom and moxie-native 
incrementally map those push-shaped declarations onto pull-based data structures.&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#native-phases&quot;&gt;6&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt;&lt;&#x2F;p&gt;
&lt;p&gt;That said, it&#x27;s completely feasible to treat it completely as a &amp;quot;tracing&amp;quot; system in Raph&#x27;s terms,
which is what I intend to do with ImGui bindings. moxie would still provide stateful components and
memoized reuse of expensive computations, but wouldn&#x27;t actually retain any tree structure.&lt;&#x2F;p&gt;
&lt;p&gt;Regarding the concrete strategy for identity, moxie&#x27;s a little bit weird according to Raph&#x27;s
breakdown.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;...common approach is some form of &lt;em&gt;key path,&lt;&#x2F;em&gt;...at heart a sequence of directions from the root 
to the identified node.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Semantically, this is what a &lt;code&gt;topo::Id&lt;&#x2F;code&gt; encodes, where the nodes are function activation records. In
the near future I expect it to be a more literal encoding of this.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;...a common choice for other path elements is unique call site identifiers.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Each &lt;code&gt;topo::Id&lt;&#x2F;code&gt; is created at a callsite, so the &amp;quot;node&amp;quot; identifiers in moxie&#x27;s model are partly made
from callsite identifiers.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Using object references is possible in Rust but...nail down the fact that the tree is stored in a 
data structure at that &lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;moxie-dom and moxie-native rely on &lt;code&gt;topo::Id&lt;&#x2F;code&gt;s to map from memoization storage to object references
stored between frames. But that doesn&#x27;t rule out...&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;...unique identifiers of some kind (usually just integers). This is the basic approach of &lt;a href=&quot;https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Entity_component_system&quot;&gt;ECS&lt;&#x2F;a&gt;
and also druid before the muggle branch.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;...which would also work with memoization storage, I think.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;In both Jetpack Compose and imgui, you have a succession of stages which are basically &amp;quot;push&amp;quot; 
and end up emitting events to a context on the output. These compose well. ... This  pattern works
especially well for expand-type transformations, as the transformation logic is especially intuitive
-- it&#x27;s just function calls. It&#x27;s also really clean when the transformation is stateless, otherwise
you have the question of how the transformer gets access to state.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Aside: one interesting way to think about moxie is the constrained ability to add memoization and
statefulness to computation written to be stateless and pure. Another interesting way to think
about moxie is that it allows for imperative code with the &amp;quot;concision of purity.&amp;quot;&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;For one, you do put startGroup and endGroup calls in (these are mostly magically inserted by a 
compiler plugin, doing source transformation of the original logic). These help the Composer keep 
track of the key path at all times, which, recall, is an identifier to a specific position in the 
tree.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;And the Composer internally maps that to a &lt;em&gt;slot,&lt;&#x2F;em&gt; which can be used to store state as needed. 
So basically, even though there&#x27;s not a tree data structure in memory, when you&#x27;re in the middle 
of a transformation stage, you can get access to state for your node as &lt;em&gt;if&lt;&#x2F;em&gt; the tree was 
materialized.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;moxie plays a similar trick with its memoization storage being &amp;quot;lensed&amp;quot; by the current instruction
pointer, as it were. Memoized value storage is indexed by the &lt;code&gt;topo::Id&lt;&#x2F;code&gt; at the callsite where 
the value is to be materialized. That new &lt;code&gt;Id&lt;&#x2F;code&gt; comes from the current &lt;code&gt;Id&lt;&#x2F;code&gt; (that of the calling 
context, or the &amp;quot;parent&amp;quot; in our abstract tree), the callsite of the new &lt;code&gt;Id&lt;&#x2F;code&gt; (analogous to 
startGroup), and some runtime data which moxie calls the &amp;quot;slot.&amp;quot; As I mentioned before, that&#x27;s
typically populated with the number of times the new callsite has been invoked within the current
(parent) &lt;code&gt;Id&lt;&#x2F;code&gt;, allowing for the default behavior in loops to make intuitive sense.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;I highly recommend Leland Richardson&#x27;s &lt;a href=&quot;http:&#x2F;&#x2F;intelligiblebabble.com&#x2F;compose-from-first-principles&#x2F;&quot;&gt;Compose From First Principles&lt;&#x2F;a&gt;, as it goes into a fair 
amount of detail about general tree transformations, and the concept of &amp;quot;positional memoization&amp;quot; 
as a way to (in the lingo of this blog post) access state of intermediate tree stages in a 
transformation pipeline.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I also highly recommend Leland&#x27;s post! In Compose&#x27;s worldview, moxie might be said to implement
&amp;quot;topologically-nested memoization.&amp;quot; Ow, that hurts my mouth. Leland and I have talked a few times
about how to think about the style of repeatable, declarative functions that moxie and Compose add
to their respective languages,&lt;sup class=&quot;footnote-reference&quot;&gt;&lt;a href=&quot;#not-fp&quot;&gt;7&lt;&#x2F;a&gt;&lt;&#x2F;sup&gt; and it&#x27;s always been a blast. I look forward to seeing a lot
more from that team, especially as they&#x27;re able to iterate in the open on runtime and language-level
features.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;There have been a number of attempts to adapt React-style patterns to Rust. Probably the most 
interesting is &lt;a href=&quot;https:&#x2F;&#x2F;moxie.rs&quot;&gt;moxie&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;(moxie) builds key paths to identify nodes in the output tree, and emits the output tree as a
trace. Like Imgui, Jetpack Compose, and makepad, it mostly uses function calls to represent the
application logic. I look forward to seeing how it progresses.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;&amp;lt;3 !!!&lt;&#x2F;p&gt;
&lt;p&gt;To be slightly more precise about my goals re: React, my main goal is to identify the technology
needed for the analogous &lt;em&gt;ecosystem niche&lt;&#x2F;em&gt; for Rust. Well, that, and I quite like the &lt;a href=&quot;https:&#x2F;&#x2F;reactjs.org&#x2F;docs&#x2F;hooks-intro.html&quot;&gt;Hooks API&lt;&#x2F;a&gt;. I
have described moxie a few times as &amp;quot;what if a React in Rust but built out of context and hooks?&amp;quot;&lt;&#x2F;p&gt;
&lt;p&gt;There is some fun nuance here with how moxie actually fits into the broader technical picture Raph
paints, but I won&#x27;t duplicate that here as thats a...lot of what I&#x27;ve already written.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;If you&#x27;re designing one of these systems for scripting, the cross-language boundary is always 
going to be one of the most important.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I heartily agree, especially having originally started this project thinking about providing a
runtime for JavaScript (story for another time, literally). That&#x27;s actually a significant influence
on the ImGui flavor of moxie-dom. Calling functions with a context pointer is IMO much simpler to do
across an FFI boundary than to navigate shared ownership of nodes with a managed environment.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Obviously most JS reactive frameworks take DOM as a given, and are organized around it. They 
also tend to gloss over the implicit state in DOM nodes and downstream, pretending that the only 
state management concerns are in the transformations from app state up to the DOM.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Agreed! I&#x27;m particularly interested to see how moxie-native continues to develop, and whether bets
on non-hierarchical memoization pay off in later pipeline phases. This is an area where I see
React Native as having struggled quite a bit and I think that Rustic solutions need a higher bar.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;a href=&quot;#acknowledgements&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;cmr&quot;&gt;cmr&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tiffany352&quot;&gt;Tiffany&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;LPGhatguy&quot;&gt;Lucien&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;bkase_&quot;&gt;Brandon&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;twitter.com&#x2F;lincolnnathan21&quot;&gt;Nathan&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;sunjay&quot;&gt;Sunjay&lt;&#x2F;a&gt; all gave their time and attention to 
review this post and provide invaluable feedback. Thank you!&lt;&#x2F;p&gt;
&lt;h1 id=&quot;q-a&quot;&gt;Q&amp;amp;A&lt;a href=&quot;#q-a&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;I&#x27;ve been tinkering with a static-site-friendly comments setup but don&#x27;t yet have it working. In the
meantime, please &lt;a href=&quot;mailto:opine@anp.lol&quot;&gt;email me&lt;&#x2F;a&gt; your comments and questions and I&#x27;ll post them here!&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;Some thoughts emailed by [Raph]:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;I think that most diffing strategies in JS-land compare virtual DOM trees against one another, 
rather than comparing directly with the DOM. I could be wrong. A good thing to look closely at if 
someone were to write more summary content!&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Oh, absolutely, and I&#x27;m sure that&#x27;s just one of many things that wasn&#x27;t clear from my blog post. The
fundamental model of React (as I understand it) is that building a vdom and then deep-diffing it 
against the previous version is relatively cheap compared with any actual DOM update. This is, I 
believe, partly true - it&#x27;s certainly the case that it&#x27;s more efficient than any naive approach 
which does more DOM manip than necessary, but shaky in other contexts. I think in &amp;quot;native GUI land&amp;quot;,
the DOM is super-expensive, and imgui style approaches (makepad included) give you a very nice 
performance baseline to quantify this.&lt;&#x2F;p&gt;
&lt;p&gt;So the deeper part is, how do you avoid generating a vdom subtree when it&#x27;s the same as the previous 
frame? I think this is often presented in React circles as an optimization trick, as a beginning 
developer can often get away with not bothering. But, in the general framework, (a) you need access 
to previous-frame state (which hooks, JC slots, and moxie all do), and (b) you need logic in your 
app now to compute whether the subtree indeed needs changing (dependency tracking) and tell the next 
pipeline stage to use the retained subtree.&lt;&#x2F;p&gt;
&lt;p&gt;I think the dependency tracking is one of the hardest parts. It&#x27;s possible to do it by hand, but 
that&#x27;s verbose and error-prone (&amp;quot;make&amp;quot;). Other viable strategies include static analysis of the 
program source (svelte, JC), but there are many more.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;moxie assumes that the program will enter from the &amp;quot;top&amp;quot; of the tree each time. I think that lower 
level re-entry may be interesting, but the implementation details for moxie would be quite 
challenging and may not be feasible without language extensions.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;I am increasingly convinced this is the right approach, as long as both tree traversal and skipping 
of subtrees are fast. I think trying not to touch the path from the root to the hot node is a false 
economy, as you&#x27;ll often need to do that anyway to propagate invalidations, relayout, etc.&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;Regarding the concrete strategy for identity, moxie&#x27;s a little bit weird according to Raph&#x27;s 
breakdown.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Not sure why you say this; seems like a pretty standard key path system to me. Most of them use some 
kind of callsite tracking plus an integer index for collections.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;p&gt;(Note to self: figure out a better way to format replies-to-replies-to-replies...)&lt;&#x2F;p&gt;
&lt;p&gt;Agree without comment on the first and second sections here, and will clarify what I meant by &amp;quot;a
little bit weird according to Raph&#x27;s breakdown.&amp;quot; &lt;code&gt;topo::Id&lt;&#x2F;code&gt;s are indeed &amp;quot;key paths.&amp;quot; I think they&#x27;re
interesting because they are used to mediate storage for other node identities (object references, 
ECS IDs, etc.). Re-reading here, I think it may be more accurate to say that &lt;code&gt;Id&lt;&#x2F;code&gt;s are used only to
bridge the invocation syntax to a stored node of some kind, and &lt;em&gt;that&lt;&#x2F;em&gt; node can be identified with 
any of the strategies listed. Maybe that&#x27;s to say that moxie isn&#x27;t &amp;quot;weird&amp;quot; in this model, it&#x27;s 
attempting to be versatile when integrating with other systems?&lt;&#x2F;p&gt;
&lt;p&gt;Thanks for the reply, good stuff!&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h3 id=&quot;notes&quot;&gt;Notes&lt;a href=&quot;#notes&quot; class=&quot;section-anchor&quot;&gt;ahoy&lt;&#x2F;a&gt;&lt;&#x2F;h3&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;maturity&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;1&lt;&#x2F;sup&gt;
&lt;p&gt;moxie-dom isn&#x27;t very mature, by the way.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;forget-iframe&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;2&lt;&#x2F;sup&gt;
&lt;p&gt;That is, until the source URL changes and I forget to update it.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;min-fixed&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;3&lt;&#x2F;sup&gt;
&lt;p&gt;NB: in addition to keeping the expense of changes proportional to the type of change 
needed, we also need to have minimal fixed costs imposed by declarative style when resolving UI 
state.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;push-vs-pull&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;4&lt;&#x2F;sup&gt;
&lt;p&gt;moxie-native progressively does several tree-to-tree transformations, all of which
but the final GPU pass are incremental, and none of which are push-based.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;moxie-dom defaults to a push-based API for ease of use with collections and other control flow, but
under the hood manipulates a concrete DOM tree to which it exposes &amp;quot;raw&amp;quot; access for the adventurous.&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s important to note that while moxie-dom gains convenience from a push-based API, it loses the
ability to statically verify the correctness of parent&#x2F;child relationships the way that moxie-native
can by virtue of expressing application logic with a pull-based API. I think there may be solutions
at the language level for this, mainly by offering static checking for &lt;code&gt;#[illicit::from_env(...)]&lt;&#x2F;code&gt;
or a similar feature. Since that&#x27;s very far away, I consider the two approaches to be exploring
really valuable tradeoff&#x2F;design points for &amp;quot;declarative UI in Rust.&amp;quot; Do we actually find ourselves 
significantly more productive with easy control flow for UI elements? How often in practice do 
errors occur from having the checks at runtime?&lt;&#x2F;p&gt;
&lt;p&gt;It&#x27;s also worth noting that as far as &amp;quot;react-alike&amp;quot; systems go, the use of concrete return values
from functions is the undisputed &amp;quot;known entity&amp;quot; and projects like Compose and moxie-dom are outliers
here.&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;sidebar&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;5&lt;&#x2F;sup&gt;
&lt;p&gt;I have my own suspicions about the &amp;quot;sociotechnical&amp;quot; challenges of producing correct and
efficient (enough) software over time with hetergeneous teams of imperfect humans. Interesting
parallel: carefully managing the size of incremental changes is a significant component of many 
successful software engineering practices as well.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;I suspect there&#x27;s also an argument that any software which interactively mediates human activity
will eventually find its success bounded by its latency properties. Perhaps this implies there&#x27;s an
argument that meatbag-adjacent technologies should prioritize latency instrumentation and analysis?
This has certainly been true of human-facing usage of request&#x2F;response systems like HTTP services.
I think there are some very interesting things moxie can do regarding latency, especially in 
conjunction with the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;tokio-rs&#x2F;tracing&quot;&gt;tracing&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;jonhoo&#x2F;tracing-timing&quot;&gt;tracing-timing&lt;&#x2F;a&gt; crates.&lt;&#x2F;p&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;native-phases&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;6&lt;&#x2F;sup&gt;
&lt;p&gt;In later phases, moxie-native takes the returned tree, performs incremental 
layout, and linearizes the tree into a list of display commands with WebRender before sending them
to the GPU.&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
&lt;div class=&quot;footnote-definition&quot; id=&quot;not-fp&quot;&gt;&lt;sup class=&quot;footnote-definition-label&quot;&gt;7&lt;&#x2F;sup&gt;
&lt;p&gt;How to think about them except not as pure functional programming constructs ;).&lt;&#x2F;p&gt;
&lt;&#x2F;div&gt;
</description>
            </item>
        
            <item>
                <title>lolbench: automagically and empirically discovering Rust performance regressions</title>
                <pubDate>Sat, 29 Sep 2018 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2018/09/29/lolbench/</link>
                <guid>https://blog.anp.lol/rust/2018/09/29/lolbench/</guid>
                <description>&lt;p&gt;lolbench compiles ~350 benchmarks with every Rust nightly. It then runs them and highlights potential performance regressions in the standard library and the output of the compiler. Each toolchain&#x27;s run is summarized with a list of likely candidates, as seen in the image below, and we&#x27;re now getting started using these to safeguard the performance of Rust programs. Come help!&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>Snapshots: Automating Golden Master Regression Tests in Rust</title>
                <pubDate>Fri, 18 Aug 2017 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2017/08/18/golden-master-regression-in-rust/</link>
                <guid>https://blog.anp.lol/rust/2017/08/18/golden-master-regression-in-rust/</guid>
                <description>&lt;p&gt;I&#x27;ve been playing around with &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;anp&#x2F;snapshot-rs&quot;&gt;snapshot&lt;&#x2F;a&gt;, a crate for automating golden master tests in Rust. It&#x27;s experimental and unstable, but I think it&#x27;s a cool example of how easy it is to build procedural macro helpers with the newer Rust APIs.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>For Posterity: New job, conference talks</title>
                <pubDate>Mon, 22 May 2017 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/personal/new-job-conference-talks/</link>
                <guid>https://blog.anp.lol/personal/new-job-conference-talks/</guid>
                <description>&lt;p&gt;Blogs serve lots of purposes. In the past I&#x27;ve written here to talk about mostly technical Rust things, but I thought it&#x27;d be worth writing a little bit about what I&#x27;ve been doing since last fall. I don&#x27;t expect anyone to read this but it&#x27;ll be nice to have for myself down the road.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>Rust Performance: A story featuring perf and flamegraph on Linux</title>
                <pubDate>Sun, 24 Jul 2016 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2016/07/24/profiling-rust-perf-flamegraph/</link>
                <guid>https://blog.anp.lol/rust/2016/07/24/profiling-rust-perf-flamegraph/</guid>
                <description>&lt;p&gt;Gaining some performance wins in a Rust program with a 7 line diff, using &lt;a href=&quot;https:&#x2F;&#x2F;doc.rust-lang.org&#x2F;book&#x2F;benchmark-tests.html&quot;&gt;cargo bench&lt;&#x2F;a&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;perf.wiki.kernel.org&#x2F;index.php&#x2F;Main_Page&quot;&gt;perf&lt;&#x2F;a&gt;, and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;brendangregg&#x2F;FlameGraph&quot;&gt;flamegraph&lt;&#x2F;a&gt; on Linux.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>cue: a little parallel pipeline</title>
                <pubDate>Fri, 01 Jul 2016 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2016/07/01/publishing-cue/</link>
                <guid>https://blog.anp.lol/rust/2016/07/01/publishing-cue/</guid>
                <description>&lt;p&gt;&lt;em&gt;Update: the &lt;code&gt;cue&lt;&#x2F;code&gt; crate on crates.io has been transfered to someone working with CUE format files for compact discs.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p&gt;I published a quick little crate for long-running &amp;quot;streaming&amp;quot; parallel tasks.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>Baby Steps: Slowly Porting musl to Rust</title>
                <pubDate>Sat, 11 Jun 2016 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2016/06/11/baby-steps-porting-musl-to-rust/</link>
                <guid>https://blog.anp.lol/rust/2016/06/11/baby-steps-porting-musl-to-rust/</guid>
                <description>&lt;p&gt;I&#x27;m toying with writing a C standard library in Rust by porting musl-libc over function-by-function. The work is in progress at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;anp&#x2F;rusl&quot;&gt;https:&#x2F;&#x2F;github.com&#x2F;anp&#x2F;rusl&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>Measuring Rust Runtime Performance: cargo bench vs. getrusage()</title>
                <pubDate>Wed, 24 Feb 2016 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2016/02/24/rust-runtime-cargobench-vs-getrusage/</link>
                <guid>https://blog.anp.lol/rust/2016/02/24/rust-runtime-cargobench-vs-getrusage/</guid>
                <description>&lt;p&gt;Comparing cargo bench results to a slightly more robust method eliminates a lot of the noise, but there still appear to be a few performance regressions that both methods agree on. If someone has the statistics expertise to set me straight or help me take this further or both, please get in touch.&lt;&#x2F;p&gt;
</description>
            </item>
        
            <item>
                <title>(Almost) 6 Months of Rust Runtime Performance</title>
                <pubDate>Tue, 16 Feb 2016 00:00:00 +0000</pubDate>
                <link>https://blog.anp.lol/rust/2016/02/16/almost-6-months-rust-runtime-perf/</link>
                <guid>https://blog.anp.lol/rust/2016/02/16/almost-6-months-rust-runtime-perf/</guid>
                <description>&lt;p&gt;After reading &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;rust-lang&#x2F;rust&#x2F;issues&#x2F;31265&quot;&gt;this issue&lt;&#x2F;a&gt;, I decided to poke around in the history of &lt;code&gt;rustc&lt;&#x2F;code&gt;&#x27;s runtime performance.&lt;&#x2F;p&gt;
</description>
            </item>
        
    </channel>
</rss>
