<?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: Owen</title>
    <description>The latest articles on DEV Community by Owen (@owenbellowen).</description>
    <link>https://dev.to/owenbellowen</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%2F3573303%2F1b170325-68af-44b3-a07a-a8f589db81b0.png</url>
      <title>DEV Community: Owen</title>
      <link>https://dev.to/owenbellowen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/owenbellowen"/>
    <language>en</language>
    <item>
      <title>I Over-Engineered My First Project: Bridging TypeScript and Zig with Bun! 🚀</title>
      <dc:creator>Owen</dc:creator>
      <pubDate>Mon, 16 Mar 2026 02:29:06 +0000</pubDate>
      <link>https://dev.to/owenbellowen/i-over-engineered-my-first-project-bridging-typescript-and-zig-with-bun-2h8n</link>
      <guid>https://dev.to/owenbellowen/i-over-engineered-my-first-project-bridging-typescript-and-zig-with-bun-2h8n</guid>
      <description>&lt;p&gt;Hello, hello! It's me Owen again!&lt;/p&gt;

&lt;p&gt;I've been inactive for awhile and thought maybe I should post again (Even if this is my second post fully). Some people say that coding project should start with To-do lists, REST APIs, Generators, etc.&lt;/p&gt;

&lt;p&gt;Instead, I decided to dive completely into the deep end. I wanted to build something fast, learn about memory management, and figure out how different languages talk to each other. &lt;/p&gt;

&lt;p&gt;So, I built &lt;strong&gt;Dunena&lt;/strong&gt;—a high-performance, hybrid-architecture monorepo. It leverages &lt;strong&gt;Bun&lt;/strong&gt; and &lt;strong&gt;TypeScript&lt;/strong&gt; for the web layer, and delegates heavy CPU tasks to &lt;strong&gt;Zig&lt;/strong&gt; via a Foreign Function Interface (FFI). Oh, and I deployed it on Kubernetes. Because why not? 😅 (But don't worry about that since I'm still new to Docker and Kubernetes.)&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://github.com/OwenBellowen/dunena" rel="noopener noreferrer"&gt;Check out the Dunena Repository on GitHub here!&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
🔗 &lt;strong&gt;&lt;a href="https://owenbellowen.github.io/dunena/" rel="noopener noreferrer"&gt;Check the documentation here!&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a breakdown of what I built, how it works, and the massive amount of things I learned along the way.&lt;/p&gt;


&lt;h3&gt;
  
  
  🏗️ What is Dunena?
&lt;/h3&gt;

&lt;p&gt;At its core, Dunena is a backend platform designed to handle requests quickly and efficiently. It features routing, WebSockets, pub/sub services, and a caching layer. &lt;/p&gt;

&lt;p&gt;But the real magic is under the hood. I wanted the rapid development speed of TypeScript, but I didn't want Node/Bun to get bogged down by heavy computations like compression, bloom filters, or complex stat calculations. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Tech Stack:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Runtime &amp;amp; Monorepo Manager:&lt;/strong&gt; Bun 🥟&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Primary Language:&lt;/strong&gt; TypeScript (Strict mode)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High-Performance Core:&lt;/strong&gt; Zig ⚡&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database:&lt;/strong&gt; SQLite 🗄️&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deployment:&lt;/strong&gt; Docker &amp;amp; Kubernetes 🐳 (Again I'm new to this so bare in mind)&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;
  
  
  🧠 The Architecture
&lt;/h3&gt;

&lt;p&gt;The coolest (and scariest) part of this project is the FFI bridge. Here is how a request goes from TypeScript to near bare-metal execution in Zig.&lt;/p&gt;

