Recent

Author Topic: Which AI Model is the Best for Assisting in Lazarus/Free Pascal Code Development  (Read 7044 times)

yahoo000

  • New Member
  • *
  • Posts: 21
Hello everyone,

I've been experimenting with various AI models for assisting in code development with Lazarus/Free Pascal, including OpenAI (such as ChatGPT) and Claude (Anthropic). Both of these AI models seem to have their strengths, but I'm curious to hear from the community:

Have you used any AI tools for generating or improving Lazarus/Free Pascal code?
Which AI model do you find most helpful for our specific programming language and environment—OpenAI, Claude, or perhaps another tool?
Do you think these AI models are reliable enough for more complex coding tasks, or are they better suited for simple snippets and debugging?
I'm looking forward to your thoughts and any experiences you've had with these AI tools when working with Lazarus/Free Pascal. Thank you!

Hansvb

  • Hero Member
  • *****
  • Posts: 863
Hi
I've been experimenting a little bit with chatgpt and ms copilot. The results were disappointing. I haven't been able to get a working procedure/function as an answer yet. Most of the time, fictive class names are used that you can't do anything with. I've parked it for the time being and I'll look back in a year I think.
I haven't tried yet what happens when you ask to check code. I do suspect that it is due to the different pascal dialects that there are no good answers. So maybe I should learn to include that in the prompt. I suspect that because if you ask for a sql query, the result is often good.

Funny incident, the other day I improved co pilot 3 times in a row and then copilot gave up. Didn't want to continue with the discussion.
Addendum, I only use the free version. I do not have a paid version.


Thaddy

  • Hero Member
  • *****
  • Posts: 18483
  • Here stood a man who saw the Elbe and jumped it.
You do not need a payed version perse.
I have a beta-key acquired after some email exchanges after the December 22 key expired.
What is really important is that your question needs to be expressed in the most specific, detailed way you can word.
I found that the answers you get become much better if you put in more effort in the question itself.

Tuples in Freepascal according to copilot (  ;D ):
Code: Pascal  [Select][+][-]
  1. program TupleExample;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. type
  6.   generic TTuple<T1, T2> = class
  7.   private
  8.     FItem1: T1;
  9.     FItem2: T2;
  10.   public
  11.     constructor Create(AItem1: T1; AItem2: T2);
  12.     function GetItem1: T1;
  13.     function GetItem2: T2;
  14.     procedure SetItem1(AItem1: T1);
  15.     procedure SetItem2(AItem2: T2);
  16.   end;
  17.  
  18.   TIntStringTuple = specialize TTuple<Integer, String>;
  19.  
  20. constructor TTuple.Create(AItem1: T1; AItem2: T2);
  21. begin
  22.   FItem1 := AItem1;
  23.   FItem2 := AItem2;
  24. end;
  25.  
  26. function TTuple.GetItem1: T1;
  27. begin
  28.   Result := FItem1;
  29. end;
  30.  
  31. function TTuple.GetItem2: T2;
  32. begin
  33.   Result := FItem2;
  34. end;
  35.  
  36. procedure TTuple.SetItem1(AItem1: T1);
  37. begin
  38.   FItem1 := AItem1;
  39. end;
  40.  
  41. procedure TTuple.SetItem2(AItem2: T2);
  42. begin
  43.   FItem2 := AItem2;
  44. end;
  45.  
  46. var
  47.   TupleInstance: TIntStringTuple;
  48. begin
  49.   TupleInstance := TIntStringTuple.Create(42, 'Hello');
  50.   WriteLn('Item1: ', TupleInstance.GetItem1);
  51.   WriteLn('Item2: ', TupleInstance.GetItem2);
  52.   TupleInstance.SetItem1(100);
  53.   TupleInstance.SetItem2('World');
  54.   WriteLn('Updated Item1: ', TupleInstance.GetItem1);
  55.   WriteLn('Updated Item2: ', TupleInstance.GetItem2);
  56.   TupleInstance.Free;
  57. end.

