Introducing Bhash (भाष): an open-source Devanagari programming language—with a browser playground and classroom lessons

Suggested category: Project Showcase. forum.fossunited.org

Namaste, FOSS United community!

I’m sharing Bhash (भाष), an early-stage, open-source programming language that lets learners write programs using Devanagari keywords and identifiers.

Bhash is a project of Nij Bhasha Sanstha, the nonprofit behind Bhashitva. Our broader mission is to make knowledge and tools for creating knowledge accessible to people who primarily work in Indian languages.

With Bhash, we’re exploring a practical question: can students begin learning programming concepts in a familiar language, then carry that understanding into Java, C#, and other languages?

Here’s a small example:

कार्य गुणनफल(संख्या: पूर्णांक) -> पूर्णांक {
    यदि (संख्या <= १) {
        लौटाओ १;
    }
    लौटाओ संख्या * गुणनफल(संख्या - १);
}

कार्य मुख्य() -> शून्य {
    लिखो(गुणनफल(५));
}

Output: १२०

What’s available today

  • A working compiler, written in Java, targeting JVM, .NET CLR, and browser WebAssembly backed by .NET.

  • A mobile-friendly browser playground where you can write and run Bhash without installing Java or .NET.

  • Twelve introductory lessons with Hindi lesson plans, runnable examples, coding challenges, and reference solutions.

  • A VS Code extension with Devanagari syntax highlighting, completion, compiler diagnostics, navigation, and build/run commands. It has been submitted to the Visual Studio Marketplace and is awaiting publication.

The language already supports functions, classes, inheritance, interfaces, generics, arrays, lists/maps, collection iteration, exceptions, packages, and multi-file projects.

A bridge to familiar programming concepts

The lessons explicitly connect Bhash constructs to their English equivalents:

Bhash Familiar concept
यदि / अन्यथा if / else
लौटाओ return
जबतक while
वर्ग class
अनुबंध interface
प्रयास / पकड़ो / अंततः try / catch / finally

The teacher guide also explains differences that a simple keyword translation would miss. The aim is for learners to develop transferable understanding of algorithms, types, state, and program structure.

Try it and help shape it

Bhash is licensed under Apache 2.0. It is still evolving, and I would welcome candid feedback—especially from teachers, students, compiler developers, and people working on Indic-language computing.

Some useful starting points for contributors:

  • Try a lesson with learners and tell us where they get stuck.

  • Review the Devanagari terminology and suggest clearer alternatives.

  • Test the playground on phones and slower connections.

  • Contribute exercises, documentation, compiler fixes, or editor improvements.

If your FOSS club or teaching community would like to experiment with Bhash, I’d be glad to discuss a small introductory session here.

What would make this useful in your classroom or community?

5 Likes

VS Code extension is now approved and is available for download and use. Bhash (भाष) - Visual Studio Marketplace

This is interesting @manoj_srivastava . I don’t program in any other language than english yet of course :slight_smile: I have noticed that most folks (Indian) don’t even write comments in local languages. However, there are many Chinese software projects I have seen which have extensive comments in Chinese.

What are your thoughts about the relevance of using local languages for programming ?

I have a thought running for a while that this “programming” in our languages may have well have uses, but must not be a straightforward “translation” of the control constructs of regular programming languages. I mean to say - we are comfortable mixing languages, where necessary - e.g. regular speech, TV shows etc. So, are there some “words” you could layer on top of english to improve the programming experience in local languages ? I haven’t had a look at the links yet, so if there is something I must look at before asking such questions - do send them my way!

Thank you for these thoughtful questions. I agree that programming in an Indian language needs to offer more than translated keywords.

For me, the main relevance is lowering the barrier between understanding an idea and expressing it in code. Someone may understand a problem perfectly well in Hindi, yet have to learn unfamiliar English terminology alongside programming concepts. English proficiency should not have to be a prerequisite for exploring computation.

Your point about mixing languages is particularly useful. I don’t think programmers should have to choose between an entirely Hindi world and an entirely English one. Familiar English terms, library names and existing tools should be able to coexist with local-language identifiers, comments and explanations. The useful boundary will probably emerge through actual use rather than a rule imposed in advance.

