3 ms·
I used GitHub Copilot to translate a few small programs, from Javascript to Python. Results: - single lines went over well, and even became idiomatic in the d
by john-tells-all 4y ago
I used GitHub Copilot to translate a few small programs, from Javascript to Python.
Results:
- single lines went over well, and even became idiomatic in the destination language
- snippets translated well
- for two snippets translated separately, the 2nd snippet didn't understand the original context and got confused. Lesson: translate a whole file at once, or you'll have to fix cross-function references/names.
One test I thought didn't work. My 100 lines of (admittedly crappy) Javascript got cut off. Actually... it worked! It translated 100 lines of JS into 50 lines of idiomatic Python! I was extremely surprised.
More results
- original had a driver function and a worker function. The translated code just inlined everything. I'd have preferred the multiple functions be preserved, but it's okay.
- idiomatic Javascript was translated to idiomatic Python
- it used modules I'd never heard of. I thought the AI had just made things up, but the modules were actually real! Very happy with this.
- it also used old modules. I had to rewrite several lines and retarget the code to use a modern module, vs the original which was deprecated.
Bottom line: at least the AI I tried (Copilot), is effing magic! We saved our client probably $1000 in just one usage of this tool.
I'm going to continue paying for this out of my own pocket, to use for learning new languages, modules, and for translating the occasional small program.
Huge caveat: talk to your Dir Eng or CTO about sending their proprietary code to some random service on the internet. They probably will NOT like it. Thus, AI can only be used in occasional "I'm starting from scratch and learning this" type situations. You can NOT use AI on business code without company consent, which dramatically limits its usefulness for the moment.
- strajk 4y agoHow did you instruct Copilot to do the conversion? I've always used it just as a smart auto-complete.