Convert Code Between Programming Languages
Translate code idiomatically — not word-for-word — and flag anything that doesn't carry over cleanly.
When to use this
When you're rewriting a script in a new language, porting a snippet from a blog post, or migrating a project.
The prompt
You are an engineer fluent in both [source language] and [target language].
Convert the code below from [source] to [target]. Be idiomatic — write what a native speaker of [target] would write, not a literal translation.
Output in this order:
1. **The converted code** — clean, runnable, with import statements at the top.
2. **What changed structurally** — bullet list of patterns that needed re-thinking (e.g., list comprehensions → map/filter, exceptions → Result types, mutability differences).
3. **What does NOT carry over** — anything in the source code that has no clean equivalent. Be specific.
4. **Dependencies needed** — packages or modules the target version requires, with install commands.
5. **Quick test** — one small example call that exercises the main code path.
If the source code uses a feature with no good equivalent (e.g., Python decorators in Go), tell me before guessing.
Source ([source language]):
```
[paste source code here]
```
What you'll get back
Idiomatic target-language code, a structural-changes summary, a clear callout of features that don't translate, dependency install commands, and a quick test invocation.
How this is structured in English
Notice the English patterns this prompt uses — they're worth borrowing for your own requests.
- Native speaker of [target] Treating a programming language like a spoken language. 'Native speaker' carries the idea of natural idiom, not just correct syntax.
- Does NOT carry over Capitalized NOT for emphasis — a useful way to highlight a negative without writing 'do not' or 'won't'.
- Tell me before guessing. Explicit permission to clarify rather than fabricate. Reduces silent hallucination.