Bhash currently retains familiar programming structures while allowing expression in Devanagari. That is a starting point. The broader work includes understandable diagnostics, standard-library documentation and tutorials with Hindi explanations and English terminology alongside them. Those may matter more to a learner than the spelling of a keyword.

I would also distinguish making code approachable from making it resemble everyday speech. Natural-language-like syntax can introduce ambiguity; predictable rules are valuable when learning and debugging. But that leaves considerable room to improve terminology and how concepts are explained.

I’d be interested in examples of the “words layered on top of English” you have in mind. A good test would be whether they make a real program easier to understand or write.

There’s no prerequisite reading needed to ask these questions :slightly_smiling_face: If you’d like to experiment, the playground is the quickest introduction, and the source repository has examples and tutorials. Feedback on where the language feels helpful—or merely translated—would be especially valuable.

1 Like

Yes, 100%. I couldn’t have said this better myself either !

A reasonable starting point. Bhash is a 100% two-way equivalent from regular programming, so it would be useful to have a converter from say - abundantly available FOSS code to Bhash. That way, a learner can get larger examples for free, rather than thinking it’s a “new language” ? Do look at additional thoughts related to this matter at the end of this post.

Fair point. Ambiguity of natural languages is an important aspect, and it becomes even more fun with LLMs/AI in the picture.

At the recently concluded IICT 2026 conference, I posed the question of programming in Indian Languages to Prof Kishore Nandivada, who is well known in the compiler world. His opinion was that with LLMs in the picture, we should be asking what programming is! He illustrated this saying let’s say a user wants to create a program, they are free to give the spec in whatever language, based on which the AI tools could generate reasonable output, using an internal translation from the source language to english. This seemed like a good response during the conference, and I could not find immediate fault with the Professor’s reasoning :smiley:

After I came back home, my mind was still on it. Then I realized a potential limitation - translation from any indian language to english, is lossy. This then creates extra burden in the verification step for the human “programmer”. And indeed, one may very well argue that internal idiotic translations (including idiomatic translations), and many other translation #FAILs would create weird barriers for humans, that would be very hard to overcome. 90% of Indians are not well versed in english, so this is not a small matter.

How I wish I had examples! My mind is roaming around in this garden, but I haven’t found the flowers yet.

So - for now let me close by just telling you what the utility of such layering could be. To start with, we have to appreciate the role of a languages - as in what each language allows a user to express. English is great for expressing specifics. The vocabulary aids dealing with multiple levels of abstraction, while at the same time maintaining precision. The other extreme is Sanskrit. Sanskrit is great for… generalizations ? That’s the power of that language! That is why Sanskrit is the preferred language for expressing philosophical concepts. (no idea about Latin btw!)

So - let’s say you now want to write a minimal spec of a hypothetical program that deals with many generalizations, you could choose english for dealing with specifics. Sanskrit for generics.

Here are two fun examples:

धर्मो रक्षति रक्षितः | Generate a license to protect software dharma.

software dharma here is “FOSS” !

and what should get generated as output ? Maybe GPL/AGPL 3, or something else even more revolutionary !

Hopefully this example makes sense. If not just ask for an explanation !

ಧರ್ಮೋ ರಕ್ಷತಿ ರಕ್ಷಿತಃ . Create a mafia game where the crooks follow the chora dharma. Further, use a monte-carlo simulation to establish the minimum size of the mafia that cannot be eliminated by an uninformed community of 1000-30000 people, and report the result.

Just in case you aren’t familiar with the mafia game, refer to it’s wikipedia page. And of course, chora dharma here means “dharma of thieves” !

Of course, I switched the script to Kannada here, without change in intent of the first sentence. So see the reference to v2 below.

An alternate direction further for Bhash ?

I haven’t done any compiler development almost ever, but I suspect there are better ways in which you can execute these ideas. E.g. instead of thinking of Bhash as a standalone compiler, would it make sense to think of it as “Bhash+” extensions ? E.g. Bhash+Rust, or Bhash+C, or whatever ! Bhash then become a patchset on top of the LLVM toolchain. It provides additional alternate keywords as language helpers. This will make it easy for Bhash to track upstream improvements, and thus - more people might even try this out in a variety of projects. Furthermore, the same ideas could apply in other countries - like China, who, like I said are already comfortable writing comments in Mandarin.

