<?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: Johnny</title>
    <description>The latest articles on DEV Community by Johnny (@jhi2).</description>
    <link>https://dev.to/jhi2</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%2F1380252%2Fab84ca22-6a34-41ae-9471-25b545e95f32.png</url>
      <title>DEV Community: Johnny</title>
      <link>https://dev.to/jhi2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jhi2"/>
    <language>en</language>
    <item>
      <title>I built a Python -&gt; C transpiler. Then it transpiled itself.</title>
      <dc:creator>Johnny</dc:creator>
      <pubDate>Sat, 20 Jun 2026 15:54:24 +0000</pubDate>
      <link>https://dev.to/jhi2/i-built-a-python-c-transpiler-then-it-transpiled-itself-3p8i</link>
      <guid>https://dev.to/jhi2/i-built-a-python-c-transpiler-then-it-transpiled-itself-3p8i</guid>
      <description>&lt;p&gt;A few weeks ago I needed to run Python scripts in initramfs — the tiny Linux environment that exists before your actual OS boots. No interpreter. No dynamic linker. Nothing.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Transpilatron&lt;/strong&gt;: an AI agent that takes Python code and produces a fully static C binary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx transpilatron your_code.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. No C knowledge required.&lt;/p&gt;

&lt;h2&gt;
  
  
  The benchmarks
&lt;/h2&gt;

&lt;p&gt;First, does it actually work? I ran two tests:&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;Python&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;th&gt;Speedup&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sieve of Eratosthenes (10M numbers)&lt;/td&gt;
&lt;td&gt;0.526s&lt;/td&gt;
&lt;td&gt;0.022s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;24x&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Selection sort (10K elements)&lt;/td&gt;
&lt;td&gt;1.963s&lt;/td&gt;
&lt;td&gt;0.033s&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;58x&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Same output. Verified on the same machine. The C binary is fully static — no runtime, no interpreter, no dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Flask demo
&lt;/h2&gt;

&lt;p&gt;Then I tried something more interesting. A 14-line Flask app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Hello from the webserver!&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/ping&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ping&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;pong&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;0.0.0.0&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx transpilatron web.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output: a native C HTTP server. No Flask. No Python runtime.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl http://localhost:8080/
Hello from the webserver!

&lt;span class="nv"&gt;$ &lt;/span&gt;curl http://localhost:8080/ping
pong
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verified memory-safe by valgrind: 0 errors, 0 leaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Then it transpiled itself
&lt;/h2&gt;

&lt;p&gt;Here's where it gets weird.&lt;/p&gt;

&lt;p&gt;Transpilatron is written in Python. So I pointed it at its own source code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx transpilatron src/transpilatron/agent.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The agent read its own Python source, wrote 400+ lines of C, fixed its own compiler errors autonomously, ran a memory audit, and produced a working binary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./out/agent &lt;span class="nt"&gt;--help&lt;/span&gt;
Usage: ./agent &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;--minimal&lt;/span&gt;|--full] &amp;lt;entry_file&amp;gt;
  &lt;span class="nt"&gt;--minimal&lt;/span&gt;  Use minimal mode: static linking, raw sockets only
  &lt;span class="nt"&gt;--full&lt;/span&gt;     Use full mode &lt;span class="o"&gt;(&lt;/span&gt;default&lt;span class="o"&gt;)&lt;/span&gt;: dynamic linking, libcurl, etc.

&lt;span class="nv"&gt;$ &lt;/span&gt;./out/agent examples/web.py
Thinking...
I&lt;span class="s1"&gt;'ll help you convert the Python project to C...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;A C binary, orchestrating an AI agent, transpiling Python to C.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Valgrind result: 0 errors, 0 leaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;Transpilatron wraps the Poolside CLI (free) as its agentic backend. The agent:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Reads your Python entry file and follows all imports&lt;/li&gt;
&lt;li&gt;Transpiles the full project to C&lt;/li&gt;
&lt;li&gt;Writes a Makefile and compiles with &lt;code&gt;-O3&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Auto-installs missing build tools via your system package manager&lt;/li&gt;
&lt;li&gt;Runs the binary under valgrind to verify zero memory leaks&lt;/li&gt;
&lt;li&gt;Audits the C for race conditions, NULL dereferences, and logic bugs&lt;/li&gt;
&lt;li&gt;Retries up to 3 times if compilation fails&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Two modes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Linking&lt;/th&gt;
&lt;th&gt;HTTP&lt;/th&gt;
&lt;th&gt;Best for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--minimal&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Static only&lt;/td&gt;
&lt;td&gt;Raw BSD sockets&lt;/td&gt;
&lt;td&gt;initramfs, scratch containers, embedded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;--full&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Dynamic permitted&lt;/td&gt;
&lt;td&gt;libcurl&lt;/td&gt;
&lt;td&gt;Web apps, ML inference, general use&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;--full&lt;/code&gt; mode supports Flask/FastAPI → libmicrohttpd, torch/tensorflow → libtorch/TFLite, OpenCV, and more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not Nuitka?
&lt;/h2&gt;

&lt;p&gt;Nuitka bundles CPython. PyInstaller bundles CPython. Both produce 30MB+ binaries that require a Python runtime.&lt;/p&gt;

&lt;p&gt;Transpilatron strips CPython entirely. The output binary has no idea Python exists.&lt;/p&gt;

&lt;p&gt;That's the only approach that works for initramfs, scratch containers, or embedded targets with no OS.&lt;/p&gt;

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



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uvx transpilatron your_code.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Requires only &lt;code&gt;uv&lt;/code&gt;. Everything else (Poolside CLI, gcc, make, valgrind) is auto-installed on first run.&lt;/p&gt;

&lt;p&gt;GitHub: &lt;a href="https://github.com/NoodlixProject/transpilatron" rel="noopener noreferrer"&gt;NoodlixProject/transpilatron&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Transpilatron was originally built to compile boot scripts for Noodlix — a Python-only OS I'm building. That project is ongoing.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>c</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
