<?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: Artin Azadsarv</title>
    <description>The latest articles on DEV Community by Artin Azadsarv (@artin9094).</description>
    <link>https://dev.to/artin9094</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4036289%2Fbceb59a0-0567-4aae-90b8-9f5137ee4a46.jpg</url>
      <title>DEV Community: Artin Azadsarv</title>
      <link>https://dev.to/artin9094</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/artin9094"/>
    <language>en</language>
    <item>
      <title>Zamin: A Scripting Language with a Rust-Based Bytecode VM and GPU-Accelerated ML</title>
      <dc:creator>Artin Azadsarv</dc:creator>
      <pubDate>Sun, 19 Jul 2026 08:46:47 +0000</pubDate>
      <link>https://dev.to/artin9094/zamin-a-scripting-language-with-a-rust-based-bytecode-vm-and-gpu-accelerated-ml-2f5m</link>
      <guid>https://dev.to/artin9094/zamin-a-scripting-language-with-a-rust-based-bytecode-vm-and-gpu-accelerated-ml-2f5m</guid>
      <description>&lt;p&gt;If you'd rather not clone anything just to see what this is, there's a playground that runs the whole interpreter in your browser — no install required: &lt;a href="https://young-developer90.github.io/zamin/playground.html" rel="noopener noreferrer"&gt;https://young-developer90.github.io/zamin/playground.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've been working on Zamin for the past several months. It's a scripting language, written in Rust, with its own bytecode virtual machine rather than a tree-walking interpreter. I wanted to actually see a project like this through to a working, reasonably complete state instead of leaving it half-finished, which is admittedly a common failure mode with language projects. So it's grown to include a proper CLI, a formatter, a test runner, two GUI toolkits, and even optional GPU acceleration — more than I originally set out to build, if I'm honest.&lt;/p&gt;

&lt;p&gt;Repo: &lt;a href="https://github.com/young-developer90/zamin" rel="noopener noreferrer"&gt;https://github.com/young-developer90/zamin&lt;/a&gt; (MIT licensed)&lt;br&gt;
Playground: &lt;a href="https://young-developer90.github.io/zamin/playground.html" rel="noopener noreferrer"&gt;https://young-developer90.github.io/zamin/playground.html&lt;/a&gt;&lt;br&gt;
Docs: &lt;a href="https://young-developer90.github.io/zamin/" rel="noopener noreferrer"&gt;https://young-developer90.github.io/zamin/&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  why build another language 🤔
&lt;/h2&gt;

&lt;p&gt;Mostly curiosity about how languages work under the hood, rather than just using them. Python was my reference point for the surface syntax — closures, string interpolation, that general feel — but I didn't want to just tree-walk an AST the way a lot of hobby interpreters do, since that's the easy path and I wanted to actually learn something harder. So Zamin compiles source down to bytecode and executes it on a small register-based VM instead.&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;func&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&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;n&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="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;10&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="n"&gt;f&lt;/span&gt;&lt;span class="s"&gt;"fib({i}) = {fibonacci(i)}"&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;You can paste that directly into the playground and it runs immediately, nothing to install.&lt;/p&gt;

&lt;h2&gt;
  
  
  how it's put together 🏗️
&lt;/h2&gt;

&lt;p&gt;The pipeline is fairly conventional on paper: lexer, parser, AST, compiler, bytecode, VM. A few parts took more effort than I expected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VM dispatches using raw byte dispatch (computed gotos on GCC/Clang) rather than a function-pointer table. This ended up being a bigger win than I anticipated — roughly 15-25% faster across the board from that change alone.&lt;/li&gt;
&lt;li&gt;A handful of integer operations get their own dedicated opcodes, so common cases like adding a small constant to a register skip boxing and type checks entirely.&lt;/li&gt;
&lt;li&gt;The garbage collector is mark-and-sweep, generational, non-moving, and incremental, mainly because I didn't want noticeable pause times during execution.&lt;/li&gt;
&lt;li&gt;There's a peephole optimizer that does constant folding, dead code elimination, strength reduction, and a few other passes over the compiled bytecode.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  how it compares to Python 📊
&lt;/h2&gt;

