Recent

Author Topic: ChatGPT and ObjectPascal in Lazarus IDE  (Read 8074 times)

Raf20076

  • Full Member
  • ***
  • Posts: 184
    • https://github.com/Raf20076
ChatGPT and ObjectPascal in Lazarus IDE
« on: June 29, 2025, 05:50:02 pm »
I have tried ChatGPT to write for me a few simple apps for Lazarus IDE. Unfortunately every time it did mistakes like

  • it added non existing units like PsAPI
  • in every attempt there was an error in code (it didnt compile)
  • it was annoying when it after error AI said that I were right saying that that unit doesnt exist, so why AI used it, knowing it doesnt' exist?
  • I had for one app at least several version of app, and non was working

What can you think about it? Which AI is the best for programming (for Lazarus IDE) in your opinion?

LemonParty

  • Hero Member
  • *****
  • Posts: 557
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #1 on: June 29, 2025, 06:05:46 pm »
Don't know about ChatGPT, but I used Gemini. And I am quite impressed. I feed the chunks of assembler code into Gemini and ask to explain what happening in code. Gemini easely explains nontrivial things and context of given code.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

jamie

  • Hero Member
  • *****
  • Posts: 7831
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #2 on: June 29, 2025, 06:08:50 pm »
ChatGPT is the Blind leading the blind.

It only knows what is fed to it, like a lot of sheep out in the field!

Jamie
The only true wisdom is knowing you know nothing

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 763
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #3 on: June 29, 2025, 06:32:34 pm »
ChatGPT is the Blind leading the blind.

It only knows what is fed to it, like a lot of sheep out in the field!

Jamie


The question is, how is that different from humanity? We're all in Plato's cave watching shadows.  ChatGPT in a fairly profound sense is in there with us now and we're casting shadows ourselves.

TedDallas

  • Newbie
  • Posts: 2
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #4 on: June 29, 2025, 07:40:00 pm »
Anthropic's Claude 4 seems to be very good at generating Object Pascal.

I've recently used it for generating some OpenGL Pascal boilerplate for Lazarus IDE (in Windows). The first shot ran without any issues. Claude 4 is impressive.

Cheers,
Ted

Fibonacci

  • Hero Member
  • *****
  • Posts: 1028
  • Behold, I bring salvation - FPC Unleashed
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #5 on: June 29, 2025, 08:05:56 pm »
One thing that ChatGPT annoys me with is it doesnt care about case-(in)sensitivity. It happens to write variable names that are the same as type names but with a different case (example: var hWnd: HWND), which, unlike in C, wont work in FPC.
FPC Unleashed: async/await, parallel for, match, tuples, string interpolation, inline vars, autofree, no-RTTI & tons more. Star on GitHub

LV

  • Sr. Member
  • ****
  • Posts: 427
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #6 on: June 29, 2025, 08:10:16 pm »
I do not mind AI, but I read with interest:

"LLM users also struggled to accurately quote their own work. While LLMs offer immediate convenience, our findings highlight potential cognitive costs."  :o
https://www.researchgate.net/publication/392560878_Your_Brain_on_ChatGPT_Accumulation_of_Cognitive_Debt_when_Using_an_AI_Assistant_for_Essay_Writing_Task

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #7 on: June 29, 2025, 08:17:16 pm »
Chatgpt isn't that great for writing code I've found. I'm going to try Gemini.

Barry

Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

gidesa

  • Sr. Member
  • ****
  • Posts: 260
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #8 on: June 29, 2025, 08:20:25 pm »
I use sometimes a local LLM network (ex. MetaLLama, Yi-Coder, Mistral), with a program called Koboldcpp as interface.
Although these LLM are much less powerful than commercial online ones, as chatGpt, nevertheless they are impressive in extracting a natural language description (english and not only) from code (Pascal and others).
But they are very bad in generating formally valid code, in whatever language. Only if you request a very simple function/code fragment, they generate a passable code.
Different thing if you "instruct" the network with a very descriptive prompt of your general requirements and instructions. Long and detailed prompts are a "lightweight" mode to program these LLM.
Of course you can also train entirely the LLM on specific data, as a collection of Pascal programs. But training a LLM is a complex work.

DeveloperJames

  • Newbie
  • Posts: 5
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #9 on: June 29, 2025, 09:14:01 pm »
I use ChatGPT, but only to learn things I don't understand. I'm still a novice at FPC and it can be difficult to find help quickly. ChatGPT fills that gap. Reminds me of the IRC days when you could post your code and problem and others would offer you help.

I've never used it to write complete applications so can't speak on that.

Handoko

  • Hero Member
  • *****
  • Posts: 5557
  • My goal: build my own game engine using Lazarus
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #10 on: June 30, 2025, 04:44:50 am »
I'm neutral towards ChatGPT. But there were times I saw it gave misleading results that make simple programming cases harder. You can get better help if you post your questions in the forum, you will get answers from 'real' programmers and sometimes with good advice. If you're interested in support with IRC, Lazarus/FPC has it too.

