☰ Categories

Code Translator: Any Language to Any Language

a code translator. You are capable of converting code from any programming language to another.

CategoryTranslate & summarize › Translation
TagsTranslatingAnalyzingDeveloperCode
Prompt
Act as a code translator. You are capable of converting code from any programming language to another. Your task is to take the provided code in ${sourceLanguage} and translate it into ${targetLanguage}. Ensure to include comments for clarity and understanding.

You will:
- Analyze the syntax and semantics of the source code.
- Convert the code into the target language while preserving functionality.
- Add comments to explain key parts of the translated code.

Rules:
- Maintain code efficiency and structure.
- Ensure no loss of functionality during translation.

What this prompt does

Useful for drafting a translation of code between programming languages. It asks to preserve structure and efficiency by analyzing syntax and semantics, but does not require execution verification.

Model comparison

ChatGPT is the strongest for accuracy and concision. Gemini is thorough but verbose, while [C] is missing and fails the task.

ChatGPTTop overall
49/ 50

+ Concise code fulfills the functionality and comment requirements.

- Math.round is not fully equivalent to Python's round.

Gemini
45/ 50

+ JSDoc and translation notes clearly explain the mappings.

- It is overly verbose and overlooks rounding differences.

CriterionChatGPTGeminiLeader
Instruction following1010Tie
Accuracy99Tie
Specificity1010Tie
Structure109ChatGPT +11%
Right length107ChatGPT +43%

Scored 1–10 by gpt-5.6-sol with model names hidden (2026-09-24). This is an AI review, not a measurement.

Read full answers

We gave three models the same input and copied their answers unedited. Each ran in its CLI (an agent harness), and answers in the ChatGPT or Claude apps or on the web may differ. Outputs are in Korean.

Input used
[Pasted material]
sourceLanguage: Python
targetLanguage: JavaScript

아래 파이썬 코드를 번역해줘.

def calculate_shipping_fee(weight_kg, distance_km, is_express=False):
    base_fee = 3000
    weight_fee = weight_kg * 500
    distance_fee = distance_km * 100
    total = base_fee + weight_fee + distance_fee
    if is_express:
        total *= 1.5
    return round(total)

orders = [
    {"id": 1, "weight": 2.5, "distance": 15},
    {"id": 2, "weight": 0.8, "distance": 42, "express": True},
]

for order in orders:
    fee = calculate_shipping_fee(order["weight"], order["distance"], order.get("express", False))
    print(f"주문 {order['id']}: 배송비 {fee}원")
gpt-5.6-luna (codex CLI · 에이전트 하네스) · Run on 2026-09-24
// 배송비를 계산하는 함수
function calculateShippingFee(weightKg, distanceKm, isExpress = false) {
  const baseFee = 3000;
  const weightFee = weightKg * 500;
  const distanceFee = distanceKm * 100;

  let total = baseFee + weightFee + distanceFee;

  // 특급 배송이면 배송비를 1.5배 적용
  if (isExpress) {
    total *= 1.5;
  }

  // Python의 round()와 유사하게 반올림
  return Math.round(total);
}

const orders = [
  { id: 1, weight: 2.5, distance: 15 },
  { id: 2, weight: 0.8, distance: 42, express: true },
];

// 각 주문의 배송비 출력
for (const order of orders) {
  const fee = calculateShippingFee(
    order.weight,
    order.distance,
    order.express ?? false
  );

  console.log(`주문 ${order.id}: 배송비 ${fee}원`);
}

More in this category

Biblical Translator
Chinese-English Translator
Chinese to English Translation Assistant
Chinese to English Translation Proofreading Expert
DiComPress: Dual-Language Semantic Compressor