Recent

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


DeveloperJames

  • Newbie
  • Posts: 5
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #16 on: June 30, 2025, 06:29:36 pm »
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.

Thanks Handoko, I will use the forum to ask for help in future :) It's a great place.

Nicole

  • Hero Member
  • *****
  • Posts: 1324
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #17 on: June 30, 2025, 07:00:02 pm »
It is very useful, but it is a stupid Clark and no manager. Do not expect it to write complete units. It keeps mixing up the syntax with Delphi. After this it gives you hints, what you shall change, that your Lazarus compiles. Then you get the hint to re-install your OS. Follow its hints and your computer is dead.

What it is good for: Give it one method and ask it, to write a similar one for a different purpose.
Tell it, to write tedious code and care, it does not tell you "and the rest the same".

And it keeps to imagine properties. If you say, "I cannot paint it, write me a code". Then it says, "RichEdit.paint";
Does not exists? - no worries.

It is important you never discuss with it. This makes it run into internal loops and give you your own text back mixed with pure new nonsense. If you once came into a stupidity argument with it - relog.

Unfortunately, it tends to change var names. You must read the stuff and check it.
So: It is just a machine, give it small tasks and force it to do them one by one.
The more complex a loop gets, the less you can use CI.

Where you can use it fine:
- key in a string and ask to split it
- key in a name and ask the fitting unit for it
- key in a table and let it make queries

Michel_GONZALEZ

  • New Member
  • *
  • Posts: 12
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #18 on: July 09, 2025, 07:28:48 am »
Hi,
I use phind for my Lazarus/freepascal code.
https://www.phind.com/
Sometime it give you cool answer with shematic graph.

I use "duck.ai" too.
and "perplexity.ai"

all of them give you (sometimes) fonctions who dont exist.
So you have to say it and the AI try to solve this...

Thaddy

  • Hero Member
  • *****
  • Posts: 19273
  • Glad to be alive.
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #19 on: July 09, 2025, 07:56:29 am »
Well, yesterday I needed a very lightweight - very - USB detection unit. Asked DeepSeek and got a working unit that did not need changes. And that unit was really written, not copied.
Code: Pascal  [Select][+][-]
  1. // written by deepseek.
  2. // Specifically asked lightweight.
  3. unit usbpoll;
  4. {$mode objfpc}{$H+}
  5. interface
  6. uses
  7.   Windows,SysUtils, Classes;
  8.  
  9. type
  10.   TUSBDeviceList = TStringList;
  11.   TUSBEvent = procedure(DeviceInserted: Boolean; const DeviceName: String) of object;
  12.  
  13.   TUSBPoller = class(TThread)
  14.   private
  15.     FInterval: Integer;
  16.     FOnUSBEvent: TUSBEvent;
  17.     FLastDeviceList: TUSBDeviceList;
  18.     procedure CheckDevices;
  19.   protected
  20.     procedure Execute; override;
  21.   public
  22.     constructor Create(Interval: Integer = 1000);
  23.     destructor Destroy; override;
  24.     property OnUSBEvent: TUSBEvent read FOnUSBEvent write FOnUSBEvent;
  25.   end;
  26. implementation
  27.  
  28. constructor TUSBPoller.Create(Interval: Integer);
  29. begin
  30.   FInterval := Interval;
  31.   FLastDeviceList := TUSBDeviceList.Create;
  32.   inherited Create(False);
  33. end;
  34.  
  35. destructor TUSBPoller.Destroy;
  36. begin
  37.   FLastDeviceList.Free;
  38.   inherited;
  39. end;
  40.  
  41. procedure TUSBPoller.CheckDevices;
  42. {$IFDEF Windows}
  43. var
  44.   DriveBits: DWORD;
  45.   Drive: Char;
  46.   DrivePath: String;
  47.   NewList: TUSBDeviceList;
  48.   i:integer;
  49. begin
  50.   NewList := TUSBDeviceList.Create;
  51.   try
  52.     DriveBits := GetLogicalDrives;
  53.     for Drive := 'A' to 'Z' do
  54.     begin
  55.       if (DriveBits and 1) <> 0 then
  56.       begin
  57.         DrivePath := Drive + ':\';
  58.         if GetDriveType(PChar(DrivePath)) = DRIVE_REMOVABLE then
  59.         begin
  60.           NewList.Add(DrivePath);
  61.         end;
  62.       end;
  63.       DriveBits := DriveBits shr 1;
  64.     end;
  65.  
  66.     // Check for new devices
  67.     for i := 0 to NewList.Count - 1 do
  68.     begin
  69.       if FLastDeviceList.IndexOf(NewList[i]) = -1 then
  70.       begin
  71.         if Assigned(FOnUSBEvent) then
  72.           FOnUSBEvent(True, NewList[i]);
  73.       end;
  74.     end;
  75.  
  76.     // Check for removed devices
  77.     for i := 0 to FLastDeviceList.Count - 1 do
  78.     begin
  79.       if NewList.IndexOf(FLastDeviceList[i]) = -1 then
  80.       begin
  81.         if Assigned(FOnUSBEvent) then
  82.           FOnUSBEvent(False, FLastDeviceList[i]);
  83.       end;
  84.     end;
  85.  
  86.     FLastDeviceList.Assign(NewList);
  87.   finally
  88.     NewList.Free;
  89.   end;
  90. end;
  91. {$ELSE}
  92. // Linux version would use /proc/mounts or similar
  93. begin
  94.   // Implement Linux-specific polling here
  95. end;
  96. {$ENDIF}
  97.  
  98. procedure TUSBPoller.Execute;
  99. begin
  100.   while not Terminated do
  101.   begin
  102.     Synchronize(@CheckDevices);
  103.     Sleep(FInterval);
  104.   end;
  105. end;
  106. end.