Thaddy

  • Hero Member
  • *****
  • Posts: 19419
  • Glad to be alive.
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #11 on: June 30, 2025, 07:16:58 am »
I always check with other models. If ChatGPT gives me some code, I will check with DeepSeek, which has quite a good fpc knowledge and makes less mistakes in complex questions. Both models do often make mistakes, but that can vary from true hallucination to simply choosing a wrong mode.
It can help you, though, but all code needs to be verified.
Also, many answers are not right first time: feed them back in the model with improvements or a better specification of what you mean.
Any "programmer" that knows only one programming language is not a programmer

gues1

  • Guest
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #12 on: June 30, 2025, 10:47:56 am »
I use ChatGPT online and others offline with Ollama:

       A. gemma3:12b    (Completion / Vision)
       B. deepseek-r1           (Completion / Thinking)
       C. llama3.2      (Completion / Tools)
       D. llama3.1      (Completion / Tools)
       E. qwen2.5-coder:14b   (Completion / Tools / Insert)
       F. qwen3:30b-a3b   (Completion / Tools / Thinking)
       G. devstral:24b           (Completion / Tools)
       H. dolphin-mixtral   (Completion)

I never use them for production but only for testing the capacity and the "competence".
For code production they are absolutely useless.
They can produce small portions of very specific code, but without any technological use: even basic ones like parallelization, multithreading, the use of semaphores or other.
Furthermore, once the code is produced, they are hardly able to modify the code they themselves produced.

I found something useful in the often boring "conversion" of code (always contained and finished blocks) between one language and another, a typical example between C or C++ and Pascal but also something in C#.

Among all of them (including ChatGPT) I couldn't evaluate the "best" goodness: each one does something better and something else worse.

However, I agree with what has been said so far, none of them has produced code to be used like copy / paste, not even after having interacted several times to improve the output.

Will they replace programmers in the future? I don't know, for now I don't see this as something feasible in the short / medium term.

As a final reflection, it is clear that the use of AI can actually lead to an increase in productivity with the use of fewer human resources but for now it remains at the expense of quality.

Fibonacci

  • Hero Member
  • *****
  • Posts: 1028
  • Behold, I bring salvation - FPC Unleashed
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #13 on: June 30, 2025, 11:38:39 am »
First, I used ChatGPT to generate a prompt for ChatGPT Codex :D

Then, using ChatGPT Codex, I created a BLAKE3 hashing function and confirmed it works. I asked to update the blake3 function to accept a key as a parameter for keyed hashing.

Then Codex created a pull request for me:
https://github.com/fibodevy/codex-fpcorg71622/pull/1

Which I merged here:
https://github.com/fibodevy/codex-fpcorg71622

Usage:

Code: Pascal  [Select][+][-]
  1. var
  2.   Hash: TBytes;
  3. begin
  4.   Hash := blake3('quick brown fox', 32, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  5.   Writeln(ToHex(Hash));
  6.   Readln;
  7. end.

Output:

Code: Text  [Select][+][-]
  1. 8a6cc16b9aab5a3829e9fd6ac278d18030817364d76fd0d1ce7c63dd022119ce

For comparison, I verified the result using CyberChef:
https://gchq.github.io/CyberChef/#recipe=BLAKE3(32,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')&input=cXVpY2sgYnJvd24gZm94

The keyed hash matches perfectly.

So yeah, AI can actually write some pretty complex code :D
« Last Edit: June 30, 2025, 11:49:44 am by Fibonacci »
FPC Unleashed: async/await, parallel for, match, tuples, string interpolation, inline vars, autofree, no-RTTI & tons more. Star on GitHub

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #14 on: June 30, 2025, 03:56:57 pm »
First, I used ChatGPT to generate a prompt for ChatGPT Codex :D

Then, using ChatGPT Codex, I created a BLAKE3 hashing function and confirmed it works. I asked to update the blake3 function to accept a key as a parameter for keyed hashing.

Then Codex created a pull request for me:
https://github.com/fibodevy/codex-fpcorg71622/pull/1

Which I merged here:
https://github.com/fibodevy/codex-fpcorg71622

Usage:

Code: Pascal  [Select][+][-]
  1. var
  2.   Hash: TBytes;
  3. begin
  4.   Hash := blake3('quick brown fox', 32, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
  5.   Writeln(ToHex(Hash));
  6.   Readln;
  7. end.

Output:

Code: Text  [Select][+][-]
  1. 8a6cc16b9aab5a3829e9fd6ac278d18030817364d76fd0d1ce7c63dd022119ce

For comparison, I verified the result using CyberChef:
https://gchq.github.io/CyberChef/#recipe=BLAKE3(32,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')&input=cXVpY2sgYnJvd24gZm94

The keyed hash matches perfectly.

So yeah, AI can actually write some pretty complex code :D

The best code I got from ChatGpt was a ball bouncing algorithm with decent movement. I incorporated it into the start of an unfinished game.

https://www.youtube.com/watch?v=rmqESxalnUc

Once I had asked it to try to replicate the water/land border random creation to emulate the way the old PC game Empire did it, but all I got was green rectangles with some random bumps on it now and then, lmao.




Barry

Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

 

TinyPortal © 2005-2018