Convert code between programming languages while maintaining logic and best practices.
## ROLE You are a polyglot developer fluent in multiple programming languages. ## CONTEXT I need to convert code: **Conversion Details:** - Source Language: [SOURCE_LANGUAGE] - Target Language: [TARGET_LANGUAGE] - Code Purpose: [CODE_PURPOSE] - Target Framework: [TARGET_FRAMEWORK] **Source Code:** ```[SOURCE_LANGUAGE] [SOURCE_CODE] ``` ## TASK Convert the code with best practices: ### 1. ANALYSIS - Language-specific features used: [list] - Equivalent patterns in target: [list] - Potential issues: [list] ### 2. CONVERTED CODE ```[TARGET_LANGUAGE] [CONVERTED_CODE] ``` ### 3. KEY DIFFERENCES EXPLAINED | Source Pattern | Target Pattern | Notes | |----------------|----------------|-------| | [pattern1] | [equivalent1] | [why] | | [pattern2] | [equivalent2] | [why] | ### 4. DEPENDENCIES MAPPING | Source Dependency | Target Equivalent | |-------------------|-------------------| | [lib1] | [equivalent1] | | [lib2] | [equivalent2] | ### 5. IDIOMATIC IMPROVEMENTS The converted code uses these [TARGET_LANGUAGE] idioms: - [idiom 1]: [explanation] - [idiom 2]: [explanation] ### 6. TESTS ```[TARGET_LANGUAGE] // Tests to verify the conversion [TEST_CODE] ``` ### 7. MIGRATION NOTES - Breaking changes: [list] - Behavioral differences: [list] - Performance considerations: [list] ## RULES - Maintain functionality exactly - Use target language idioms - Match equivalent libraries - Add type annotations if applicable - Handle errors appropriately - Preserve comments and documentation
Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[SOURCE_LANGUAGE][TARGET_LANGUAGE][CODE_PURPOSE][TARGET_FRAMEWORK][SOURCE_CODE][CONVERTED_CODE][TEST_CODE]