&lt;p&gt;First, I write the high-performance logic in Zig and export it using the C Application Binary Interface (ABI):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight zig"&gt;&lt;code&gt;&lt;span class="c"&gt;// zig/src/exports.zig&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="n"&gt;std&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;@import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"std"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c"&gt;// Exporting a function so Bun can read it via the C ABI&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;compute_heavy_stats&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_val&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;i32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Imagine some incredibly complex, CPU-blocking math here&lt;/span&gt;
    &lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;input_val&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&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;Then, in my TypeScript platform package, I use Bun's native &lt;code&gt;dlopen&lt;/code&gt; to load the compiled Zig shared library and bridge the function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// packages/platform/src/bridge/ffi.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;dlopen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;FFIType&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;suffix&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bun:ffi&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Load the compiled Zig library&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`../../zig/zig-out/lib/libdunena_core.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;suffix&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;symbols&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dlopen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;compute_heavy_stats&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;FFIType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;returns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;FFIType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;i32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Now I can call Zig directly from TypeScript!&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;runStats&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;symbols&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compute_heavy_stats&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&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;When a client hits my Bun server (&lt;code&gt;apps/server/src/index.ts&lt;/code&gt;), the platform handles the API routing, hands the heavy computation off to Zig, and returns the result instantly.&lt;/p&gt;




&lt;h3&gt;
  
  
  🤖 The "AI" Elephant in the Room
&lt;/h3&gt;

&lt;p&gt;I want to be totally transparent: &lt;strong&gt;I used AI coding agents to help build this.&lt;/strong&gt; Using tools like Claude and Gemini was incredible for speeding up the boilerplate, setting up the monorepo structure, and scaffolding the initial file architecture. It felt like having a senior developer sitting next to me typing out the boring stuff.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;However...&lt;/strong&gt; AI agents are terrifyingly bad at manually managing memory across an FFI boundary. &lt;/p&gt;

&lt;p&gt;If the AI changed a data type in Zig but forgot to update the exact corresponding FFI definition in TypeScript, the server would just crash with a memory access violation. The AI helped me move fast, but &lt;strong&gt;I still had to do the brutal, hair-pulling debugging and fixing.&lt;/strong&gt; Figuring out how to safely pass pointers, prevent memory leaks, and get Kubernetes to play nice with an attached SQLite volume was all human effort. It taught me not to blindly trust generated code, especially when dealing with low-level systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  🧗 The Biggest Challenges
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;1. Managing Memory Across the Void&lt;/strong&gt;&lt;br&gt;
When you pass data between TypeScript and Zig, there are no safety nets. Bun’s garbage collector has no idea what Zig is doing. Learning how to manually manage memory and use &lt;code&gt;defer&lt;/code&gt; statements in Zig was a huge hurdle!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. SQLite in Kubernetes&lt;/strong&gt;&lt;br&gt;
Deploying an SQLite database (which is essentially a physical file) attached to a K8s pod via Persistent Volume Claims (PVC) was tricky. It works great for a single pod, but I quickly realized that if I scale this horizontally, I might run into database locking issues. &lt;/p&gt;




&lt;h3&gt;
  
  
  🚀 What's Next?
&lt;/h3&gt;

&lt;p&gt;This project is far from "finished." I'm currently maintaining this project on my own, but would love to see anyone who'd try and contribute!&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's Connect!
&lt;/h3&gt;

&lt;p&gt;Since this is my first major project, I would absolutely love any feedback, code reviews, or advice from the community. &lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;&lt;a href="https://github.com/OwenBellowen/dunena" rel="noopener noreferrer"&gt;Check out the code on GitHub&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
🔗 &lt;strong&gt;&lt;a href="https://owenbellowen.github.io/dunena/" rel="noopener noreferrer"&gt;Check the documentation here!&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Have you ever tried mixing languages like this or fighting with FFI boundaries? Let me know in the comments! 👇&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>zig</category>
      <category>typescript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Elba Lang</title>
      <dc:creator>Owen</dc:creator>
      <pubDate>Sun, 19 Oct 2025 04:08:36 +0000</pubDate>
      <link>https://dev.to/owenbellowen/elba-lang-408g</link>
      <guid>https://dev.to/owenbellowen/elba-lang-408g</guid>
      <description>&lt;h2&gt;
  
  
  Elba — A modern, statically-typed programming language with multiple compilation backends
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/OwenBellowen/elba" rel="noopener noreferrer"&gt;GitHub → OwenBellowen/elba&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As someone deeply interested in programming languages, compilers, and full-stack systems (yes, that’s me: a student, TypeScript/Zig/Rust dev), I’m excited to introduce &lt;strong&gt;Elba&lt;/strong&gt; — a project I’ve been working on that brings together clarity, performance, and tooling in one language.&lt;/p&gt;

