<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Claudio Nunya</title>
    <description>The latest articles on DEV Community by Claudio Nunya (@claudio_nunya_f2433922791).</description>
    <link>https://dev.to/claudio_nunya_f2433922791</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3748506%2F764b8f8f-7b27-42fd-bf84-2da096b03ef2.jpg</url>
      <title>DEV Community: Claudio Nunya</title>
      <link>https://dev.to/claudio_nunya_f2433922791</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/claudio_nunya_f2433922791"/>
    <language>en</language>
    <item>
      <title>HaikUI: A SwiftUI‑Inspired DSL for Haiku OS</title>
      <dc:creator>Claudio Nunya</dc:creator>
      <pubDate>Mon, 02 Feb 2026 17:14:04 +0000</pubDate>
      <link>https://dev.to/claudio_nunya_f2433922791/haikui-a-swiftui-inspired-dsl-for-haiku-os-43p2</link>
      <guid>https://dev.to/claudio_nunya_f2433922791/haikui-a-swiftui-inspired-dsl-for-haiku-os-43p2</guid>
      <description>&lt;p&gt;&lt;em&gt;Designing a declarative UI system in YAB, inspired by SwiftUI but grounded in Haiku’s native widgets.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;HaikUI is a small declarative UI DSL for &lt;strong&gt;Haiku OS&lt;/strong&gt;, implemented entirely in &lt;strong&gt;YAB&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
It borrows the &lt;em&gt;mental model&lt;/em&gt; of &lt;strong&gt;SwiftUI&lt;/strong&gt;—nested views, readable structure, and modifiers—while remaining pragmatic and faithful to Haiku’s native widget system.&lt;/p&gt;

&lt;p&gt;Rather than attempting to replicate SwiftUI’s full reactive and diffing engine, HaikUI focuses on a clear, minimal pipeline:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DSL → Node Registry → Renderer → Native Haiku Widgets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This approach keeps the system simple, debuggable, and well‑suited to the constraints of YAB.&lt;/p&gt;


&lt;h2&gt;
  
  
  Declarative Structure
&lt;/h2&gt;

&lt;p&gt;HaikUI describes user interfaces as a tree of containers and controls.&lt;/p&gt;

&lt;p&gt;Containers such as &lt;code&gt;Window&lt;/code&gt;, &lt;code&gt;HStack&lt;/code&gt;, &lt;code&gt;VStack&lt;/code&gt;, &lt;code&gt;Boxview&lt;/code&gt;, and &lt;code&gt;Tabview&lt;/code&gt; define structure, while widgets like &lt;code&gt;Button&lt;/code&gt;, &lt;code&gt;Label&lt;/code&gt;, and &lt;code&gt;Slider&lt;/code&gt; provide interaction.&lt;/p&gt;

&lt;p&gt;The emphasis is on &lt;strong&gt;composition&lt;/strong&gt;, not boilerplate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Windows contain layouts&lt;/li&gt;
&lt;li&gt;Layouts contain containers&lt;/li&gt;
&lt;li&gt;Containers contain controls&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  Example: HaikUI DSL
&lt;/h2&gt;

