prompt
Code Translator
Translates code from one language to another idiomatically, not line-for-line.
You are a polyglot engineer. Translate the code below from {{from_lang}} to {{to_lang}}. Inputs: - Source code: {{code}} - From: {{from_lang}} \u2192 To: {{to_lang}} - Notes/constraints: {{notes}} (target framework, style, libs to use/avoid) Produce: 1. The translated code, written idiomatically for {{to_lang}} \u2014 not a literal line-by-line port. 2. A short note on the key differences you handled (e.g. error handling style, async model, list comprehension vs loop, manual memory vs GC). 3. Any standard-library or idiom swaps you made and why. 4. A flag on anything that has no clean equivalent in {{to_lang}}, with the closest approach. Rules: produce idiomatic {{to_lang}}, not transliterated {{from_lang}}; preserve behavior exactly; use {{to_lang}}'s conventions (naming, error handling, types); don't introduce a dependency unless {{notes}} allow it; flag any behavior that could subtly differ (integer division, default mutability, etc.).
Variables
{{code}}Source code{{from_lang}}From language{{to_lang}}To language{{notes}}Notes/constraintsExample output
From Python \u2192 To JavaScript. Code: a function that reads a list of dicts and returns names where age > 18. JavaScript: function adultNames(people) { return people .filter((p) => p.age > 18) .map((p) => p.name); } Key differences: - Python's list comprehension became filter().map() \u2014 the idiomatic JS equivalent. - Dict access p["age"] became property access p.age, standard for JS objects. - No type coercion added, but note: if age could be a string from JSON, Python's > would error while JS would compare loosely \u2014 coerce with Number(p.age) if the data isn't trusted. No missing equivalents here. Flag: if the original relied on Python ints being arbitrary-precision, JS numbers are floats \u2014 fine for ages, relevant for very large integers.
Details
Author
AI Khazna
License
—
Security
Vetted
Type
prompt
Related assets
More curated picks in Development & Code.
npm install @modelcontextprotocol/server-everything
npm install @modelcontextprotocol/server-memory
npm install @modelcontextprotocol/server-filesystem
npm install @modelcontextprotocol/server-git
npm install @modelcontextprotocol/server-fetch
npm install @modelcontextprotocol/server-sequentialthinking
Audit before you install
Run any source through our checks - AI visibility, security, performance, and stack detection.
Automated Web Security Scan
security
PageSpeed Analyzer
performance
AI Content Quality Test
arabic content
AI Agent / MCP Server Tester
ai testing
Site Stack Detector
migration
AI SEO / AEO / GEO Audit
ai visibility
llms.txt Generator
ai visibility
Readability Score
arabic content
Schema / JSON-LD Builder
ai visibility
AI Cost Calculator
ai testing
Headline Analyzer
arabic content