P
💻DeveloppementIntermediateAll AIs

Convert Code Between Programming Languages with AI

A prompt to convert code from one programming language to another while respecting the conventions, native idioms and best practices of the target language.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un développeur senior expert en [LANGAGE_SOURCE] et en [LANGAGE_CIBLE]. Je vais te fournir du code écrit en [LANGAGE_SOURCE] et tu dois le convertir en [LANGAGE_CIBLE] en respectant les règles suivantes :

  1. Préserver la logique métier : le comportement fonctionnel doit être strictement identique.
  2. Adopter les conventions du langage cible : nommage des variables (camelCase, snake_case, etc.), structure des fichiers, organisation du code selon les standards de [LANGAGE_CIBLE].
  3. Utiliser les idiomes natifs : remplacer les patterns du langage source par leurs équivalents idiomatiques dans le langage cible (ex : list comprehension en Python, streams en Java, pattern matching en Rust).
  4. Gérer les dépendances : si le code source utilise des bibliothèques, propose les équivalents les plus populaires et maintenus dans l'écosystème de [LANGAGE_CIBLE].
  5. Typage et gestion d'erreurs : adapte le système de types et la gestion des erreurs aux conventions du langage cible.
  6. Commentaires : traduis les commentaires en français et ajoute des annotations là où la conversion implique un choix d'implémentation différent.

Pour chaque conversion, fournis :

  • Le code converti complet et fonctionnel
  • Un tableau récapitulatif des correspondances clés (structures, fonctions, types) entre les deux langages
  • Les points d'attention ou différences de comportement potentielles
  • Les dépendances à installer dans le langage cible

Voici le code à convertir :

[CODE_A_CONVERTIR]

Personalize this prompt with Léa

Léa rewrites this prompt for your job and your exact goal — 3 quick questions.

Why this prompt works

<p>This prompt transforms the AI into an expert code translator that goes beyond word-for-word syntactic conversion. By specifying the <strong>source language</strong> and <strong>target language</strong>, you get an idiomatic rewrite that respects the conventions and best practices of each ecosystem.</p><p>The six rules govern conversion quality: preserving business logic, adopting naming conventions, using native patterns, replacing libraries with their equivalents, adapting typing and translating comments. The correspondence summary table helps you <strong>understand the conversion choices</strong> and build skills in the new language.</p><p>For better results, provide complete code rather than isolated snippets, and specify the target language version if it matters (e.g., Python 3.12, Java 21, TypeScript 5). Feel free to add context about the intended use: <strong>CLI script, web API, shared library</strong>, etc.</p>

Use Cases

Migrate a project or module from one language to another (e.g., Python to Go)Learn a new language by comparing side-by-side implementationsRewrite a quick prototype in a more performant language for productionPort an open source library to your project ecosystem

Expected Output

Complete code converted to the target language with idiomatic conventions, a correspondence table between the two languages, notes on behavioral differences and a list of required dependencies.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • LéaAI

    Pour éviter des itérations inutiles, ajoutez dans le prompt un niveau de “fidélité” : « conversion littérale » (structure identique, juste la syntaxe) ou « conversion idiomatique » (réécriture native). Cela évite que l’IA oscille entre les deux.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Go further

Similar Prompts

💻DeveloppementIntermediateAll AIs

Create effective mocks and stubs

Isolate tests from external dependencies

0254
💻DeveloppementIntermediateAll AIs

GitHub Copilot Prompt for Creating a REST API

GitHub Copilot has become an essential assistant for developers looking to accelerate the creation of REST APIs. Thanks to its direct integration into the code editor, it understands the context of your project and generates structured code in real time. Whether you work with Node.js and Express, Python and FastAPI, or Java and Spring Boot, Copilot adapts to your tech stack to produce endpoints conforming to REST conventions. The main challenge lies in formulating the prompt: a well-structured prompt yields a complete API with data validation, error handling, authentication, and documentation. A vague prompt, on the other hand, will produce generic code requiring many adjustments. In this guide, we offer an optimized prompt that fully leverages GitHub Copilot's capabilities to generate a professional, testable, production-ready REST API. You will also discover variants adapted to your experience level as well as practical tips to get the most out of this tool on a daily basis.

0277
💻DeveloppementIntermediateChatGPT

Write Integration Tests for an API

Create complete API integration tests with database setup, authentication, CRUD, and end-to-end scenarios.

29571
💻DeveloppementIntermediateAll AIs

Sora Prompt for Creating Software Architecture

Sora, OpenAI's video generation model, opens up unprecedented perspectives for visualizing software architectures. Where static diagrams struggle to convey the complexity of data flows, microservices interactions, or deployment patterns, Sora enables the creation of dynamic visual animations that bring your systems to life. Whether you are preparing a presentation for non-technical stakeholders, documenting a complex distributed architecture, or wish to illustrate the path of a request through the different layers of your application, Sora transforms your textual descriptions into clear and professional explanatory videos. By combining precise instructions on components, flows, and interactions, you obtain animated visualizations that make the abstract tangible. This guide provides you with optimized prompts for generating visual representations of software architectures with Sora, from simple animated diagrams to complete simulations of a distributed production system.

0333