So, Rust => Bhash+Rust (v1) => Bhash+I10N+I18N+Rust (v2)

I10N stands for localization. I18N stands for internationalization.

Now at v2 you are looking at serious traction, and freedom for people to code in their own languages.

Of course, moving across languages is simple enough. That patchset would have equivalent language keywords for the root keyword. Thus, substituting alternate language keywords in the AST, and mapping it back to the source code is a simple way of generating source code in different languages ! What say ?

Also tagging @Ashutosh_Pandey who actually works in the area of Compilers, and indeed runs the IICT conference mentioned at the beginning of this post, plus LLVM Social Bangalore. Ashutosh - how easy would it be to implement this “Bhash v2” concept using LLVM ? Upstreaming chances ?

1 Like

Thank you, Shree. There are several useful directions here, particularly the idea of making existing examples accessible and your point about the human’s ability to verify AI-generated code.

On converting existing code to Bhash: I like the educational value of this. A learner could examine the same algorithm in Bhash and another language, with explanations connecting the concepts.

One clarification, though: familiar programming constructs do not make Bhash a completely interchangeable representation of arbitrary existing code. A reliable converter would need to account for differences in types, runtime behavior, libraries, and language-specific features—not just keywords. A practical starting point could be a defined subset of small educational programs, displayed side by side. That would let us test its usefulness before attempting broader translation.

On AI and programming in Indian languages: Your verification point gets to the heart of why I think this work remains relevant. Being able to ask for a program in Hindi is valuable; being able to understand, question, and modify the result is equally important.

I would separate that concern from the assumption that an LLM necessarily translates everything internally into English. We need not assume that particular mechanism for the underlying problem to exist: intent can be lost or misinterpreted between a request and an implementation. If the resulting code, explanations, and diagnostics are inaccessible to the person making the request, meaningful verification becomes harder.

For Bhash, this suggests a useful goal: learners should be able to follow the path from “their intention → the program → its behavior → an explanation of what went wrong”, using language they understand.

On your Sanskrit examples: I take your point to be that a culturally meaningful expression can convey intent that a literal translation may miss. That is worth exploring without needing to assign fixed strengths to different languages.

The interesting next step is making the implied meaning explicit. In the mafia example, what rules does chora dharma impose on the agents? What information may they share, and what counts as elimination or survival? A system could ask those questions in the user’s language, then turn the answers into inspectable rules and tests. That seems a promising connection between expressive language and precise computation.

On “Bhash+” and LLVM: I see two related approaches here:

  • A programming language with its own defined semantics and learning environment.
  • Localized ways of writing an existing language while preserving that language’s semantics and ecosystem.

Bhash currently follows the first approach; your proposal explores the second. A small prototype of the second could be valuable. Technically, alternate keywords would generally be handled in the language frontend, before or while constructing the AST, rather than through changes to LLVM itself. Producing readable source again would also require preserving identifiers, comments, formatting, and source locations.

For now, my immediate priority is to get Bhash into learners’ and teachers’ hands and discover which barriers actually matter. Alongside that, a limited experiment with localized syntax and paired examples could help us compare approaches.

@Ashutosh_Pandey, I would welcome your thoughts on the smallest useful experiment here—especially one that lets us test the educational benefit without taking on a large compiler fork.

Thanks again, Shree. The question I would like these experiments to answer is: “does this help someone understand and control a program that would otherwise feel inaccessible to them?”

Hi @manoj_srivastava and @Corpo-Rate_Kumar ,

Thanks for the tag. I have a few suggestions.

Re: LLVM, I believe this will require a significant amount of work for unclear gains. Yes, an LLVM frontend would give you free support to run Bhash on all backends supported by LLVM, but LLVM moves really fast, and maintaining an out-of-tree fork is very hard. It’s so hard that multiple languages like Zig have had to move away from LLVM because their relatively small dev teams struggle with keeping pace with upstream LLVM.

