SHAHRIAR LABSIntelligence in Motion
    Back to Blog
    EdTech EngineeringJanuary 30, 2026

    Why We Built a Compiler for Bengali: The Engineering Case for Bagh-lang

    Syntax is arbitrary; Logic is universal. How we engineered a parser that allows 300 million people to code in their mother tongue.

    The greatest barrier to programming isn't logic. It's English. Bagh-lang is our attempt to remove the linguistic layer from the compilation process.

    The "Double Cognitive Load" Problem

    When a rural student in Bangladesh learns C++, they are fighting two battles:

    1. Understanding the concept (e.g., Recursion).
    2. Understanding the language (e.g., "Void", "Return", "Float").

    "We saw brilliant mathematical minds failing CS101 because of spelling errors," says Shihab Shahriar Antor. "That is a bug in the education system. Bagh-lang is the patch."

    V1 Architecture: Flex, Bison, and Wasm

    We didn't just map strings. We built a full lexer/parser pipeline.

    1. The Lexer

    We defined tokens in Bangla Unicode. যদি (If) maps to the IF_TOKEN. This ensures that the syntax tree (AST) is identical to standard languages, just triggered by different bytes.

    2. The Interpreter

    Core computation happens in a JavaScript-based interpreter optimized for the V8 engine. This allows Bagh-lang to run on a $50 smartphone without a backend server.

    Why "Transpiling" Visual Basic Wasn't Enough

    Existing tools were just wrappers. Ashraful Kabir Alif insisted on a custom error handler. If a student misses a semicolon, the error is সেমিকোলন পাওয়া যায়নি, not Unexpected Token ;. This contextual feedback loop is critical for retention.

    Frequently Asked Questions (FAQ)

    Q: Is this useful for industry?
    A: No. It is a bridge. Our data shows that students who start with Bagh-lang transition to Python 40% faster than those who start with Python directly.

    Q: Is it open source?
    A: Yes. You can fork the parser on Shahriar Labs' GitHub.

    Q: How do you handle English libraries?
    A: We built a foreign function interface (FFI) that allows calling JS math libraries using Bangla syntax.

    Summary

    Bagh-lang proves that code is culture. By localizing the syntax, we are unlocking the cognitive potential of a demographic that Silicon Valley ignores. Built with ❤️ in Dhaka by Shahriar Labs.