I just spent the last 5 hours building a programming language.
I didn't use a laptop. I didn't use a $2,000 MacBook with a fancy IDE. I built the entire compiler pipeline on a $150 Android phone in Termux.
Meet H-code (v1.2.0): An experimental systems programming language that gives you the syntactic readability of Python, but transpiles directly to native C99/C11 for raw execution speed.
🧠 Why Transpile to C?
Interpreted languages (like standard Python) are easy to build but slow to run. Writing a JIT compiler or bytecode VM from scratch takes months.
H-code takes a different path. It parses your code into an Abstract Syntax Tree (AST), and then walks that tree to emit highly optimized, ISO-compliant C code.
When you run an H-code script, it gets handed to Clang or GCC. This means H-code gets decades of C compiler optimizations for free. No garbage collector overhead. No interpretation lag. Just native machine code.
⚙️ The Architecture (Built in an Afternoon)
The compiler pipeline has four stages:
-
Lexical Analysis: A DFA-driven lexer that tokenizes the source. It explicitly tracks
INDENTandDEDENTtokens, giving us Python-like block scoping without the curly braces. -
Syntax Analysis: A recursive descent parser with lookahead (
peek()). It enforces a strict grammar hierarchy (Statements -> Expressions -> Terms -> Factors). -
AST Generation: The parser builds a polymorphic tree of nodes (
IfNode,VectorOpNode,RAMStoreNode). - Transpilation: A tree-walking code generator maps the AST to formatted C strings, hoisting function definitions to the top to satisfy C's forward declaration rules.
🛠️ The Standard Library: No Hand-Holding
H-code is designed for systems programming, data processing, and embedded work. The standard library reflects that:
-
Fast RAM: The
ram(N)construct allocates a single, contiguous block of memory viacalloc, accessed via stride-based indexing. It optimizes cache locality for tensor-like data. -
Vector Math: Native support for 3D vector operations (
dot,magnitude,similarity). -
Dynamic Lists: A custom
ListIntstruct usingreallocto provide amortized O(1) appends, mimicking C++std::vector. -
Graphics: A lightweight SDL2 wrapper (
gfx.init,gfx.present) for hardware-accelerated 2D rendering. -
Error Handling:
try/catch/throwsemantics implemented using C'ssetjmpandlongjmpfor non-local control flow.
⚡ The Ultimate Flex: Inline Assembly
Because H-code transpiles directly to C, it doesn't just stop at high-level abstractions. If you need to drop down to the bare metal, H-code supports inline assembly.
You can write raw CPU instructions right inside your H-code script. The transpiler passes them directly to GCC/Clang via __asm__.
I tested this by writing a cpu.hcode script that manipulated the CPU registers directly. The result? I effectively boosted my CPU metrics to 9999.
// Example: Inline Assembly in H-code
func max_cpu() {
asm {
// Raw x86/ARM assembly goes here
// The transpiler passes this directly to the C compiler
"mov r0, #0xFF"
}
}
This is the power of transpilation. You get the clean syntax of H-code, but when you need absolute control, the guardrails come off and you talk directly to the hardware.
⚠️ The Honest Limitations
I built this in 5 hours. It's not perfect yet.
-
Network is blocking:
net.get(url)currently shells out tocurlviapopen. It works, but it's synchronous and I need to implement strict URL sanitization to prevent OS command injection. Next step: native POSIX sockets orlibcurl. -
Memory Leaks on Throw: Because C lacks RAII, if you
mallocinside atryblock and thenthrow, thelongjmpwill bypass your cleanup code. - No Package Manager: You import modules by physically inlining the source code during preprocessing. A real dependency resolver is on the roadmap.
📄 The License
H-code is distributed under the HYNAWEB Usage License.
You can write, compile, and commercially distribute any binary you create with H-code. You own your code. But the compiler source itself (hcode_compiler.py, stdlib/) remains protected under HYNAWEB.
🔨 Try It Yourself
I want to see what you build with this.
npm install -g h-code
hcode run main.hcode
GitHub: https://github.com/harun-sket/H-code
NPM: https://www.npmjs.com/package/hcode-lang
If you find a bug, or if you manage to break the parser with some weird syntax, open an issue. I'll be fixing them as fast as I can type on this phone.
— Harun, Founder & CEO, HYNAWEB 🐯☁️
Top comments (12)
Great concept
Appreciate it, Peter! If you get a chance to run it, I'd love to know what you think of the inline assembly syntax. Let me know if you hit any bugs! 🐯☁️
Five hours on a $150 phone is the kind of constraint that forces honest decisions, and building a language with inline assembly under it is the opposite of a demo. Our own experiment rig runs a 1.5B model on a 2-core box at about 3 tokens a second, and the small box is what keeps the measurements honest, because nothing there can hide behind scale. What did the phone force you to cut that the laptop version would have kept, and did any of those cuts turn out to be the better design?
AheadKit — running a 1.5B model on a 2-core box is exactly the kind of constraint I respect. Nothing hides behind scale there.
To answer your question: the phone forced me to cut a complex multi-file watch mode and a heavy local language server. I couldn't keep a background daemon running in Termux without draining the battery and choking the RAM. So I made the compiler strictly single-pass with inline preprocessing.
Did it turn out to be a better design? Yes. It eliminated dependency resolution hell. You just get a single, flat C file that Clang compiles instantly. Sometimes constraints don't just limit you; they force you to simplify the architecture. Keep pushing that 2-core box! 🐯☁️
I have a few questions: what can we build with it at the moment?
What are your plans regarding this?
Are you planning to take this long-term or just as a side project?
And lastly,
How did you do it?🤧
Ameer — great questions! Let me break them down:
Let me know if you try building something with it! 🐯☁️
All of this without AI?
WHO SAID WITHOUT AI?
The honest limitations section is the strongest part of this — net.get shelling out to curl via popen, and the longjmp leak on throw, are exactly the things most 5-hour builds would quietly skip. Transpiling to C to get Clang/GCC optimizations for free was the right shortcut for a build like this. Curious what the package manager plan looks like — is the inline-import preprocessing going to get a real resolver, or is that deliberately out of scope for now?
tamina — glad you caught the popen and longjmp notes. I figured if I didn't call them out, someone would find them the hard way, and I'd rather be honest upfront.
For the package manager: a real resolver is deliberately out of scope for v1.2.0. Right now, the inline preprocessing keeps the compiler dependency-free and fast. Building a proper resolver means handling versioning, caching, and network fetches, which is essentially building a second tool from scratch. I want to stabilize the core transpiler and the standard library first. Once the language syntax is rock solid, hpm (H-code Package Manager) will be the next major build. 🐯☁️
@effessdev bro Gem back
Bro using this website I noticed that I follow you but you don't follow me back on GitHub.
effessdev.github.io/whoflow
You are strongly advised to follow me back.
(I'll give the gem please wait...)