<story><title>The complexity that lives in the GUI</title><url>https://blog.royalsloth.eu/posts/the-complexity-that-lives-in-the-gui/</url></story><parent_chain><item><author>brundolf</author><text>The fundamental challenge of GUIs is that they have state as a core concern. Unlike most systems, state is not an implementation detail that can be refactored away. It is central to the problem domain. The &lt;i&gt;end user&lt;/i&gt; sees and cares about having a stateful system.&lt;p&gt;The hardest part of dealing with state in a complex system is maintaining consistency in different places. Some instances of this this can be avoided by creating single-sources-of-truth, but in other cases you can&amp;#x27;t unify your state, or you&amp;#x27;re dealing with an external stateful system (like the DOM), and you have no choice but to find a way to keep separate pieces of state in sync.&lt;p&gt;I should probably write a blog post on this</text></item></parent_chain><comment><author>danielvaughn</author><text>You could conceive of a GUI as merely a projection of internal state. If you do, then a GUI could be a completely stateless layer that exists solely to render visual content parametrically.&lt;p&gt;I&amp;#x27;ve been developing a convention in React over the last year that uses this idea and it&amp;#x27;s very very nice. I&amp;#x27;m also trying to write a platform-agnostic UI language specifically for designers that makes this a first class concept.</text></comment>
<story><title>The complexity that lives in the GUI</title><url>https://blog.royalsloth.eu/posts/the-complexity-that-lives-in-the-gui/</url></story><parent_chain><item><author>brundolf</author><text>The fundamental challenge of GUIs is that they have state as a core concern. Unlike most systems, state is not an implementation detail that can be refactored away. It is central to the problem domain. The &lt;i&gt;end user&lt;/i&gt; sees and cares about having a stateful system.&lt;p&gt;The hardest part of dealing with state in a complex system is maintaining consistency in different places. Some instances of this this can be avoided by creating single-sources-of-truth, but in other cases you can&amp;#x27;t unify your state, or you&amp;#x27;re dealing with an external stateful system (like the DOM), and you have no choice but to find a way to keep separate pieces of state in sync.&lt;p&gt;I should probably write a blog post on this</text></item></parent_chain><comment><author>rwmj</author><text>The way Tcl&amp;#x2F;Tk dealt with this was nice: You could watch the value in a variable, getting notified when the variable changed.  GUI controls could therefore exactly reflect the content of variables.  Of course this comes with a certain hidden overhead.&lt;p&gt;This complete example will toggle the checkbox every second (1000ms), or the user can click to update the variable.  The checkbox watches variable &amp;quot;v&amp;quot;.&lt;p&gt;&lt;pre&gt;&lt;code&gt;  #!&amp;#x2F;usr&amp;#x2F;bin&amp;#x2F;wish
  
  checkbutton .button -variable v -text &amp;quot;Click me&amp;quot;
  pack .button
  
  proc run {} {
      global v
      after 1000 run
      set v [expr !$v]
  }
  run&lt;/code&gt;&lt;/pre&gt;</text></comment>