DEV Community

I Built a Self-Hosting Language, a DB Engine and a Microkernel - Entirely on My Phone

No laptop. No IDE. Just Termux and a text editor. Over the past year I shipped five systems from my Android phone: - SahajCore - a self-hosting programming language - SahajQL - a natural-language query language - SahajDB / SahajGame / SahajOS - a DB engine, game engine, microkernel Here's how the core works. SahajCore: source → machine The pipeline is classic: source → tokenizer → recursive-descent parser → AST → tree-walk interpreter → bytecode compiler → stack VM → C / WAT transpilers The bytecode compiler emits a flat instruction list. This is real output from sahajcore --compile : 0004 LOAD a 0005 LOAD b 0006 CONST 2 0007 BIN * 0008 BIN + 0009 STORE c 0014 BIN > 0015 JZ 19 Self-hosting (the fun part) The interpreter is written in SahajCore itself. The bootstrap chain: Python-hosted interpreter → runs selfhost.sahaj (interpreter written in SahajCore) → runs target.sahaj (user program) The hardest bug: recursive Fibonacci blew the Python stack because every target-level call expanded into hundreds of host frames. Fix: rewrote the demo iteratively and raised the recursion limit. Backends - C backend: emits C, compile with clang → native binary. - WASM backend: emits WAT (i32 locals/params, stack ops), assemble with wat2wasm. SahajDB A tiny relational engine with: - Write-Ahead Log (WAL) for durability - Hash index on primary key - commit() flushes to disk and clears the WAL Lessons - Constraints focus you. A phone forces small, fast iterations. - Write the interpreter in the language itself as early as possible. - Test with real programs, not toy examples. Try it pip install sahajcore pip install sahajql GitHub: github.com/sayan9168/SahajCore Happy to go deep on any part - ask me anything. Top comments (0)

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.