<?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: Sam Pudke</title>
    <description>The latest articles on DEV Community by Sam Pudke (@trytobesam).</description>
    <link>https://dev.to/trytobesam</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%2F4226576%2Fb3bccc64-5582-48b7-84a6-2795c4f7a3fb.png</url>
      <title>DEV Community: Sam Pudke</title>
      <link>https://dev.to/trytobesam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/trytobesam"/>
    <language>en</language>
    <item>
      <title>I built a programming language that reads like plain English, and it compiles to native code</title>
      <dc:creator>Sam Pudke</dc:creator>
      <pubDate>Wed, 04 Nov 2026 15:37:15 +0000</pubDate>
      <link>https://dev.to/trytobesam/i-built-a-programming-language-that-reads-like-plain-english-and-it-compiles-to-native-code-5cka</link>
      <guid>https://dev.to/trytobesam/i-built-a-programming-language-that-reads-like-plain-english-and-it-compiles-to-native-code-5cka</guid>
      <description>&lt;p&gt;For the past while I've been building &lt;strong&gt;Moth&lt;/strong&gt;, a programming language that reads the way you'd say it out loud. Moth 1.11 came out today, and this is what it is and how it works.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like
&lt;/h2&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set guests to list of "Ada", "Grace", "Alan"
for each guest in guests
    say "Welcome, " guest "!"
end

to fib with n
    if n is less than 2
        return n
    end
    return fib(n - 1) + fib(n - 2)
end
say "fib(32) is " fib(32)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;There are no symbols to learn beyond a little arithmetic, and when something goes wrong, Moth says so in plain words: &lt;code&gt;line 12: there is no item 5, the list only has 3 items&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Numbers work the way people expect, like a spreadsheet: they're compared to 15 significant digits, so &lt;code&gt;0.1 + 0.2 is 0.3&lt;/code&gt; says &lt;code&gt;yes&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A compiler written in itself
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;moth build hello.moth&lt;/code&gt; turns a program into &lt;code&gt;hello.exe&lt;/code&gt; on Windows, or &lt;code&gt;hello&lt;/code&gt; on Linux: a program of its own, with nothing to install.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzjynbkxpltgz6boe56no.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzjynbkxpltgz6boe56no.gif" alt="Building fib.moth into fib.exe: fib(32) in 16 ms, against 341 ms for the same program in Python" width="760" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The compiler that does this is written in Moth. It writes x86-64 machine code and the Windows (PE) and Linux (ELF) file formats byte by byte, with no assembler, no linker and no C toolchain. &lt;code&gt;moth.exe&lt;/code&gt; builds itself, and the Linux &lt;code&gt;moth&lt;/code&gt; builds it too, into exactly the same bytes.&lt;/p&gt;

&lt;h2&gt;
  
  
  How fast
&lt;/h2&gt;

&lt;p&gt;The same four programs in C, Rust, Moth and Python, each timed from start to finish on Windows 11:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;th&gt;Rust&lt;/th&gt;
&lt;th&gt;Moth&lt;/th&gt;
&lt;th&gt;Python&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;fib(32): 7 million calls&lt;/td&gt;
&lt;td&gt;20 ms&lt;/td&gt;
&lt;td&gt;18 ms&lt;/td&gt;
&lt;td&gt;25 ms&lt;/td&gt;
&lt;td&gt;521 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;adding 1 to 100,000,000&lt;/td&gt;
&lt;td&gt;36 ms&lt;/td&gt;
&lt;td&gt;10 ms&lt;/td&gt;
&lt;td&gt;37 ms&lt;/td&gt;
&lt;td&gt;11.1 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;primes up to 300,000&lt;/td&gt;
&lt;td&gt;71 ms&lt;/td&gt;
&lt;td&gt;71 ms&lt;/td&gt;
&lt;td&gt;72 ms&lt;/td&gt;
&lt;td&gt;2.2 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;30,000,000 steps of decimal maths&lt;/td&gt;
&lt;td&gt;48 ms&lt;/td&gt;
&lt;td&gt;51 ms&lt;/td&gt;
&lt;td&gt;49 ms&lt;/td&gt;
&lt;td&gt;4.6 s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Moth still keeps its promises in these: numbers are decimals compared to 15 digits, and every step that could go wrong is checked. The compiler gets there by working out, as it writes the code, what each variable is sure to hold.&lt;/p&gt;

&lt;h2&gt;
  
  
  Four engines that must agree
&lt;/h2&gt;

&lt;p&gt;Moth also runs in the browser. The &lt;a href="https://samyyy2423.github.io/moth/" rel="noopener noreferrer"&gt;playground&lt;/a&gt; has a debugger that goes backwards through a run, and mistakes are underlined as you type.&lt;/p&gt;

&lt;p&gt;Behind it are three engines: a bytecode VM, a JIT that compiles Moth to JavaScript, and a WebAssembly compiler that writes the module byte by byte. All of them, and the native compiler, must say, draw and fail exactly alike. CI checks that on every push, including with 5,000 randomly broken programs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Batteries included
&lt;/h2&gt;

&lt;p&gt;Moth ships with a standard library: HTTP and an HTTPS server, sockets with TLS, email, SQLite through C libraries, JSON, XML, TOML, zip, PNG and JPEG images, AES-GCM encryption, charts, numbers of any size, and tools to use every core at once. There's a package manager, a profiler, a coverage tool, notebooks, an installer builder and a VS Code extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In your browser: &lt;a href="https://samyyy2423.github.io/moth/" rel="noopener noreferrer"&gt;https://samyyy2423.github.io/moth/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Download Moth 1.11 for Windows or Linux: &lt;a href="https://github.com/samyyy2423/moth/releases/latest" rel="noopener noreferrer"&gt;https://github.com/samyyy2423/moth/releases/latest&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The code, and DESIGN.md, which explains every decision, including what didn't work: &lt;a href="https://github.com/samyyy2423/moth" rel="noopener noreferrer"&gt;https://github.com/samyyy2423/moth&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's open source under Apache 2.0. I'd love to hear what you think of the syntax, and what you'd build with it.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>compilers</category>
      <category>opensource</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