That doesn’t mean Bhash can’t do better than it is now though; I have two main suggestions :slight_smile:

  1. Use the Truffle Language framework (GraalVM): Truffle Language Implementation Framework
    From the page :

“The Truffle language implementation framework (Truffle) is an open source library for building tools and programming languages implementations as interpreters for self-modifying Abstract Syntax Trees. Together with the open source Graal compiler, Truffle represents a significant step forward in programming language implementation technology in the current era of dynamic languages.”

GraalVM is very performant and is built on top of the JVM, so at least for Bhash, which already targets the JVM, this should be much easier to move to than LLVM. Truffle is also very compact, so writing a Bhash implementation shouldn’t take more than a few hundred lines (an LLM should be able to do it in one pass). GraalVM also has first class support for the JVM family of languages and also the LLVM family of languages.

  1. Add support for Jupyter Notebooks: Project Jupyter | Try Jupyter

I noticed the focus on providing a browser-based ‘playground’ for the language. Providing support for a REPL (Read-Eval-Print-Loop) and Jupyter notebooks would go a long way in building a library of ‘shareable’ and ‘hackable’ examples for your language. You could demo features in isolation without having to ask users to install anything. This goal is not even orthogonal to 1. above, as GraalVM already supports WASM (Webassembly). Jupyter is a great way to demo language features.

2 Likes

Thank you, @Ashutosh_Pandey, for taking the time to look at Bhash and share these suggestions. The Jupyter notebook idea is particularly useful for the educational direction I want to pursue.

I plan to start with a small notebook pilot, adapting a few existing Hindi lessons on variables, conditions, and loops. Bringing explanations, runnable examples, results, and exercises together should make it easier for students to experiment and for teachers to share and adapt the material. Initially, each code cell would run as an independent Bhash program using the existing compiler. Persistent sessions and a fuller REPL can follow as we learn what students and teachers need.

One update I should have mentioned earlier: Bhash now has a working, experimental LLVM-based native backend alongside its JVM, .NET, and browser WebAssembly targets. It generates LLVM IR and uses the LLVM toolchain without maintaining a modified LLVM fork. I appreciate your caution about maintenance; compatibility and runtime support still require work.

Given that progress, I won’t be pursuing Truffle at this stage. I don’t currently see enough additional benefit for Bhash’s immediate goals to justify implementing and maintaining another execution engine. I would prefer to focus that effort on the learning experience and classroom feedback.

Your notebook suggestion gives me a concrete next step toward that goal. Thank you again—I’d be glad to share the pilot here once it is ready and hear your feedback.

2 Likes

Bhash has been updated and function declarations now use फलन, and collection iteration follows Hindi collection-first order: प्रत्येक (संख्याएँ में अंक: पूर्णांक). The old keyword and binding-first loop forms are intentionally rejected. Arrays, lists, byte buffers and one/two-binding map loops retain their types, evaluation order, errors and runtime/GC semantics.

1 Like

Jupyter Notebook support is coming soon…

1 Like

You can try Bhash with Jupyter Notebook now.

Install the Bhash Jupyter kernel and Hindi starter notebook with a full JDK 17 or newer and Python 3.8 or newer. The wheel includes the Bhash compiler. Maven and a source checkout are unnecessary.

python -m pip install "bhash-jupyter[lab] @ https://github.com/bhashitva/bhash/releases/download/jupyter-0.1.0/bhash_jupyter-0.1.0-py3-none-any.whl"
python -m bhash_jupyter.install --notebook Hindi-Starter.ipynb
python -m jupyterlab Hindi-Starter.ipynb

Select Bhash (भाष) and run the cells in order. Run the cell that increments कुल twice to see २ and then ४. Use --java when your JDK is outside PATH.

The kernel supports persistent scalar and text bindings, named functions, and top-level await. Interrupting execution clears the session. See the Jupyter guide for details.

This is a remarkable project with immense educational potential! Targeting JVM, .NET CLR, and WebAssembly out of the gate is a very ambitious and solid architecture choice.

