Graham Knapp

AI coding patterns: Language bridging

written by Graham Knapp on 2025-02-10

A pattern I enjoy with Copilot or other AI coding tools is something I'm calling "Language bridging":

Language bridging : Write code to solve a problem in a language you know well, then use an AI to translate the code into the language you want or need to use.

A bridge between Python and Typescript

LLMs help to bridge the gap between my knowledge of different programming languages

Steps

The pattern looks like this for me:

  1. Write the code in Python (the programming language I know best)
  2. [Optional, recommended] Simplify the code, refactor into small functions, add comments
  3. Translate the code with an AI - I usually use Claude 3 at the moment.
  4. [Strongly recommended for production code] Ask someone with better skills in the target language to carefully review the code.
  5. [Recommended for personal growth] Read the code line by line, identify one or two subjects to learn more about.

I find that stage 2 - refactoring and commenting - improves the chances of success and makes it easier for me to understand the code after translation.

Use cases

I mainly use this for Proof Of Concept (POC) building, personal projects, one-off tools and for exploring ideas. I don't find it efficient for general coding.

I find it especially effective where I am combining a number of simple actions (cli commands, file parsing, data transformation, image manipulation, etc.) in a custom way. LLMs are often very good at these simple tasks and they can combine them much more quickly than me in a programming language I don't use regularly.

python typescript ai