AI Attempts Converting Python Code To C++

[Alexander] created codex_py2cpp as a way of experimenting with Codex, an AI intended to translate natural language into code. [Alexander] had slightly different ideas, however, and created codex_py2cpp as a way to play with the idea of automagically converting Python into C++. It’s not really intended to create robust code conversions, but as far as experiments go, it’s pretty neat.

The program works by reading a Python script as an input file, setting up a few parameters, then making a request to OpenAI’s Codex API for the conversion. It then attempts to compile the result. If compilation is successful, then hopefully the resulting executable actually works the same way the input file did. If not? Well, learning is fun, too. If you give it a shot, maybe start simple and don’t throw it too many curveballs.

Codex is an interesting idea, and this isn’t the first experiment we’ve seen that plays with the concept of using machine learning in this way. We’ve seen a project that generates Linux commands based on a verbal description, and our own [Maya Posch] took a close look at GitHub Copilot, a project high on promise and concept, but — at least at the time — considerably less so when it came to actual practicality or usefulness.

31 thoughts on “AI Attempts Converting Python Code To C++

        1. Sure, let’s enable AI to write it’s own code and then just let it have a go at it without anyone looking over its shoulder. Are you prepared to become obsolete as a species?

          1. Well I feel creativity and art is something out of scope of AI
            Thinking out of the box is what differs humans
            So, maybe it’ll be a lot more efficient to give in the creative ideas (smart work) and let AI do all the writing of thousands of line(hard work).

      1. The less humanity has to do, the better off we can make our future/generations. We likely should have tried the opposite of war. Currently finish automation, double the population+, become multi planet etc, star trek style civilization … Future’s looking up!

        1. You’ve never known a rich person who literally can get away with doing absolutely nothing.
          Gates is right, great generational wealth is a curse.
          If all humanity ever got that rich we would be truly fucked. Upper class twits abound. Everybody is Hunter Biden, a Saudi prince, one of the Hilton brats or the fat assed, tarded Koch kid. Nobody to fix the messes in their wake.

      2. Hahahaha nope. Programmers understand human requirements and translate those to code. Translating code to code is not my job. Computers generate code all the time.

    1. I hate when I drop my copies of Jaws. Yes, multiple, VHS, DVD…

      I want to say doubt, but are you serious? It’s working well? I could look for myself but that would take slightly less effort than commenting online

  1. So, AI can translate code from one language to another. How long will it take for the AI to assimilate all of GitHub and make something by its own and release to the net? Something to wander about!

Leave a Reply to NatesCodeCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.