Translating short-form Python exercises to other programming languages using diverse prompting strategies
Stephen R Piccolo1, Harlan P Stevens1,2
1Department of Biology, Brigham Young University, Provo, UT 84602, USA.
Gigascience
|December 8, 2025
Summary
Large language models (LLMs) effectively translate Python programming exercises into C++, Rust, Julia, and JavaScript. This automated code translation significantly aids scientific research and education by reducing manual effort.
Area of Science:
- Computational Biology
- Bioinformatics
- Scientific Computing
Background:
- Life scientists increasingly use programming for data analysis, reproducibility, and collaboration.
- Python offers simplicity, while C++ and Rust provide efficiency for complex computations.
- Translating code between languages is labor-intensive, motivating the exploration of automated solutions.
Purpose of the Study:
- To investigate the efficacy of large language models (LLMs) for semi-automated code translation.
- To assess LLM performance in translating Python programming exercises into C++, Rust, Julia, and JavaScript.
Main Methods:
- Translated 559 short-form Python programming exercises into C++, Rust, Julia, and JavaScript using GPT-4.
- Employed three prompting strategies: instructions only, code only, and a combination of both.
- Compared the output of translated code against the original Python code for accuracy.
Main Results:
- LLM-based code translation demonstrated high success rates across all target languages.
- Rust achieved the highest translation success rate (99.5%), followed by JavaScript (98.9%), C++ (97.9%), and Julia (95.0%).
- Prompting strategy significantly impacted translation success, with combined approaches often proving most effective.
Conclusions:
- LLMs are effective tools for translating small-scale programming exercises between languages, reducing manual effort.
- The study provides valuable, freely available code translations to support scientific education and research.
- Automated code translation using LLMs shows promise for streamlining workflows in computational science.
Keywords:
Python programming languageRust programming languageautomated code translationbioinformatics educationlarge language modelstranslating programming languagesMore Related Videos
Related Concept Videos
Initiation of Translation
7.8K
7.8K
Initiation of Translation
38.2K
Initiating translation is complex because it involves multiple molecules. Initiator tRNA, ribosomal subunits, and eukaryotic initiation factors (eIFs) are all required to assemble on the initiation codon of mRNA. This process consists of several steps that are mediated by different eIFs.
First, the initiator tRNA must be selected from the pool of elongator tRNAs by eukaryotic initiation factor 2 (eIF2). The initiator tRNA (Met-tRNAi) has conserved sequence elements including modified bases at...
First, the initiator tRNA must be selected from the pool of elongator tRNAs by eukaryotic initiation factor 2 (eIF2). The initiator tRNA (Met-tRNAi) has conserved sequence elements including modified bases at...
38.2K
Improving Translational Accuracy
3.5K
3.5K
Improving Translational Accuracy
14.0K
Base complementarity between the three base pairs of mRNA codon and the tRNA anticodon is not a failsafe mechanism. Inaccuracies can range from a single mismatch to no correct base pairing at all. The free energy difference between the correct and nearly correct base pairs can be as small as 3 kcal/ mol. With complementarity being the only proofreading step, the estimated error frequency would be one wrong amino acid in every 100 amino acids incorporated. However, error frequencies observed in...
14.0K
Exercise and Muscle Performance
2.3K
Exercise induces a range of adaptations in muscle tissue, depending on the type and duration of activity. Such physical training can be broadly categorized into two types: endurance exercises and resistance exercises.
Endurance exercises
Endurance exercises involve running, swimming, or cycling, which require repetitive movements with low force output. When a person engages in endurance exercise, a few noticeable changes occur in their skeletal muscles. For instance, the number of capillaries...
Endurance exercises
Endurance exercises involve running, swimming, or cycling, which require repetitive movements with low force output. When a person engages in endurance exercise, a few noticeable changes occur in their skeletal muscles. For instance, the number of capillaries...
2.3K
Machines: Problem Solving I
661
A toggle clamp is a mechanical device commonly used for holding and clamping objects in various applications, such as woodworking, metalworking, and assembly operations. Consider a toggle clamp subjected to a force of 200 N at the handle. The vertical clamping force can be calculated, provided the dimensions of the toggle clamp are known.
The toggle clamp system is a machine structure consisting of movable, pin-connected multi-force members that form a stabilized system to transmit forces. The...
The toggle clamp system is a machine structure consisting of movable, pin-connected multi-force members that form a stabilized system to transmit forces. The...
661


