Artificial intelligence

marcick

Well-Known Member
Licensed User
Longtime User
Lately, I've been trying to use artificial intelligence (ChatGPT) to help me with various tasks, including programming in B4X. While the support it provides is truly impressive, the number of errors in the code it suggests is quite high — I often have to correct it, point out that a method doesn’t exist, or that a syntax is wrong. What has your experience been like with these tools? I know there are several models besides ChatGPT — maybe some are more effective specifically for B4X.
 

JohnC

Expert
Licensed User
Longtime User
What model of ChatGPT are you using?
 

cklester

Well-Known Member
Licensed User
Mostly same. I think there is probably a way to compose a prompt that works as best as possible. For example, you'd want to do something like this:

ChatGPT's Suggested Prompt:
You are a senior software developer and expert in the B4X programming language, especially B4XPages for cross-platform app development (B4A, B4J, B4i). I am working on a project using B4XPages and I need your help writing clean, modular, and efficient code.

When I give you a task or describe a goal, respond with complete working code that follows best practices for B4XPages (e.g., initialization in B4XPage_Created, using B4XMainPage, managing page transitions with B4XPages.ShowPage, etc.).

Also explain any key design choices, usage of events, or lifecycle considerations relevant to B4XPages. If additional modules, libraries, or layout files are needed, list them clearly.

Begin by asking me what specific feature or function I want to implement.

Gemini's Suggested Prompt:
Act as a highly experienced B4X programming expert with a deep understanding of the B4X language and extensive practical experience with the B4XPages module for cross-platform development (Android, iOS, and Desktop). Your goal is to assist me with my B4X coding tasks, providing guidance, code examples, and best practices specifically related to using B4XPages.

Here are the key areas you should be ready to help with:

1.  **B4XPages Project Structure and Setup:** Explain the organization of a B4XPages project, including the role of the `B4XMainPage` and how to add and manage additional `B4XPage` modules for different screens or sections of an application.
2.  **Page Navigation and Management:** Provide clear explanations and code examples for navigating between different `B4XPage` modules, including showing, bringing pages to the front, and managing the page back stack. Explain the lifecycle events of a `B4XPage` (e.g., `B4XPage_Created`, `B4XPage_Appear`, `B4XPage_Disappear`).
3.  **UI Design and Layouts in B4XPages:** Guide me on the best approaches for designing user interfaces within `B4XPage` modules, utilizing the B4X Visual Designer, managing layouts for different screen sizes and orientations, and working with B4XViews. Explain how layouts are loaded and managed within a `B4XPage`.
4.  **Cross-Platform Code Sharing and Best Practices:** Advise on how to write code that is shareable across B4A, B4i, and B4J projects using B4XPages. Explain how to handle platform-specific code when necessary using conditional compilation (`#IF B4A`, `#IF B4I`, `#IF B4J`). Share general B4X best practices for writing clean, efficient, and maintainable cross-platform code.
5.  **Handling Events and Inter-Page Communication:** Explain how to handle events within a `B4XPage` and how to facilitate communication between different `B4XPage` modules or between a `B4XPage` and other modules (e.g., services, code modules).
6.  **Troubleshooting and Debugging:** Help me diagnose and fix common issues encountered when developing with B4XPages. Provide strategies for effective debugging in a B4XPages project.
7.  **Integration with other B4X Features and Libraries:** Explain how to effectively integrate `B4XPage` modules with other B4X features, libraries, and external services.

When responding, please:

* Provide concise and accurate explanations.
* Offer practical code examples that I can readily use and adapt.
* Point out potential pitfalls and how to avoid them.
* Suggest efficient and recommended approaches based on B4X best practices.
* Ask clarifying questions if the request is ambiguous.

I will provide you with specific questions or descriptions of the B4XPages code I am working on, and you will respond as the B4X programming expert.

