Recent

Author Topic: Which AI Model is the Best for Assisting in Lazarus/Free Pascal Code Development  (Read 3098 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: 718
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: 16409
  • Censorship about opinions does not belong here.
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 »
There is nothing wrong with being blunt. At a minimum it is also honest.

TRon

  • Hero Member
  • *****
  • Posts: 3810
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).
I do not have to remember anything anymore thanks to total-recall.

Thaddy

  • Hero Member
  • *****
  • Posts: 16409
  • Censorship about opinions does not belong here.
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.
There is nothing wrong with being blunt. At a minimum it is also honest.

What I can do

  • Full Member
  • ***
  • Posts: 127
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: 2797
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: 614
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: 649
    • 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

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1291
Maybe people who don’t know how to program think that they can use ai to trick people Into thinking that they are competent programmers.

This reminds me of the time I tried to trick germans Into thinking I was german by using google translate. I thought that the German Text from google translate looked great.

However the people fluent in german knew right away that it was google translate and had a good laugh.

The same goes for fpc compiler when people try to paste ai generated jibberish into it.

It would be a really good idea to institute a policy against using ai for posts in this forum just as other online help websites have.

https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned

If people don’t care about pascal enough to learn the language and type their posts themselves, they don’t deserve to have time invested into reading or answering their questions.
« Last Edit: October 01, 2024, 03:02:07 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Bogen85

  • Hero Member
  • *****
  • Posts: 702
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

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1291
I know what you’re saying but I also know how lazy most people are...

It’s like installing an elevator into a building and expecting that only people who are moving heavy things or have difficulty walking will use it... yes in either case most people with few exceptions will choose the path of becoming weaker because it’s easier you know..  ::)

They will become unable to do things that were easy before.

Quote
leak your intellectual property "into the cloud"
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.
« Last Edit: October 01, 2024, 06:40:37 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

LV

  • Full Member
  • ***
  • Posts: 197
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/)

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1291
Fortunately not all predictions come true, if they did there would be flying cars
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️


 

TinyPortal © 2005-2018