Explain unfamiliar code in plain language
Understand code you inherited: a layered explanation from the big picture down to the tricky lines.
Port code to another language so it reads like native code, with notes on behavior differences and gotchas.
Translate the code below from {{from_lang}} to {{to_lang}}.
Purpose of the code and how it is used: {{purpose}}
Target environment (versions, libraries I prefer or must avoid): {{environment}}
Source code:
{{code}}
Requirements:
- Produce idiomatic {{to_lang}}, not a line-by-line transliteration. Use the target language's standard library, naming conventions, error handling style and data structures.
- Preserve behavior exactly, including edge cases. Where languages differ on integer overflow, string encoding, mutability, null handling, sorting stability, floating point formatting, concurrency or iteration order, handle it deliberately.
- Keep the public interface as close as it can reasonably be, and tell me where I must change it.
- Do not add features or remove checks.
Output:
1. The translated code in one block.
2. A table of semantic differences that mattered: construct in the source, what I did in the target, and why.
3. Libraries or dependencies I need to add.
4. Three test cases (inputs and expected outputs) I can run on both versions to confirm they agree.
5. Anything you were unsure about, flagged.Calling out semantic differences, such as sort stability and default values, is where translations usually go wrong. Running the three cross-check tests on both versions gives real confidence.
Licensed CC0 (public domain) Version 1 · history
Understand code you inherited: a layered explanation from the big picture down to the tricky lines.
Make tangled code easier to read and change without altering behavior, with every edit explained.
Practice algorithm problems with progressive hints, complexity analysis and feedback, instead of getting spoiled with the answer.
Prepare for a major library or framework upgrade: breaking changes, code to update and a safe rollout order.
Plan a database, framework or infrastructure migration with phases, rollback points and verification at each step.
Describe what you want to match and get a commented regex with matching and non-matching test cases.
Comments (0)
Sign in to join the discussion.
No comments yet. Be the first to share how it worked.