GitHub code repository to Xojo

Is it possible to ask an AI engine to convert a public domain GitHub code repository written in one language into another language (eg Xojo)?

I don’t need to do this now, but might one day.

I mean you can certainly ask it, let us know what it says!

But my experience trying to have a few different AIs try to port code from other languages has not been great. While it’s getting better, the various language changes over the years in Xojo are more often than not missed by the AI, so it mostly spits out garbage. Or at least partial garbage.

I have found it to be useful for specific tasks with very specific, detailed prompts (telling it to use only API2 code, what version of Xojo I’m using, giving it the variable and class names you want, etc). Even then, it sometimes uses invalid syntax, while confidently telling you you’re good to go. When you say “that’s not legal syntax in xojo” it acts like it was just being forgetful and corrects it. Kind of. Usually takes a few tries.

Surprisingly, the best of them lately seems to be a plain language google search, and it’s AI suggestion at the top of the page - it’s produced some decent code for me on my latest project. Not production ready, of course, but a good starting point.

I say surprisingly, because on most google searches I do, that AI result is complete junk. I read recently that they’re using a “reasoning” model that starts with a premise and builds off of it when constructing a response. If the starting point, or some point in the middle is wrong, it veers off into crazytown, outputting nonsense. But for xojo code it hasn’t been too bad.

My experience has been very similar.

After having done a fair bit of usage testing over the past couple of weeks for work I have some thoughts on this. Anything to or from Xojo and another language is going to be somewhat fraught as there are too many examples of old API 1 and fewer of API 2 and any of the models will confuse the two (and sometimes throw in VB6 code for good measure).

Not all models are created equal. My experience with ChatGPT says it will make a ton of mistakes. However, I’ve had much better luck with Claude Sonnet 3.5 and 3.7 (though I believe these are premium models) and will cause fewer headaches.

Where they all fail is handling a complex instruction set. Writing prompts is still an art form rather than a science. So I recommend creating very small, specific tasks for the model. All of my work has been in VS Code so in Agent mode it can change code and run Terminal commands automatically for you so I have no idea how this will all work with the Xojo IDE. I suspect it would not be very good but I’m willing to say I don’t have enough Xojo and AI experience at this point in time.

The models are pretty good at creating documentation and since no one likes doing documentation it’s a good use-case, in my opinion. It’s also reasonably good at Code Review as long as you have specific instructions. Again, I’ve not tried this explicitly with Xojo code so I can’t speak to anything other than the Go and Python that I’ve done it in. Those languages have well documented ‘best practices’ for coding. There might be such documents in Xojo but I’ve not see one recently.

I feel like the Xojo IDE needs to gain a bunch of capabilities to leverage the power of any of the LLM’s. For VSCode it’s built-in and much of it can be hands-off and it can read any bit of code in the entire project. And Copilot works with any number of the VSCode extensions so things like AI creating Git commit statements for you are just there and ready to be used. These are features that Xojo just doesn’t have at this point.

Bottom line is you can try. Expect it to fail. Don’t trust it. Verify every line of code with your own eyes and test everything.

2 Likes

I had our internal AI convert .Net code for a console program to Python and it did pretty well. But to be fair it was a little less than 400 lines of .Net so not super complex, but it was certainly time saving!

you forgotten the used frameworks, third party librarys, closed source code, licence terms.

especially open source projects takes all.

in the second place the target device could have a different OS and other requirement.