Which it wrote after I specified that the specialization of the generic must be done to a type and not a var....
But your mileage may vary.
This generated code still has one big flaw: tuples are immutable and contain/keep their initial values during their lifetime, but copilot still it adds setters.
So with a little bit of tinkering:
Code: Pascal  [Select][+][-]
  1. program TupleExample;
  2. {$mode objfpc}{$H+}{$modeswitch advancedrecords}
  3.  
  4. type
  5.   generic TTuple<T1, T2> = record
  6.   private
  7.     FItem1: T1;
  8.     FItem2: T2;
  9.   public
  10.     constructor Create(AItem1: T1; AItem2: T2);
  11.     function GetItem1: T1;
  12.     function GetItem2: T2;
  13.   end;
  14.  
  15.   TIntStringTuple = specialize TTuple<Integer, String>;
  16.  
  17. constructor TTuple.Create(AItem1: T1; AItem2: T2);
  18. begin
  19.   FItem1 := AItem1;
  20.   FItem2 := AItem2;
  21. end;
  22.  
  23. function TTuple.GetItem1: T1;
  24. begin
  25.   Result := FItem1;
  26. end;
  27.  
  28. function TTuple.GetItem2: T2;
  29. begin
  30.   Result := FItem2;
  31. end;
  32.  
  33. var
  34.   TupleInstance: TIntStringTuple;
  35. begin
  36.   TupleInstance := TIntStringTuple.Create(42, 'Hello');
  37.   WriteLn('Item1: ', TupleInstance.GetItem1);
  38.   WriteLn('Item2: ', TupleInstance.GetItem2);
  39. end.
So the AI is not perfect, but close, and very well suited to improve on.

« Last Edit: September 29, 2024, 07:14:16 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

TRon

  • Hero Member
  • *****
  • Posts: 4377
imho AI is a waste of time but even then you can waste it running your own local AI instead of providing these companies with your input (and money).

They should be paying you for providing them with valuable information and not the other way around. This world is truly topsy-turvy and everyone seems to be buying it because of the FOMO. Every question asked, every piece of information provided  is free information and labour for them (you have to admit that the idea is genius).
Today is tomorrow's yesterday.

Thaddy

  • Hero Member
  • *****
  • Posts: 18483
  • Here stood a man who saw the Elbe and jumped it.
I don't think that is the case: Warfleys implementation was not scanned yet. It made this up from other snippets for you to improve upon. Still not perfect after my intervention. Helpful.
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

What I can do

  • Full Member
  • ***
  • Posts: 183
I'm a newbie so take it with a grain of slat.
I have used ChatQBT about 10 times or so.
Never have I just copy paste, cause most of the time I can clearly see it don't work that way.
The same goes for every example I have found most of the time it need adjustment to make it work.
I recently searched for CopyDirTree on how to copy a folder
the main part give by AI was from two different trials returned CopyDir and CopyDirectory to which neither worked.
The real reason I like AI is basically a go fetch some samples that can point me in a direction.
It's like a super search and get close to what I need.

Zvoni

  • Hero Member
  • *****
  • Posts: 3165
Have you used any AI tools for generating or improving Lazarus/Free Pascal code?
No.
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

VisualLab

  • Hero Member
  • *****
  • Posts: 693
I do not use any "artificial prompter" because:
  • from the descriptions of many people it follows that in the case of programming at present it is more artificial stupidity than artificial intelligence,
  • I can write simple source code myself without any problems,
  • a medium-difficulty problem requires well-defined questions, so I prefer to add the time spent on writing the question to my programming time, as a result the time consumption will be similar, but without bothering about AI,
  • I solve difficult problems with the help of books, documentation and my own work: design, prototyping, improving the prototype (and ultimately discussions on forums), because in this case AI cannot help me.
If current AIs had the ability to write source code at the level that Wolfram Alpha solves math problems (capability analogy), then it would be a helpful tool. It is not and probably will not be for a long time. A text concatenation tool (even an advanced one) is not a module that analyzes, designs, prototypes, tests and draws conclusions. So, programmers can sleep peacefully for now, but webmasters and scripters probably can't.

When a module appears that is capable of creating correct source code that works as intended by designers/developers (subroutines, classes, modules, etc.), it will most likely become part of an IDE like Visual Studio. And MS (or some other big IT corporation) will trumpet it so much that almost every programmer will know about it.

Seenkao

  • Hero Member
  • *****
  • Posts: 718
    • New ZenGL.
Да, я использую ИИ. Но больше не для программирования, а для поиска информации. Сейчас это очень удобный инструмент поиска! Пользуйтесь этим!

Всегда! Всегда пишите ИИ что он не должен использовать не существующие функции. Иначе он поставит вас в не выгодное положение.


Google translate:
Yes, I use AI. But not for programming anymore, but for searching information. It is a very convenient search tool now! Use it!

Always! Always tell the AI ​​that it should not use functions that do not exist. Otherwise, it will put you at a disadvantage.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Bogen85

  • Hero Member
  • *****
  • Posts: 703
AI is a software tool like any other software tool.
You can use it if you want, or you can ignore it.

