Has anyone successfully used AI to translate code between languages?
Asked by
basket+weaver
I've been experimenting with AI to convert code from Python to JavaScript or TypeScript, but my experiences have been hit or miss. It rarely works perfectly on the first try, and while it sometimes captures the underlying logic well, the typing and structure often end up a bit odd. I'm curious if anyone has developed a reliable method for this type of conversion?
Answers
Using AI for smaller chunks of code can really help, but donโt expect it to handle large projects all at once. From my experience, itโs been helpful for translating small functions and understanding new languages once you know the basics.
Reply to this answer
It's a fun experiment, but AI still doesn't understand coding concepts fully. AI can generate code that just mirrors styles of one language into another, which can lead to odd results. So while AI can help, you need to keep an eye on it, especially for larger code blocks.
Reply to this answer
I think a lot of folks forget that transpilers have been around for a long time, and there are solid tools for this without needing AI. It might be worth checking out those options instead of relying solely on AI.
Reply to this answer
Just a heads up, the technical term youโre looking for is 'porting,' not just translating. If you prompt AI correctly using that term, you might see better results.
Reply to this answer
I've had good luck with AI for initial code translations. It handles boilerplate well, but you always have to tweak it for language quirks. It can't fully automate the process since different languages work in different ways.
TIDY.desk: True, but it gets a lot of the tedious stuff done faster, which is what many of us are looking for!
Reply to this answer
Add your answer
Answers are reviewed before publication.
nib_and_ink: Yeah, but integrating libraries can get tricky. In my tests, AI can adapt and replace those libraries when converting, which simplifies the process.