<?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: Osa George-Mannella</title>
    <description>The latest articles on DEV Community by Osa George-Mannella (@osa_mannella).</description>
    <link>https://dev.to/osa_mannella</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%2F3523133%2Fc4b09c91-9ed4-4816-b2aa-c4db88ce137c.jpeg</url>
      <title>DEV Community: Osa George-Mannella</title>
      <link>https://dev.to/osa_mannella</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/osa_mannella"/>
    <language>en</language>
    <item>
      <title>Type-Safe SVGs with Mirrow: A New DSL for Modern Frontend Graphics</title>
      <dc:creator>Osa George-Mannella</dc:creator>
      <pubDate>Thu, 25 Sep 2025 21:42:21 +0000</pubDate>
      <link>https://dev.to/osa_mannella/type-safe-svgs-with-mirrow-a-new-dsl-for-modern-frontend-graphics-27bj</link>
      <guid>https://dev.to/osa_mannella/type-safe-svgs-with-mirrow-a-new-dsl-for-modern-frontend-graphics-27bj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; Mirrow is a DSL for SVGs that introduces compile-time type safety, structural validation, and a more intuitive attribute model. In this post I’ll show how it works, compare it to “raw” SVG, and guide you through setup and examples.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Vector graphics have become the backbone of modern web development, with SVGs emerging as the universal standard for scalable graphics. Yet while SVGs dominate web vector graphics, the tooling ecosystem has remained largely stagnant since the XML era. We believe it's time to strip away the tedious nature of SVG authoring to make this wonderful technology more accessible.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;My Journey to Building Mirrow&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I started developing Mirrow after growing increasingly frustrated with the current vector graphics landscape. We have a plethora of JavaScript libraries like &lt;a href="https://gsap.com/" rel="noopener noreferrer"&gt;GSAP&lt;/a&gt; and &lt;a href="http://snapsvg.io/" rel="noopener noreferrer"&gt;Snap.svg&lt;/a&gt; which excel at manipulating SVGs at runtime, and they serve their purposes well. &lt;/p&gt;

&lt;p&gt;This is great; however, these tools never addressed my fundamental pain points with SVG authoring itself. I wanted to shift left: instead of mutating SVGs at runtime, I wanted to verify them at compile time. The goal was to enforce structure and protocol on XML that has historically been overly dynamic and error-prone.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Compile-Time Safety: Mirrow's Core Innovation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Mirrow enforces structure through three key mechanisms: attribute typing, required attributes, and permitted children validation, all at compile time.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Silent Failures in XML&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Consider this invalid SVG structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;circle&lt;/span&gt; &lt;span class="na"&gt;cx=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt; &lt;span class="na"&gt;cy=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt; &lt;span class="na"&gt;r=&lt;/span&gt;&lt;span class="s"&gt;"30"&lt;/span&gt; &lt;span class="na"&gt;fill=&lt;/span&gt;&lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;rect&lt;/span&gt; &lt;span class="na"&gt;x=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;y=&lt;/span&gt;&lt;span class="s"&gt;"10"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"20"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt; 
&lt;span class="nt"&gt;&amp;lt;/circle&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This SVG is completely invalid because both &lt;code&gt;circle&lt;/code&gt; and &lt;code&gt;rect&lt;/code&gt; are leaf nodes that cannot act as parent elements. Yet traditional XML parsing provides no feedback about this structural error. The broken SVG renders silently in the DOM, leaving developers to hunt down the issue through visual debugging.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Compile-Time Error Detection&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now consider the equivalent Mirrow code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="n"&gt;circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fill&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"red"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// ← Type error caught here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mirrow performs compile-time safety checks using an internal element index to detect invalid parent-child relationships. The compiler throws a descriptive error before the invalid structure ever reaches the DOM. This creates a seamless feedback system that helps developers write correct SVGs from the start.&lt;/p&gt;

&lt;h3&gt;
  
  
  Declarative Attributes
&lt;/h3&gt;

&lt;p&gt;Mirrow introduces cleaner, more intuitive syntax while respecting the SVG specification. We've replaced ambiguous attributes like &lt;code&gt;cx&lt;/code&gt;/&lt;code&gt;cy&lt;/code&gt; and &lt;code&gt;x&lt;/code&gt;/&lt;code&gt;y&lt;/code&gt; with logical tuples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Instead of XML's:&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;lt;circle cx="50" cy="50" r="30" /&amp;gt;&lt;/span&gt;
&lt;span class="c1"&gt;// &amp;lt;rect x="10" y="20" width="50" height="50" /&amp;gt;&lt;/span&gt;

&lt;span class="c1"&gt;// Mirrow uses:&lt;/span&gt;
&lt;span class="n"&gt;circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;at&lt;/code&gt; tuple provides clear positioning that's instantly understandable, even to those new to SVG. This eliminates the confusion around attribute pairs while maintaining type safety.&lt;/p&gt;

&lt;p&gt;All attribute changes are documented with their SVG equivalents for easy migration. The goal is straightforward: make SVG authoring more accessible without sacrificing power.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type safety
&lt;/h3&gt;

&lt;p&gt;Mirrow's type checking system validates your graphics before they run, catching structural errors and type mismatches that XML would silently ignore. The compiler understands SVG semantics, preventing impossible element hierarchies as mentioned earlier alongside ensuring attribute correctness.&lt;/p&gt;

&lt;p&gt;For example, these errors are caught during compilation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Type mismatch: number expected&lt;/span&gt;
&lt;span class="n"&gt;circle&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;"thirty"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;// Error: expects number&lt;/span&gt;

&lt;span class="n"&gt;rect&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;                      &lt;span class="c1"&gt;// Error: missing 'size'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This approach maintains full SVG compatibility while dramatically improving developer experience. You spend less time debugging rendering issues and more time building graphics that work correctly the first time.&lt;/p&gt;

&lt;p&gt;The type system is at the current moment a work in progress. While it does address overarching value mismatch such as the aforementioned examples; it does not apply types to the context directly. We hope to improve these shortcomings in the future in order to implement full compile time safety. &lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Mirrow represents a shift in how we approach SVG authoring, from runtime guesswork to compile-time certainty. By bringing type safety and structural validation to vector graphics, it eliminates the silent failures and debugging sessions that have plagued developers for years. While traditional SVG tools focus on manipulating existing graphics, Mirrow ensures they're correct from the very first line of code.&lt;/p&gt;

&lt;p&gt;This is just the beginning. As the compiler evolves to encompass more contextual awareness and smarter validation, we're moving toward a future where SVG bugs are caught before they're written.&lt;/p&gt;

&lt;p&gt;Try it today with &lt;code&gt;npx mirrow&lt;/code&gt; or visit our &lt;a href="https://mirrow.app/playground" rel="noopener noreferrer"&gt;playground&lt;/a&gt;, and join us in building a better way to create for the web. The era of compile-time graphics has arrived.&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