&lt;p&gt;I ran some rough benchmarks on the same machine, measured with wall-clock time:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;Zamin&lt;/th&gt;
&lt;th&gt;Python 3&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Recursive fib(32)&lt;/td&gt;
&lt;td&gt;1.51s&lt;/td&gt;
&lt;td&gt;0.35s&lt;/td&gt;
&lt;td&gt;about 4.3x slower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Integer loop (5M ops)&lt;/td&gt;
&lt;td&gt;0.47s&lt;/td&gt;
&lt;td&gt;0.53s&lt;/td&gt;
&lt;td&gt;slightly faster, actually&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;String concat (100K)&lt;/td&gt;
&lt;td&gt;3.14s&lt;/td&gt;
&lt;td&gt;0.23s&lt;/td&gt;
&lt;td&gt;about 13.4x slower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List push (500K)&lt;/td&gt;
&lt;td&gt;0.13s&lt;/td&gt;
&lt;td&gt;0.09s&lt;/td&gt;
&lt;td&gt;about 1.5x slower&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So it holds up reasonably well on tight integer loops, and is honestly not great yet on strings and list operations — that's mostly bytecode interpreter overhead I haven't fully optimized away. I'd rather be upfront about that than pretend it doesn't exist; it's a known weak spot I'm still working through.&lt;/p&gt;

&lt;h2&gt;
  
  
  what's actually in the box 🧰
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;25+ standard library modules, all available globally without imports — math, string, fs, json, re, http, csv, datetime, stats, hashlib, logging, subprocess, path, collections, itertools, test, rand, matrix, and a few more&lt;/li&gt;
&lt;li&gt;Two GUI toolkits behind feature flags: &lt;code&gt;luna&lt;/code&gt; for Linux (built on GTK4) and &lt;code&gt;sol&lt;/code&gt; for Windows&lt;/li&gt;
&lt;li&gt;OpenCV bindings through a &lt;code&gt;cv&lt;/code&gt; module, for basic computer vision work&lt;/li&gt;
&lt;li&gt;A GPU-accelerated module called &lt;code&gt;linum&lt;/code&gt;, with a small PyTorch-style API (Sequential, Linear, Adam, CrossEntropyLoss) that runs against CUDA when it's available&lt;/li&gt;
&lt;li&gt;A C extension ABI for native modules, and Python interop — &lt;code&gt;py.import("numpy")&lt;/code&gt; with types marshalled automatically between the two languages&lt;/li&gt;
&lt;li&gt;An embedding API for calling Zamin from a host Rust application&lt;/li&gt;
&lt;li&gt;A built-in LSP server, plus a companion VS Code extension&lt;/li&gt;
&lt;li&gt;The usual project tooling: &lt;code&gt;zamin run&lt;/code&gt;, &lt;code&gt;zamin repl&lt;/code&gt;, &lt;code&gt;zamin fmt&lt;/code&gt;, &lt;code&gt;zamin test&lt;/code&gt;, &lt;code&gt;zamin build&lt;/code&gt;, &lt;code&gt;zamin new&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The interpreter also compiles to WebAssembly, which is what powers the browser playground&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  trying it out 🎮
&lt;/h2&gt;

&lt;p&gt;The fastest way in is the playground, no install needed: &lt;a href="https://young-developer90.github.io/zamin/playground.html" rel="noopener noreferrer"&gt;https://young-developer90.github.io/zamin/playground.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you'd rather run it locally:&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/young-developer90/zamin.git
&lt;span class="nb"&gt;cd &lt;/span&gt;zamin
cargo build &lt;span class="nt"&gt;--release&lt;/span&gt;
./target/release/zamin run examples/hello.zamin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requires Rust 1.80 or newer.&lt;/p&gt;

&lt;p&gt;Full docs, covering the language and standard library in more depth, are here: &lt;a href="https://young-developer90.github.io/zamin/" rel="noopener noreferrer"&gt;https://young-developer90.github.io/zamin/&lt;/a&gt; (also available in Farsi and Japanese, in case that's useful to anyone reading this).&lt;/p&gt;

&lt;p&gt;If anyone digs into the VM code, I'd genuinely like to hear where you think the string and list slowdown is coming from — I have a few theories but nothing confirmed yet, and a second pair of eyes would help. Comments are open, and I'll try to respond to whatever comes up. 🙂&lt;/p&gt;

</description>
      <category>rust</category>
      <category>showdev</category>
      <category>webassembly</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