&lt;p&gt;Note: I have no intentions yet on making this into a full project. Although I would continue working on this.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 What is Elba?
&lt;/h2&gt;

&lt;p&gt;Elba is a statically-typed programming language designed for clarity, performance, and developer productivity.&lt;br&gt;&lt;br&gt;
It offers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Static type checking &lt;strong&gt;with type inference&lt;/strong&gt; — so you get all the safety of static typing without &lt;em&gt;always&lt;/em&gt; writing verbose annotations.
&lt;/li&gt;
&lt;li&gt;Generics — write reusable, type-safe code.
&lt;/li&gt;
&lt;li&gt;Union types, optional types (&lt;code&gt;T?&lt;/code&gt;) for null safety — fewer runtime surprises.
&lt;/li&gt;
&lt;li&gt;A module system, first-class functions, rich arrays, structs with methods.
&lt;/li&gt;
&lt;li&gt;Multiple backends: AST interpreter for quick prototyping, IR interpreter for faster execution, a C code generator, and an LLVM backend for native performance. &lt;/li&gt;
&lt;li&gt;A standard library covering math, strings, and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short: think “modern language with the expressiveness of high-level code” + “compiled speed” + “tooling and REPL to iterate fast”.&lt;/p&gt;


&lt;h2&gt;
  
  
  ✨ Why build Elba?
&lt;/h2&gt;

&lt;p&gt;Because I believe we can push the boundaries of what a new language can offer. Specifically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Type safety meets productivity&lt;/strong&gt;: We want the benefits of static typing (fewer bugs) without getting bogged down in ceremony.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multiple backend flexibility&lt;/strong&gt;: Sometimes you just want a quick REPL or interpreter; other times you need native speed. Elba gives you both.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;For compiler / language-enthusiasts&lt;/strong&gt;: If you love messing around with languages, building tooling, or exploring alternative type systems (hello Zig and Rust fans), this is a playground.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modern developer experience&lt;/strong&gt;: REPL, error-reporting, benchmarking, IR visualization — all included.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🛠️ Getting Started
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Zig (version 0.15.2 or later) &lt;/li&gt;
&lt;li&gt;(Optional) LLVM 20 for native backend
&lt;/li&gt;
&lt;li&gt;(Optional) GCC or Clang for C code generation&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Build from source
&lt;/h3&gt;

&lt;p&gt;You can follow the setup on the &lt;code&gt;README.md&lt;/code&gt; or below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/OwenBellowen/elba.git
&lt;span class="nb"&gt;cd &lt;/span&gt;elba
zig build
./zig-out/bin/elba &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quick Test
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./zig-out/bin/elba examples/hello_world.elba
./zig-out/bin/elba repl
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Full documentation and more examples live in the &lt;code&gt;examples/&lt;/code&gt; directory and the repo’s docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 Example code snippet
&lt;/h2&gt;

&lt;p&gt;Here’s a small example showing Elba’s generics + optional types:&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;// examples/generic_example.elba&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="n"&gt;swap&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;

    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;first&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;second&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt;&lt;span class="nf"&gt;.new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.second&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;self&lt;/span&gt;&lt;span class="py"&gt;.first&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;maybeNum&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;i64&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;42&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;maybeNil&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;i64&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;null&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;maybeNum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maybeNil&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"x = {x}, y = {y}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Pair&lt;/span&gt;&lt;span class="nf"&gt;.new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"world"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;p2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="nf"&gt;.swap&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"swapped: {p2.first}, {p2.second}"&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;



</description>
      <category>programming</category>
      <category>zig</category>
      <category>opensource</category>
      <category>git</category>
    </item>
  </channel>
</rss>
