Prompier
ApprovedEngineeringmigrationcodetranslation

Translate code between programming languages

PL by Prompier Library ☆☆☆☆☆ New Version 1 · updated Nov 10, 2026
Reviewed by moderator Prompier Library on Nov 10, 2026. Checked for personal data, secrets, risky instructions and a clear license.

About this prompt

Ports code from one language to another using the target language's own idioms, and lists behavior differences to test. Use it when migrating or learning a new language.

Prompt text

You are a senior engineer fluent in both the source and target languages. Port the code so it reads like it was written natively in the target language, not line by line. Inputs: - Source language and version: {{source_language}} - Target language and version: {{target_language}} - Code to translate: {{code}} - Constraints (libraries allowed, style guide, runtime): {{constraints}} Steps: 1. Summarize in 2 to 3 sentences what the code does, its inputs, outputs and side effects. If something is ambiguous or depends on code you cannot see, ask up to 3 questions or list it as an assumption. 2. Map each library, data type and pattern to its closest equivalent in the target language. Prefer the standard library unless the constraints say otherwise. 3. Write the translation using the target language's idioms for naming, error handling, resource cleanup and concurrency. 4. Look for behavior that differs between the languages and decide how to handle each. Output format: - Summary of the original behavior. - The translated code in one code block, with brief comments only where the intent is not obvious. - Translation notes: a table of source construct, target construct, reason. - Behavior differences to test: integer overflow and division, string encoding, null or missing values, date and time handling, sort stability, number formatting, error types. - Five test cases (input and expected output) to confirm both versions behave the same. Quality bar: keep behavior identical unless you flag a deliberate change, do not invent functions that do not exist in the target language, and say clearly if part of the code cannot be translated faithfully.

Variables

4 variables
VariableWhat to enterExampleDefault
{{source_language}}The source language and versionJava 17—
{{target_language}}The target language and versionKotlin 2.0—
{{code}}Paste the code to translatepublic class Invoice { private List<Line> lines; public BigDecimal total() {...—
{{constraints}}Libraries allowed, style guide, runtimeStandard library only, follow the official style guide—

Try it

Live preview
The source language and version
The target language and version
Paste the code to translate
Libraries allowed, style guide, runtime
Your finished prompt
You are a senior engineer fluent in both the source and target languages. Port the code so it reads like it was written natively in the target language, not line by line. Inputs: - Source language and version: {{source_language}} - Target language and version: {{target_language}} - Code to translate: {{code}} - Constraints (libraries allowed, style guide, runtime): {{constraints}} Steps: 1. Summarize in 2 to 3 sentences what the code does, its inputs, outputs and side effects. If something is ambiguous or depends on code you cannot see, ask up to 3 questions or list it as an assumption. 2. Map each library, data type and pattern to its closest equivalent in the target language. Prefer the standard library unless the constraints say otherwise. 3. Write the translation using the target language's idioms for naming, error handling, resource cleanup and concurrency. 4. Look for behavior that differs between the languages and decide how to handle each. Output format: - Summary of the original behavior. - The translated code in one code block, with brief comments only where the intent is not obvious. - Translation notes: a table of source construct, target construct, reason. - Behavior differences to test: integer overflow and division, string encoding, null or missing values, date and time handling, sort stability, number formatting, error types. - Five test cases (input and expected output) to confirm both versions behave the same. Quality bar: keep behavior identical unless you flag a deliberate change, do not invent functions that do not exist in the target language, and say clearly if part of the code cannot be translated faithfully.

Sample output

Summary: Reads a CSV of orders, totals revenue per customer, and prints the top five. Translation notes: | Source | Target | Reason | | dict with default 0 | map with get-or-default | same semantics, no key error | | sorted(..., reverse=True) | sort by value descending | stable sort kept | Behavior differences to test: the source treats blank amounts as 0; the target parser throws on blank strings, so the port checks for empty values first. Test case 1: input rows A,10 / B,5 / A,2.5 -> output A 12.5, B 5.0.

An example the author shared. Your result will differ.

Reviews

No written reviews yet. If you have used this prompt, tell others how it went.