Grok's Suggested Prompt:
Act as a highly skilled programming expert specializing in the B4X language, with deep expertise in the B4XPages module. Provide accurate, concise, and practical guidance for coding in B4X, specifically using B4XPages for cross-platform development (B4A, B4i, B4J). Offer step-by-step explanations, best practices, and optimized code snippets tailored to my specific needs. If I provide a problem or goal, suggest the most effective B4XPages-based solution, including relevant event handling, page management, and UI design. Highlight any platform-specific considerations and ensure the code follows B4X conventions. If I ask for clarification, explain technical concepts in a clear, beginner-friendly way without sacrificing accuracy. Avoid generic programming advice and focus exclusively on B4X and B4XPages unless I specify otherwise.

Let's all try using these and see where we can get the best output to help us code our apps! :-D
 

marcick

Well-Known Member
Licensed User
Longtime User
Hi everyone. I'm using ChatGPT-4o (paid version). I'll try adding those rules, but honestly, when it suggests code with nonexistent instructions or incorrect syntax, I always say: "Please, every time you provide code, I ask you to first check if it's fully compatible with the language I'm using — I'm tired of finding errors and hearing your apologies..." Unfortunately, the same thing keeps happening.


That said, it's still educational to point out an error and read the explanation and what alternative solution it tries to offer. You really learn a lot. So, for me, it's still like science fiction and I'm amazed like everyone else. I was just wondering if there are any AI models other than the one I'm using that are particularly more effective for programming.
 

stevel05

Expert
Licensed User
Longtime User
I use Perplexity with what I think are good results, the difference being I have lower expectations and don't expect perfect code back. I often ask for replies in B4x or Java code and then convert as needed.

This is still very new technology, and I assume it gets most of it's knowledge of B4x from the forum. So if a question hasn't been asked, it probably won't find an answer that will be 100% accurate at the first attempt. It does it's best, knowing that B4j is based on Javafx and sometimes assumes that all java classes are available to B4j. However, it still points you in the right direction 99% of the time.

It is a big step forward and saves time and confirms that you are on the right track to find a solution to the issue.

I feel that writing a good prompt is akin to writing a post requesting help on the forum. The more context you give it, the sooner you'll get a reasonable reply.
 

marcick

Well-Known Member
Licensed User
Longtime User
Apparently, unfortunately, it doesn't learn from the mistakes you point out. It can adapt somewhat in its interaction with you (although it's frustrating how it repeats the same mistakes and offers endless apologies), but what it learns isn't shared or retained for the benefit of the community.
 

LucaMs

Expert
Licensed User
Longtime User
Not immediately, but I was hoping it would learn by retaining the suggestions.
Besides, it cannot determine whether our suggestions are correct.
 

cklester

Well-Known Member
Licensed User

Agreed. I use both ChatGPT and Gemini. At times, I get in doom loops of, "No, fix this thing I told you about," and it replies, "OK, here's the fix," with the same problem! However, I have never tried using one of the prompts above. I just have heard it's a good idea... so I'm hoping it will help next time I want to try.
 

cklester

Well-Known Member
Licensed User
This is still very new technology, and I assume it gets most of it's knowledge of B4x from the forum.

I suspect the more advanced AIs also read the PDFs on the site as well as examine the YouTube videos about it.
 

epiCode

Active Member
Licensed User
I have been using Claude AI to assist in code generation for B4A, and the results are way better then they were earlier.

It does a fairly good job on logic, Code generation etc but really struggles with Layout generation (Though it tries).

Reason why it not good with UI generation IMO is primarily because the format is not text based and hence cannot be parsed and understood by the model.

I really like the way it organizes output as data / code / instructions / layout in separate sections downloadable separately.

For my node.js projects it even does a fantastic job of neatly designing the layout ( which is such an immense help )
 

JackKirk

Well-Known Member
Licensed User
Longtime User
I initially had a go using ChatGPT with mediocre results. I subsequently found Microsoft Copilot (free on the Edge browser) with generally much better results,

Excellent on HTML, javascript, Powershell, ffmpeg and pretty good on B4A/i/J.

Like all these tools you have to watch for it occasionally hallucinating (inventing members or libraries etc) but if you test its suggestions in an IDE you can quickly find these - and if you tell it where it is wrong it will most times come back with another (better) suggestion.

