LLMs as Compiler for Arabic Programming Language
Summary
The paper addresses the fact that nearly all mainstream programming languages use English keywords. This is a barrier for Arabic speakers. Earlier Arabic languages such as Sakhr Basic, ARLOGO and Phoenix each needed a hand-built compiler. The authors propose APL (Arabic Programming Language). It has no conventional compiler. Instead, GPT-4 acts as a "semi-compiler": it rewrites APL source into Python, and PyRunner then executes the result. APL is written right-to-left in Arabic script, marks blocks with curly braces instead of indentation, and puts one statement per line. A single engineered prompt turns Arabic keywords into Python ones and gives identifiers English names. It also leaves Arabic string literals unchanged and reports syntax errors. The release has three parts: a Python library on GitHub built around a Compiler class, a two-pane web playground, and the paper itself. The paper reports no quantitative evaluation, only worked examples. Its value is mainly as a proof of concept: a prompted LLM can stand in for the lexer, parser and code generator of a small new language.
Key points
- APL supports only six constructs: variables, operations, reading .txt files, if-conditions, loops and functions. The authors kept it small on purpose because chained LLM prompts are fragile.
- The source code follows three surface rules: Arabic script,
{}block delimiters instead of Python indentation, and one operation per line with no;. - Translation uses GPT-4 with one system-style prompt that:
- maps Arabic keywords to Python;
- renames variables into English;
- checks syntax and returns a specific error message;
- outputs plain text rather than markdown-fenced code.
- The tooling consists of:
- a GitHub Python library whose
Compilerclass is initialised with an API key; - a playground with an Arabic right-to-left input pane on the right and the generated Python on the left.
- a GitHub Python library whose
- The authors name two main challenges:
- separating Arabic text that must be translated (keywords, names) from Arabic text that must be kept (string contents);
- the deployment cost of the GPT-4 API.
- As future work they plan to fine-tune an open-source model.
Interesting ideas
- I1. The input syntax was changed to suit the LLM rather than humans: explicit braces replace indentation, because copy-paste damages whitespace and the model handles visible delimiters more reliably. — For Mova (learn): When sending sentences or trees to an LLM teacher tier, serialize structure with explicit brackets or IDs instead of relying on layout, so whitespace damage cannot corrupt silver annotations.
- I2. The language is deliberately cut down to a few constructs, because each additional feature makes a chained LLM pipeline more fragile; scope is traded for reliability. — For Mova (learn): Give LLM teachers narrow, closed-inventory tasks (e.g., one frame type or one relation at a time) rather than open-ended full annotation, then combine the results deterministically.
- I3. The core difficulty is a split between two kinds of tokens: structural Arabic text must be translated, while Arabic inside string literals must pass through untouched. — For Mova (tokens): The tokenizer could tag spans such as quotations, code and names as "opaque content" early, so later normalisation, lemmatisation or translation steps leave them verbatim.
- I4. The translator does more than convert code: it also detects syntax errors and returns a targeted message telling the user what to fix, turning failure into feedback. — For Mova (answer): When a question or word problem cannot be mapped into the text-world, Mova could report which step failed and why instead of giving a silent wrong answer, in line with its explainability goal.
- I5. The playground shows the source and the generated output side by side so users can compare them line by line and debug easily. — For Mova (back): The text → graph → text compressor could show the original and the regenerated sentence in aligned panes, making meaning loss in the round trip easy to spot.
Cite
@misc{sibaee2024llms,
title = {{LLMs as Compiler for Arabic Programming Language}},
author = {Sibaee, Serry and Najar, Omar and Ghouti, Lahouri and Koubaa, Anis},
year = {2024},
doi = {10.48550/arxiv.2403.16087},
eprint = {2403.16087},
archivePrefix = {arXiv},
url = {https://doi.org/10.48550/arxiv.2403.16087}
}References
- Kim, S., Moon, S., Tabrizi, R., Lee, N., Mahoney, M. W., Keutzer, K., Gholami, A. (2023, December 7). ”An LLM Compiler for Parallel Function Calling.” In Proceedings of the Conference Name (pp. PageRange). Springer. find
- Author. (2023, February 26). ”LLMs are compilers.” Online article. Retrieved from https://vivekhaldar.com/articles/llms-are-compilers/ ↗
- Liventsev, V., Grishina, A., Härmä, A., Moonen, L. (2023, April 20). ”Fully Autonomous Programming with Large Language Models.” In Proceedings of the Conference Name (pp. PageRange). Springer. find
- Arabic Sakhr Basic (1987, MSX, Al Alamiah). find
- ARLOGO project homepage. http://arlogo.sourceforge.net/. Retrieved February 15, 2017. ↗
- Mansoor Al-A’Ali, Mohammed Hamid. ”Design of an Arabic programming language (ARABLAN).” Journal Computer Languages, Volume 21, Issue 3-4, pp. 191-201, October, 1995. find
- Essam Mohammad Arif. ”Design of an Arabic object-oriented programming language and a help system for pedagogical purposes.” Doctoral Dissertation, Illinois Institute of Technology Chicago, IL, USA, 1995. find
- AMORIA homepage. http://ammoria.sourceforge.net/. Retrieved Dec 14, 2018. ↗
- Ebda3 homepage. http://ebda3lang.blogspot.com/. Retrieved Dec 14, 2018. ↗
- Jeem homepage. http://www.jeemlang.com/. Retrieved Dec 14, 2018. ↗
- Youssef Bassil, Aziz Barbar. ”Loughaty/MyProLang – My Programming Language - A Template-Driven Automatic Natural Programming Language.” Proceedings of the World Congress on Engineering and Computer Science, WCECS 2008, San Francisco, USA. find
- Qlb GitHub. https://github.com/nasser/---. Retrieved Dec 14, 2018. ↗
- Kalimat GitHub. https://github.com/lordadamson/kalimat. Retrieved February 15, 2017. ↗
- Phoenix - The Arabic Object-Oriented Programming Language Youssef Bassil, LACSC – Lebanese Association for Computational Sciences, Registered under No. 957, 2011, Beirut, Lebanon find
- The State of Fortran, Laurence Kedward and others March 2022, Computing in Science and Engineering. doi:10.1109/MCSE.2022.3159862 ↗
- MLSA: a static bugs analysis tool based on LLVM IR Hongliang Liang and others International Journal of Networked and Distributed Computing, Vol. 4, No. 3 (July 2016), 137-144 Serry Sibaee, Omar Najar, lghouti, akoubaa find
- Compiling quantamorphisms for the IBM Q Experience. Ana Neri, and Others arXiv:2010.10510v1 [quant-ph] 21 Oct 2020 ↗
- Large Language Models: A Survey arXiv:2402.06196v1 [cs.CL] 9 Feb 2024 ↗ our card
- PseuToPy: Towards a Non-English Natural Programming Language Patrick Wang ICER 2021: Proceedings of the 17th ACM Conference on International Computing Education ResearchAugust 2021Pages 429–430https://doi.org/10.1145/3446871.3469787 ↗
This page in Markdown → https://md.research.elamur.ai/free/en/papers/sibaee-2024-llms-compiler-arabic-programming-language/