A few compiler design and language engineering considerations that might be helpful as you expand Bhash:

  1. Unicode Normalization & Identifier Equivalence (UAX #31):
    In Devanagari, text input from different OS keyboards (e.g. InScript, Google Indic, phonetics) can emit subtly different combining character sequences (such as nukta ordering, or NFC vs. NFD representations of composite glyphs like क्ष or ज्ञ). Conforming the lexer strictly to Unicode Standard Annex #31 (Unicode Identifier and Pattern Syntax) and running an upfront NFC (Canonical Decomposition, followed by Canonical Composition) normalization pass on the source stream before tokenization will prevent baffling compiler errors where visually identical variable names fail to match in the symbol table.

  2. Zero-Width Joiner (ZWJ) & Non-Joiner (ZWNJ) Handling:
    In Indian scripts, ZWJ (U+200D) and ZWNJ (U+200C) are often typed to control conjunct ligatures. The lexer should explicitly classify whether joiners are valid within identifiers or stripped during the canonical tokenization step so ligature variations don’t break AST construction.

  3. Bytecode Lowering & Calling Conventions:
    Targeting both JVM bytecode and CLR CIL is great. For recursive constructs (like the factorial example कार्य गुणनफल), are you planning to support tail-call optimization (tailcall opcode in CLR) during the AST lowering phase to prevent stack overflow errors for deep recursions when learners experiment with larger numbers?

  4. Language Server Protocol (LSP):
    Even a minimal LSP implementation (providing diagnostics squiggles, hover type hints, and auto-completion for Devanagari keywords) would make the browser playground and classroom experience feel as polished as mainstream developer environments.

Kudos to you and the Nij Bhasha Sanstha team for driving open-source compiler tooling forward!

1 Like

Thank you for taking the time to give Bhash such thoughtful and specific feedback. The Unicode points are especially relevant for students who may type on one keyboard and paste examples from lessons written on another. I’d like to test those workflows with InScript and phonetic keyboards, use NFC for identifier matching, and give learners a clear diagnostic when a joiner appears where Bhash doesn’t allow it. The compiler should preserve the original source so the editor can point to the exact character.

I also see a natural next step in your LSP suggestion. I’d start with live diagnostics and Devanagari keyword completion in VS Code, with the goal of reusing the same compiler checks in the playground. A student should be able to see where a name went wrong while typing, before pressing Run.

On tail calls, the factorial example gives us a good teaching opportunity. The straightforward version still has to multiply after the recursive call returns. An accumulator version would let us demonstrate a true tail call and explore whether Bhash can optimize direct self-recursion consistently across the JVM, CLR, and WebAssembly targets.

Thanks again for looking at Bhash from both the compiler and the learner’s perspective. If you have any Devanagari identifier examples that have caused trouble across keyboards or editors, I’d be glad to try them in Bhash.

Please use the latest version located at

If upgrading from a previous version, please use the following command:

python -m pip install --upgrade
“bhash-jupyter @ https://github.com/bhashitva/bhash/releases/download/jupyter-0.1.3/bhash_jupyter-0.1.3-py3-none-any.whl”

python -m bhash_jupyter.install

Your suggestions 1, 2 and 4 have been addressed (to a large extent I think).

Please check out the latest release and let me know if you see any issues.

All three packages: playground, vs code extension and Jupyter Notebook kernel have these changes.

Best regards,

Manoj

Hmm - sorry if this sounds illiterate in compiler lingo. I don’t have so much background. So - question: Does any of this mean you are creating new control flow methods ?

No it does not create new control flow method.

If is equivalent to foreach (अंक: पूर्णांक in संख्याएँ).

The order of the two variables is swapped so that it is more meaningful in Hindi.

Thanks,

Manoj

1 Like

Programming in Bhash, book is now available for download from https://github.com/bhashitva/bhash/releases/download/book-hi-1.1.0/bhash-book-1.1.0-hi.pdf

You can also read it online at https://github.com/bhashitva/bhash/blob/main/book/README.md

Swapping the loop binding order to match natural Hindi postposition phrasing (collection first, then element) makes a lot of sense for first-time students reading the code aloud. Out of curiosity, do compiler error messages also point to line/column spans in Devanagari or do they include an English fallback for IDE tooling?

Thanks for endorsing the parameter order change. The compiler error messages point to line/column spans in Devanagari. The reported line number is off by one I think.