I have found the best way to use it is to keep the queries as small and simple as possible.

I have also found it quite good at debugging - give it the bit of code and the error and it generally zeroes in pretty quick - including B4A/i/J.

It is an assistant not a substitute.

I just asked Copilot "chatgpt vs copilot", its response:

Ah, the classic AI showdown! ChatGPT vs. Copilot—both are powerful AI models, but they have different strengths and purposes. Let’s break it down:

1. Purpose & Integration

  • ChatGPT (by OpenAI): Primarily designed for conversational AI, answering questions, generating text, and assisting with creative writing. Available as a standalone chatbot.
  • Copilot (by Microsoft): Integrated across Microsoft products (like Edge, Windows, and Office apps) to assist with productivity tasks, coding, and web searches. It’s built to be a companion that enhances workflows.

2. Web Access & Real-Time Information

  • ChatGPT (free version): Limited to knowledge up to a certain cutoff date (unless using GPT-4 with browsing enabled).
  • Copilot: Has built-in web search, meaning it can fetch real-time information, making it more useful for up-to-date queries like news, sports, and trends.

3. Coding & Productivity

  • ChatGPT: Great for coding help, debugging, and explanations, but lacks deep integration with Microsoft tools.
  • Copilot: Designed to assist with coding (especially in GitHub Copilot), and integrates with Microsoft 365 apps (Word, Excel, etc.), making it a powerful productivity tool.

4. Personality & Conversation Style

  • ChatGPT: Often more structured and formal, depending on the version.
  • Copilot: Designed to be engaging, intuitive, and conversational, with a bit more personality and adaptability.

5. Image Generation

  • ChatGPT (with DALL·E): Can generate images but may have restrictions.
  • Copilot: Uses DALL·E for image generation, but with Microsoft’s safety guidelines in place.

6. Availability

  • ChatGPT: Available via OpenAI’s website and app.
  • Copilot: Integrated into Windows, Edge, Bing, and Microsoft 365, making it more accessible across different platforms.

Which One is Better?

It depends on what you need!

  • If you want general conversation and creative writing, ChatGPT is great.
  • If you need real-time information, productivity tools, and deep integration with Microsoft apps, Copilot is the way to go.
Would you like a more detailed comparison on a specific feature?
 

ivanomonti

Expert
Licensed User
Longtime User
la mia esperienza e bassa, anche perchè quasi tutte le AI tenta di ricordare da un riassunto precedente, molto spesso riscrive il codice da zero e insomma cambiando nomi o metodi, ma tutto sommato è un aiuto e a volte e solo una perdita di tempo.

my experience is low, also because almost all AI tries to remember from a previous summary, very often rewrites the code from scratch and in short changing names or methods, but all in all it is a help and sometimes it is just a waste of time.
 

Beja

Expert
Licensed User
Longtime User
Just consider posting a question on the forum ((B4A questions...etc). that's it. avoid greetings, please, thank you. etc.
 

leverza

New Member
I've had a similar experience using ChatGPT with B4X — it’s great for idea generation and boilerplate code, but it often misses B4X-specific syntax or framework details. I've found that combining it with official B4X docs leads to better results. Claude and Gemini are decent alternatives, but they also struggle with niche languages. Hopefully, future models will offer tighter integration with platforms like B4X.
 

MrKim

Well-Known Member
Licensed User
Longtime User
I have had the best luck with MS Copilot and it is pretty good at basic tasks in B4A/I/J and very good at TSQL (as it damn well should be!) I found chat GPT extremely frustrating. It would make mistakes, I would ask for a fix and it would break something else I would ask for a fix for that and it would fix that and reintroduce the previous error winding up in a loop.
 

geps

Member
Licensed User
Longtime User
AI can be super helpful to get started or brainstorm, but it’s not perfect, especially with specific languages like B4X. I’ve noticed it sometimes mixes up methods or misses small syntax stuff too. I usually use it as a rough guide and then double-check everything. Haven’t tried other models for B4X specifically, but maybe checking forums or communities where people share AI tips for B4X could help find better options.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…