In order to discuss which AI writes the best code, we have to distinguish between a subscription (like Gemini Pro for $20 per month-https://gemini.google.com/app) or pay by the token (like using OpenAI GPT5.2 via their Chat GUI-https://platform.openai.com/chat/edit?models=gpt-5.2-pro).
In my experience with Gemini as a monthly subscriber, it is lazy. It will make code if you have 3 files, such as your main module and two .bas files, or less quite competently.
Even if you use code bundle (
https://www.b4x.com/android/forum/t...ects-as-a-single-json-for-ai-analysis.169835/) and make one file, Gemini will focus on the changes you want made and then forget to include parts of the rest of your code.
Codebundle is a huge help for making coding using AI much simpler. You give the code to the AI using codebundle and get back the modified parts of your code that you paste into the GUI. It works with Gemini, OpenAI, etc. You have to always be very aware of your code size as a minimum check to see if the AI broke your code. I always require the AI to give me the complete code of any Sub it modifies. Then I highlight the Sub I am going to replace. I check the last line number in the sub. I then paste the new code over it and see what the new last line of the Sub is. If I lost lines of code at all, I ask the AI if it lefts something out which is almost always acknowledges and then might give me accurate, correct code. When the AI replaces an entire module, I do likewise to make sure 100 lines of code did not disappear (which often happens). It is obvious to me that Google is making the AI focus on those that are paying by the token and not by the subscription. You pay for what you get.
So, I got tired of Gemini breaking my code and moved to OpenAI GPT5.2 Pro and have a key and pay by the token. It is extremely competent and has only made one small error in my experience. Sadly, OpenAI has a poorer interface which requires you to put the json file from codebundle into the code interpreter tool or the file search tool which requires a couple extra steps. It also doesn't give you output in a box with an icon you can copy to put the whole response on the clipboard like Gemini has. You have to select the code then copy it. But, I have found that Gemini's icon to copy the code is only half useful because Gemini will put more than one sub in the same code block. You then highlight the top Sub in your code and paste the Gemini code over it. You then have 3 Subs where you expected one with the resulting duplicate sub errors. So, you generally have to copy the sub and paste it into your code anyway.
I have a project with 10 files and about 6000 lines of code. When I put that into a json file using codebuilder and upload it to OpenAI, the AI handles it very well and codes competently. Gemini on the subscription plan just pukes. The coding is trash. I have not tried Gemini CLI where you pay by the token.
I always ask Gemini if it left anything out of my code. It almost always finds something it broke. It usually take 3 to 10 interactions to get it sorted out with Gemini which eats into your 100 Pro queries per day rapidly. This is very obviously Google throttling back the effort Gemini gives to monthly subscribers and allowing your to burn up you 100 pro queries per day so you will upgrade to the $129 per month level to get more pro queries. Gemini won't code well in B4X languages using anything less than the pro model.
As an aside, note also that Google is soon going to have their full web search via API behind a pay wall because they can't inject ads into API respones and they obviously feel entitled to the lost revenue even though they are using the information they got for free from everyone's websites to have search data in the first place. Serper.com allows full search via API without the pay wall if you are interested.
Note also that Perplexity went the same way. When they first came out, Perplexity did good B4X coding. Now, you get 11 (if I remember correctly) pro queries per day and that won't be good at coding either. They switched to being a research model, not coding.
So, the bottom line regarding AI coding is that you pay for what you get. Pay by the token and get good code. Pay a subscription and get frustrated with poor quality code.
Regarding making apps from scratch, the quality of the code you get depends on the quality of the software spec you give the AI. If you give the AI a complex project, it will handle it in stages and give you part of the project complete to test then you prompt it to give you the next part, etc.