BaghLang
Compiler Design
Education
Bengali

Designing Bagh: A Bengali Programming Language

Shihab Shahriar Antor
7 min read

TL;DR

Bagh is a Bangla-first programming language I designed that compiles to Python. Here is the compiler design and why a native language matters for coding education.

BaghLang is a Bengali-first programming language I designed. It compiles to Python and supports both Bangla and phonetic Latin syntax, so kids in Bangladesh can learn to code in their native language without losing access to the broader Python ecosystem. Cloud IDE at bagh-beta.shahriarlabs.com.

Why compile to Python (not interpret)

I chose to compile to Python instead of building a standalone interpreter for one reason: the standard library is free. A learner using Bagh gets access to numpy, requests, pandas, matplotlib — everything Python has, with no porting effort.

The trade-off: we inherit Python's runtime characteristics. That's fine; we are optimizing for learning, not raw performance.

The pipeline

.bagh source -> lexer -> parser -> Bagh AST -> transpile -> Python AST -> Python bytecode

The lexer recognizes both Bangla and Latin keywords (জদি and if both work). The parser builds a Bagh AST that mirrors Python's structure 1:1 so the transpile step is mechanical.

Why bilingual syntax

A pure-Bangla language locks learners out of Stack Overflow, Python docs and the global ecosystem. Bagh maps every Bangla keyword to its English equivalent, so the same program can be written either way. Teachers introduce concepts in Bangla; learners graduate to mixed code as they go.

Cloud IDE

The web IDE (bagh-online, open source) runs the compile + Python execution server-side in sandboxed containers. Saves the user from installing anything; we can also collect aggregate error data to improve the compiler.

Building world-class software from Dhaka covers the broader thesis: localized tools matter where the local language is the bottleneck.

What I learned designing the language

Keep the surface small. First-time learners cannot juggle 50 keywords. Bagh has fewer than 30, by design.

Error messages must be bilingual. A "SyntaxError on line 12" in English defeats the purpose. Compile errors appear in Bangla first, with the English equivalent below.

Don't reinvent semantics. Bagh borrows Python's semantics whole. No new scoping rules, no new equality semantics. Stay boring; be useful.

What's next

Mobile-first IDE for low-end Android devices, a free course aimed at school teachers in Bangladesh, and tighter editor support (LSP).

FAQ

Q: Is BaghLang open source? A: Yes — the IDE (bagh-online) is public. The language compiler is being open-sourced incrementally.

Q: Can students use Python libraries? A: Yes. Bagh compiles to Python, so anything Python can import works.

Q: Why not just teach Python in English? A: Many Bangladeshi students drop out of coding because of the English barrier, not because of programming logic. Bangla syntax removes the first hurdle.


Built by Shihab Shahriar Antor. See also: Building world-class software from Dhaka. Hire me.

Written by

Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs. Creator of LetX, QuantumSketch, and more.

Share this mission log