
After studying this material, students should be able to:
Code translation means converting a program written in one programming language (PL) into another.
Python Code → [Translation] → Java Code
| Challenge | Explanation |
|---|---|
| Scale | Real projects have thousands of lines of code |
| Dependencies | Files reference each other in complex ways |
| Language specificity | Each PL has unique syntax, libraries, idioms |
| Validation | Translated code must actually work, not just look right |
Most prior techniques only work for one specific language pair (e.g., Java → Python)
This means:
A translation unit is the smallest meaningful chunk of code that gets translated independently — typically a function, class, or file.
Repository
├── file1.py → contains 5 translation units
├── file2.py → contains 3 translation units
└── file3.py → contains 7 translation units
Total: 15 translation units
Validation means verifying the translated code behaves identically to the original.
Original Python function → returns [1, 2, 3]
Translated Java method → must also return [1, 2, 3]
The primary validation method used: test pass rate (running tests and checking if they pass)
A system is language-agnostic if it works regardless of which programming language is involved — no special hardcoding per language pair.
❌ Language-specific: Only handles Java → Python
✅ Language-agnostic: Handles Java → Python
Python → C++
C++ → JavaScript
... and more
A programming agent is an AI system that can autonomously:
Agent Loop:
[Observe] → [Think] → [Act] → [Observe results] → repeat
One AI handles EVERYTHING:
- Understanding the repository
- Translating each file
- Running tests
- Fixing errors
- Managing dependencies
Problem: Overloaded, loses context, becomes inefficient
Specialized agents work together:
[Orchestrator Agent]
↓
[Translation Agent] → [Validation Agent] → [Repair Agent]
Benefit: Each agent focuses on what it does best
Each agent can dynamically select tools appropriate for the target language:
Target = Java? → Agent uses javac, JUnit
Target = Python? → Agent uses pytest, mypy
Target = C++? → Agent uses g++, gtest
No hardcoding required — the agent discovers and uses the right tools autonomously.
INPUT: Source repository (any PL)
+ Target PL specification
↓ ReCodeAgent ↓
OUTPUT: Fully translated & validated repository
User effort required: Minimal — just provide source code and name the target language
┌─────────────────────────────────────────┐
│ RECODEAGENT WORKFLOW │
│ │
│ 1. ANALYSIS AGENT │
│ → Understands repo structure │
│ → Identifies translation units │
│ → Maps dependencies │
│ │
│ 2. TRANSLATION AGENT │
│ → Converts code unit by unit │
│ → Handles language-specific idioms │
│ │
│ 3. VALIDATION AGENT │
│ → Runs tests in target language │
│ → Uses PL-specific tools │
│ → Reports failures │
│ │
│ 4. REPAIR AGENT │
│ → Fixes translation errors │
│ → Iterates until tests pass │
└─────────────────────────────────────────┘
ReCodeAgent requires zero manual intervention during the process:
Traditional approach:
Human → Tool → Human reviews → Tool → Human fixes → ...
ReCodeAgent:
Human provides input → ReCodeAgent runs → Human receives output
| Parameter | Value |
|---|---|
| Projects tested | 118 real-world projects |
| Average project size | 1,975 lines of code |
| Average translation units/project | 43 |
| Programming languages covered | 6 PLs |
| Language pairs tested | 4 PL pairs |
Prior techniques: ████████░░░░░░░░ (baseline)
ReCodeAgent: ████████████████ (+60.8% improvement)
ReCodeAgent improves test pass rate by 60.8% over the best prior technique
Average cost per project: $15.3
This refers to LLM API costs — relatively affordable for full repository translation
This is a critical finding:
| Metric | Multi-Agent (ReCodeAgent) | Single-Agent |
|---|---|---|
| Test Pass Rate | ✅ Baseline | ❌ -40.4% lower |
| Trajectory Length | ✅ Efficient | ❌ 28% longer |
| Efficiency over time | ✅ Consistent | ❌ Persistently inefficient |
What "trajectory" means: The sequence of steps/actions an agent takes to complete a task
Efficient trajectory:
Step 1 → Step 2 → Step 3 → ✅ Done
Inefficient trajectory (single-agent):
Step 1 → Step 2 → Step 3 → Step 4 → Step 5 →
Step 6 → Step 7 → Step 8 → ❌ Still failing
ReCodeAgent was compared against four alternative approaches:
Neuro-Symbolic approaches:
→ Combine neural networks (LLMs) with symbolic rules
→ More rigid, often language-specific
→ Less autonomous
Agentic approaches:
→ AI agents that reason and act dynamically
→ More flexible, can handle novel situations
→ ReCodeAgent is the most autonomous of these
The paper doesn't just measure outcomes — it also studies how ReCodeAgent works:
Outcome metric: Did the tests pass? (yes/no)
Process metric: How efficiently did it get there?
- How many steps?
- Were steps productive?
- Did it get stuck in loops?
This matters because an agent could pass tests but waste enormous resources doing so.
PROBLEM: Repository-level code translation
is hard, language-specific, and not scalable
↓
SOLUTION: Multi-agent workflow (ReCodeAgent)
- Autonomous agents with specialized roles
- Language-agnostic tool use
- Iterative validation and repair
↓
RESULT: 60.8% better test pass rates
Works across 6 PLs and 4 PL pairs
Multi-agent >> Single-agent
| # | Principle |
|---|---|
| 1 | Scale matters — repository-level ≠ function-level translation |
| 2 | Validation is essential — translation without testing is incomplete |
| 3 | Specialization improves performance — multi-agent beats single-agent |
| 4 | Autonomy enables agnosticism — agents adapt to any language dynamically |
| 5 | Process efficiency matters — not just whether it works, but how efficiently |
Answers: Review Steps 1, 2, 3, 4, and 5 respectively if you're unsure about any of these.