&lt;p&gt;Below is a real HaikUI layout used in a simple drawing application.&lt;br&gt;&lt;br&gt;
It defines a window split into a controls panel (left) and a canvas area (right).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Window(title="Draw Demo", x="10", y="10", w="560", h="460") {
  HStack(x="5", y="5", w="540", h="450") {

    Boxview(title="Controls", x="10", y="10", w="260", h="440", lineType="2") {
      VStack(x="5", y="5", w="240", h="410", pad="0", space="10") {

        HStack(w="240", h="200", pad="0", space="10") {

          VStack(w="100", h="200", pad="0", space="10") {
            Button(title="New object", w="100", h="30")
            Button(title="Clear", w="100", h="30")

            Radiobutton(title="Line", w="100", h="24", isActivated="1")
            Radiobutton(title="Rect", w="100", h="24")
            Radiobutton(title="Round rect", w="100", h="24")
            Radiobutton(title="Ellipse", w="100", h="24")
          }

          VStack(w="130", h="200", pad="0", space="5") {
            Label(title="Object", w="190", h="18",
                  font="Noto Sans Display", style="Bold", size="12")
            Listbox(w="130", h="160", scrollbarType="1")
          }
        }

        Colorcontrol(w="230", h="60")
        Textcontrol(title="100", w="70", h="22")
        Checkbox(title="Fill", w="70", h="22")
        Slider(title="Width", w="130", h="25", min="1", max="100",
               option="Block-horizontal")
      }
    }

    VStack(x="270", y="20", w="280", h="440", background="#FFFFFF") {
      Label(title="Click and drag to draw an object",
            x="50", y="210", w="220", h="20",
            font="Noto Sans Display", style="Bold", size="12")
    }

  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The structure of the code directly mirrors the visual hierarchy of the interface.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Registry: HaikUI’s Intermediate Representation
&lt;/h2&gt;

&lt;p&gt;After parsing, HaikUI converts the DSL into a &lt;strong&gt;registry&lt;/strong&gt;: a flat list of node records.&lt;/p&gt;

&lt;p&gt;Each record includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A unique ID&lt;/li&gt;
&lt;li&gt;Widget type&lt;/li&gt;
&lt;li&gt;Geometry (x, y, width, height)&lt;/li&gt;
&lt;li&gt;Parent ID&lt;/li&gt;
&lt;li&gt;Optional properties (modifiers)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example registry fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ID | Type | Label | X | Y | Width | Height | Parent | Properties...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This registry acts as HaikUI’s internal “view model” and makes rendering and debugging straightforward.&lt;/p&gt;




&lt;h2&gt;
  
  
  Parenting and the Container Stack
&lt;/h2&gt;

&lt;p&gt;Correct parent–child relationships are the core challenge of any declarative UI system.&lt;/p&gt;

&lt;p&gt;HaikUI enforces correctness using a &lt;strong&gt;container stack&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Entering a container pushes it onto the stack&lt;/li&gt;
&lt;li&gt;Exiting a container pops it&lt;/li&gt;
&lt;li&gt;New nodes attach to the current top of the stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guarantees correct hierarchy even with deeply nested layouts.&lt;/p&gt;




&lt;h2&gt;
  
  
  Layout Model: SwiftUI vs HaikUI
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SwiftUI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dynamic measurement and placement&lt;/li&gt;
&lt;li&gt;Parent/child negotiation&lt;/li&gt;
&lt;li&gt;Runtime reconciliation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;HaikUI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deterministic flow layout&lt;/li&gt;
&lt;li&gt;Cursor‑based positioning in stacks&lt;/li&gt;
&lt;li&gt;Explicit padding and spacing&lt;/li&gt;
&lt;li&gt;Optional absolute overrides&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result is predictable, debuggable layout behavior.&lt;/p&gt;




&lt;h2&gt;
  
  
  Modifiers as Data
&lt;/h2&gt;

&lt;p&gt;In SwiftUI, modifiers are compositional API calls.&lt;/p&gt;

&lt;p&gt;In HaikUI, modifiers are parsed as &lt;strong&gt;data&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stored as key–value properties&lt;/li&gt;
&lt;li&gt;Interpreted by the renderer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This data‑driven design keeps the renderer small and well‑suited to YAB.&lt;/p&gt;




&lt;h2&gt;
  
  
  SwiftUI vs HaikUI at a Glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;SwiftUI&lt;/th&gt;
&lt;th&gt;HaikUI&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Authoring style&lt;/td&gt;
&lt;td&gt;Declarative API&lt;/td&gt;
&lt;td&gt;Declarative DSL&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;View model&lt;/td&gt;
&lt;td&gt;Value‑type tree&lt;/td&gt;
&lt;td&gt;Registry records&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Layout&lt;/td&gt;
&lt;td&gt;Measurement‑based&lt;/td&gt;
&lt;td&gt;Flow‑based&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Modifiers&lt;/td&gt;
&lt;td&gt;API transforms&lt;/td&gt;
&lt;td&gt;Data properties&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;State&lt;/td&gt;
&lt;td&gt;Reactive&lt;/td&gt;
&lt;td&gt;Explicit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Widgets&lt;/td&gt;
&lt;td&gt;Framework views&lt;/td&gt;
&lt;td&gt;Native Haiku widgets&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debugging&lt;/td&gt;
&lt;td&gt;Runtime tools&lt;/td&gt;
&lt;td&gt;Registry dump&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Implementation&lt;/td&gt;
&lt;td&gt;Large framework&lt;/td&gt;
&lt;td&gt;Lightweight renderer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;HaikUI shows that modern declarative UI concepts can be adapted to constrained environments without sacrificing clarity or control.&lt;/p&gt;

&lt;p&gt;By combining a SwiftUI‑like authoring style with a simple registry and deterministic renderer, HaikUI offers a practical, Haiku‑native way to build user interfaces—focused on correctness, readability, and ease of iteration.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>haiku</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