Quite impressive.
Needed it to ensure user removed USB stick on program shutdown (OnCloseQuery)
Saved me the use of libusb although that is usually the better option.
« Last Edit: July 09, 2025, 08:01:18 am by Thaddy »
objects are fine constructs. You can even initialize them with constructors.

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 759
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #20 on: July 09, 2025, 06:13:20 pm »
I've noticed that a lot of my lazarus/FPC questions (basic -- my memory isn't what it used to be) are answered very efficiently now by AI (the answers are always there somewhere in the docs -- but AI saves me searching).  I wonder if this is having any impact on volume and nature of traffic to the forum here?

I can see a future where AI will change the shape of "the docs" for something like FPC pretty profoundly as people become more adept at knowing how to frame their questions.

Joanna

  • Hero Member
  • *****
  • Posts: 1461
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #21 on: July 09, 2025, 06:59:02 pm »
I want nothing to do with this ai nonsense. Where did the pascal programmers go to? There is nobody to talk about pascal anymore.

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #22 on: July 09, 2025, 07:12:50 pm »
So this morning I started to do some research into flow fields using bfs and I started up ChatgPT and the first diagram it gives me is wrong. So I tell it, that the diagram is wrong and it tells me:

Quote
Excellent observation—that's exactly right, and you caught the most common mistake when explaining flow fields. The flow in the visual example I gave is backwards.

So if it knew it was wrong, why do it wrong in the first place? 
Barry

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

paule32

  • Hero Member
  • *****
  • Posts: 647
  • One in all. But, not all in one.
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #23 on: July 09, 2025, 07:14:13 pm »
this is the price for the KI glamour...
but trust me Jo, it is only a Hype ...

StudNet was coming and going ...
WkW - Who knows Who the same ...
the Maja and Azektes ...

Late, when all money is puffed out, then the Hype fly away ...
no worries ... be happy
MS-IIS - Internet Information Server, Apache, PHP/HTML/CSS, MinGW-32/64 MSys2 GNU C/C++ 13 (-stdc++20), FPC 3.2.2
A Friend in need, is a Friend indeed.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6398
  • Compiler Developer
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #24 on: July 09, 2025, 11:22:21 pm »
Well, yesterday I needed a very lightweight - very - USB detection unit. Asked DeepSeek and got a working unit that did not need changes. And that unit was really written, not copied.
snip
Quite impressive.
Needed it to ensure user removed USB stick on program shutdown (OnCloseQuery)
Saved me the use of libusb although that is usually the better option.

Please note that this would include non-USB drives that are marked as removable (e.g. SD-Cards in SDHCI based slots), USB-drives that are not marked as removable (e.g. USB adapters for S-ATA or NVMe or bigger USB drives) and non-USB drives that are not marked as removable (e.g. NVMe drives connected through Thunderbolt or connected to a hotplug capable PCIe slot).

Joanna

  • Hero Member
  • *****
  • Posts: 1461
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #25 on: July 10, 2025, 01:13:59 am »
When ignorant people use ai, it is never “wrong”  :D

TBMan It is probably because the AI has been programmed to be polite and always take the blame no matter what, so that people will keep using it.

People who use AI to write their programs for them are not programmers, at best they are former programmers.
« Last Edit: July 10, 2025, 01:17:13 am by Joanna »

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #26 on: July 10, 2025, 01:31:27 am »
When ignorant people use ai, it is never “wrong”  :D

TBMan It is probably because the AI has been programmed to be polite and always take the blame no matter what, so that people will keep using it.

People who use AI to write their programs for them are not programmers, at best they are former programmers.

Or people trying to learn new things ... I'm learning how flow fields work using ChatgPT and youtube. Those two things are just another form of research. It's a lot faster and cheaper than buying 14 books on the subject. But, I'm not a real programmer anyway though, I admit it. I couldn't write a compiler in 100 years, :D
Barry

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

Curt Carpenter

  • Hero Member
  • *****
  • Posts: 759
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #27 on: July 10, 2025, 03:36:40 am »

Or people trying to learn new things ... I'm learning how flow fields work using ChatgPT and youtube. Those two things are just another form of research. It's a lot faster and cheaper than buying 14 books on the subject. But, I'm not a real programmer anyway though, I admit it. I couldn't write a compiler in 100 years, :D

Yes, I think that's on target.  "AI" this time (unlike last time, in the 80s/90s) has the potential to help people learn -- to think in "program" terms, create programs and make better more efficient use of programming tools (docs not the least of them).   I think this AI is going to have a big impact on the way systems (like Lazarus/FPC) are documented and accessed.  It won't replace creative problem solving, but will open new doors to achieving it.

Joanna

  • Hero Member
  • *****
  • Posts: 1461
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #28 on: July 10, 2025, 06:27:14 am »
Quote
... I'm learning how flow fields work using ChatgPT and youtube. Those two things are just another form of research.
Are there no humans still alive. To discuss flow fields or other pascal related things with? I don’t think that AI is a good substitute for mentors, teachers , personal relationships etc. Yet it’s being misused as substitutes for all these things. 
I would like to know what a flow field is but I’m not interested in talking to machines. What can I do?

Curt I admire you optimism
Sure AI might be able to help people learn... television could have also.
What matters are the intentions of the people controlling the technology not the technology itself. I’d say the purpose of AI is to manipulate and dumb people down.. 

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12430
  • Debugger - SynEdit - and more
    • wiki
Re: ChatGPT and ObjectPascal in Lazarus IDE
« Reply #29 on: July 10, 2025, 08:28:59 am »
Please don't discredit people for using AI.

 

TinyPortal © 2005-2018