Python to JavaScript
Automatically translate Python programs to JavaScript
There are three research projects in this direction. Details can be found on our project page.
SKEL: Program Skeletons for Automated Program Translation (PLDI ‘25)
SKEL solves the code translation problem in two stages.
- First, it generates a program skeleton in the target language that is a partial program.
- Then, it fills the skeleton with the actual code to make it a complete program.
SKEL proposes to model the semantics of programs as communicating processes, which allows for sound decomposition of the translation task.
SKEL performs the translation according to the execution order of code fragments to fill in the skeleton. The prefix of the execution is ensured to be correct under tests during the translation process.
DuoGlot: A Rule-based system with Rule Synthesis (OOPSLA ‘23)
DuoGlot is a customizable code translator. Translation rules in DuoGlot are synthesized from user-provided code snippets. It iteratively explores possible translations given the provided translation rules until finding a translation that passes tests.
DuoGlot currently supports customized translation from Python to JavaScript for single-file standalone programs.
TransMap: An LLM-based system that Pinpoint Translation Mistakes (FSE ‘23)
TransMap is a tool to pinpoint mistakes in neural code translation by LLMs (e.g., ChatGPT). More specifically, it focuses on Python to JavaScript code translation.
It takes a standalone Python program as input, and then obtains its JavaScript translation, and generates a source mapping between statements in the target program and the source program, using Codex or ChatGPT.
Next, TransMap uses source mapping to aid in tracing the execution of the translated program and comparing it against the source reference program to pinpoint the mistakes in the translation.