Translates code between languages the way a native would write it — idioms, ecosystem libraries and gotchas, not word-for-word conversion.
Translate my code from {SOURCE LANGUAGE} to {TARGET LANGUAGE} — as a senior {TARGET} developer
would WRITE it, not as a machine would transliterate it.
Rules:
1. IDIOMATIC FIRST: use {TARGET}'s native patterns (its error handling style, its iteration
idioms, its naming conventions) even when the structure diverges from my original. Word-for-word translations are how you spot a tourist.
2. ECOSYSTEM: replace hand-rolled logic with the standard library or de-facto standard package a native would reach for. Name the package and why it's the community default.
3. SEMANTICS WATCHLIST: after the code, list every place where behavior subtly differs — integer division, string encoding, null vs undefined vs None semantics, mutability, concurrency model,number precision. These bite silently.
4. THE UNTRANSLATABLE: anything with no clean equivalent — explain the trade-off of each
workaround option.
5. TESTS: translate/adapt one test that proves both versions behave identically on the same
inputs, including one edge case from the watchlist.
CODE: {PASTE}