I'm not a newbie. I use AI, minimally, but it is not a crutch.
I find it useful for some things.

This is my take on take on AI in the 2020s:
  • Ignore it at your peril.
  • Treat it as a panacea at your peril.

Either extreme is harmful. You need to find where you fit between the two extremes, but not judge the many software engineers in all areas of the spectrum (I know many, from beginners to extremely advanced and gifted) who find it a useful to some degree who actually benefit from it, and it is not a waste of time.

If the code in the answer does not look valid, I don't bother feeding it to the compiler, garbage in, garbage out, but depending on the prompt it can save a lot of time in quick prototyping of new ideas.

For example, I've searched for free pascal bindings to certain C libraries, and did not find them. I spent some time with mcpp, python pre and post scripts with h2pas, and was not able to come up with a reasonable binding, due the complexity of the C header file.

So sometimes I've asked an AI chat engine, and quite often it gives me a complete working binding, that required very little fixup. Since my extensive web searches did not find that particular binding, I don't see it valid that people say "Oh, it just finds and example of what you asked for and gives you that." Sometimes, maybe.... But quite often, not the case.

But like any software tool, you are not compelled to use it. There are many software tools that others use that they are benefited by, and I have no interest in those tools. AI is beneficial is used right and if you are not using it to leak your intellectual property "into the cloud".

I you consider AI a crutch for everyone that uses it, then one could argue that compilers are crutches.
Just write everything in assembly.
But than again, assembly would be a crutch then.
Just write down all the ones and zeroes and feed them into your computer with some rows of switches on your computer.
You don't need your keyboard, it is a crutch.  :D

LV

  • Sr. Member
  • ****
  • Posts: 377
I’m sure that ai will be used to collect as much information as possible and even more so after most people are completely dependent upon it.

Oracle co-founder Larry Ellison recently predicted that AI-powered surveillance will become an integral part of daily life (https://san.com/cc/oracles-larry-ellison-sees-ai-supervision-keeping-citizens-on-best-behavior/)


Hansvb

  • Hero Member
  • *****
  • Posts: 863
They exist. Not for from my town….

Quote
https://www.pal-v.com/en/


carl_caulkett

  • Hero Member
  • *****
  • Posts: 654
Hello everyone,

I've been experimenting with various AI models for assisting in code development with Lazarus/Free Pascal, including OpenAI (such as ChatGPT) and Claude (Anthropic). Both of these AI models seem to have their strengths, but I'm curious to hear from the community:

Have you used any AI tools for generating or improving Lazarus/Free Pascal code?
Which AI model do you find most helpful for our specific programming language and environment—OpenAI, Claude, or perhaps another tool?
Do you think these AI models are reliable enough for more complex coding tasks, or are they better suited for simple snippets and debugging?
I'm looking forward to your thoughts and any experiences you've had with these AI tools when working with Lazarus/Free Pascal. Thank you!

I've found that using the Preview version of Zed Editor is pretty cool. It gives you access to Claude 3.5 Sonnet, which does seem to have a reasonable knowledge of Lazarus/FPC. I think, however, it is best used by someone with a reasonable amount of experience with Lazarus or Delphi, since this makes it easy to spot when the AI is giving you incorrect information, and stop you being led down a massive rabbit hole. Also, from a personal point of view, I find that the tone of Claude 3.5 Sonnet's suggestions are way less patronising that GPT 3.5/4.0. I know it's an inanimate system but it makes a difference 😉

The trick is, I think, not to ask AI to construct huge lumps of code but to break the problem down into bite sized chunks and then use the AI to fill in the gaps in one's knowledge.

A good example happened the other day when I asked the AI if it could remove an ugly if/then/else statement that smelt pretty bad. It came up with...
Code: Pascal  [Select][+][-]
  1.   CharToAdd := specialize IfThen<string>(Character = 'UNASSIGNED', '_UNASSIGNED', Character);
  2.  

which simplified the code, and taught me something new 😉
« Last Edit: October 02, 2024, 11:33:51 pm by carl_caulkett »
"It builds... ship it!"

Thaddy

  • Hero Member
  • *****
  • Posts: 18483
  • Here stood a man who saw the Elbe and jumped it.
Joanna if you are really curious google for "Maarten Sierhuis", a very close friend of mine. You can even mention my name ;)
(His team wrote much of the mars lander software, using his own language that nobody knows:Brahms (the language, not the composer)
He used to be a good drummer too, but his brother is a better guitarist  (, because he plays in my band....)
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

 

TinyPortal © 2005-2018