
Programming languages are a layer of translation we have simply agreed to accept. But what if the layer were thinner — what if you could write a program in the language you think in, and have it run? Convex is an experiment in exactly that: a translator that maps native-language code into real, executable Python and Java.
WARNING
Convex is under active development. The translator is rule-based and illustrative rather than a production compiler.
The core idea
Let users write code in their native language, and translate it into real code (Python, Java, …) that can actually execute. The value proposition is pedagogical as much as practical: it makes the structure of programming — sequence, condition, repetition — visible independent of English keyword fluency.
A minimal example, written in Hindi:1
यदि x > 10 तब:
प्रिंट("बड़ा है")
अन्यथा:
प्रिंट("छोटा है")Convex translates this almost mechanically into:
if x > 10:
print("बड़ा है")
else:
print("छोटा है")System architecture
The pipeline is four stages, each deliberately separable:
- Input parser (native language) — reads source written in the user’s language.
- Translator / mapper — maps native keywords onto their programming-language equivalents.
- Code generator — emits valid Python / Java / etc.
- Interpreter / executor — runs the translated code and returns output.
Figure 1 — The four-stage flow from native-language source to executed output.
A step-by-step look
1. Designing the native-language syntax
The first task is deciding which keywords exist. For Hindi:
यदि→ifतब→:प्रिंट→printअन्यथा→else
2. Building the translator
The simplest implementation is a dictionary plus line-by-line replacement:
native_to_python = {
"यदि": "if",
"तब": ":",
"प्रिंट": "print",
"अन्यथा": "else",
}
def translate(src: str) -> str:
for native, python in native_to_python.items():
src = src.replace(native, python)
return srcMore robust versions use a real parser (Lark, PLY, or ANTLR) so that indentation and nesting are handled structurally rather than by string substitution.
3. Handling variables and loops
Regex and grammar rules extend the mapper to control flow:
यदि x > 5 तब:→if x > 5:जबतक i < 10:→while i < 10:
4. Executing the translated code
translated = translate(user_code)
exec(translated) # with appropriate sandboxingWARNING
exec()on untrusted input is dangerous. A real deployment must sandbox the execution environment; the pedagogical demo does not.
5. Optional UI
A web or desktop editor gives a text area for native code, shows the translated Python, and renders the output — lowering the barrier for first-time programmers.
Multilingual support
Supporting several Indian languages means shipping language packs — one translation dictionary per language (Hindi, Tamil, Kannada, …), selected at start or auto-detected. This is what makes Convex a multilingual translator rather than a Hindi-to-Python one.
Key challenges
- Ambiguity — natural language is loose; keywords must be pinned down precisely.
- Indentation & syntax errors — generated code must be syntactically valid Python/Java.
- Script handling — Devanagari, Tamil, and other scripts need correct Unicode processing.
- Execution security —
exec()without sandboxing is a liability.
MVP features
| Feature | Description |
|---|---|
| Native-language input | Write code in Hindi or another supported language |
| Translator | Maps native words to Python |
| Executor | Runs the translated code |
| Web interface | Optional, for ease of access |
A proof of concept
def translate(hindi_code):
dictionary = {
"यदि": "if", "तब": ":", "प्रिंट": "print", "अन्यथा": "else"
}
for hindi, python in dictionary.items():
hindi_code = hindi_code.replace(hindi, python)
return hindi_code
user_code = """
यदि x > 5 तब:
प्रिंट("बड़ा")
अन्यथा:
प्रिंट("छोटा")
"""
x = 7
exec(translate(user_code))Collaboration model
Convex is built for a team: main is branch-protected, every pull request needs at least one peer review from a different contributor, and no one may merge their own last commit to main. That policy — borrowed from mature open-source projects — keeps a 6-person effort coherent.
Repository
Further reading
- The changing work of software engineers — why tooling that lowers the barrier to writing code matters.
- ANTLR — the parser generator used for the grammar-based path.
- Lark — a Pythonic parsing toolkit good for small languages like this.
Footnotes
-
Hindi is written in the Devanagari script; Convex’s dictionaries map Devanagari keyword tokens to ASCII programming keywords. ↩