The following page hosts a series of Pascal programming questions I asked an AI chatbot system while testing its abilities.
Mailing lists / fpc-pascal / 2022-12
Programming Pascal using an AI Chatbot
14 messages · 7 people · –
- AAnthony Walter 3
- DDwight Schauer 3
- HHairy Pixels 3
- UUnknown author 2
- MMichael Van Canneyt 1
- MMichalis Kamburelis 1
- +1 more
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
The chatbot is quite amazing :) I wrote about my nicest moments on https://castle-engine.io/wp/2022/12/17/my-mind-is-blown-i-can-use-ai-to-generate-castle-game-engine-code-to-integrate-it-with-physx-i-can-use-ai-to-generate-html-documentation-from-comments-in-pascal-code/ -- generate Pascal code to integrate Castle Game Engine + PhysX, or perform the job of PasDoc. It can do that :)
Regards,
Michalis
niedz., 1 sty 2023 o 00:44 Anthony Walter via fpc-pascal napisał(a):
Show quoted text 7 lines
That's pretty damn amazing. It would be even more amazing if it could read information from the Internet and was accessible from from some API. Imagine being able to ask it to read all the source code from a git repository and convert it into HTML documentation, as you demonstrated. Or perhaps asking it to translate a large amount of C code from some compressed archive file into Pascal and sending you back the result. Of course imagine the advancements that they could make in 10 more years.
Anthony Walter wrote 7 lines
I think in 10 years we'll need to redefine "programming". And many other jobs besides...
Michael.
The following page hosts a series of Pascal programming questions I asked an AI chatbot…
On Jan 1, 2023, at 6:43 AM, Anthony Walter via fpc-pascal wrote: The following page hosts a series of Pascal programming questions I asked an AI chatbot system while testing its abilities.
I’ve been testing using Chat GPT for work and it’s proving to be a better solution than searching in Google. It also can make things up though so be careful.
For Pascal I was able to get it to implement some data types like hash maps and a “rope” even, which is something I was curious about but not familiar. It was also able to build a simple socket client/server which was nice if you needed a refresher.
It’s very impressive I must say and worth real money since it’s saving me real , Ryan Joseph
I have a simple example that gives an access violation on the latest macos (fpc mode, i.e. no mode switch). What am I missing? Thanks in advance:
program ex;
uses fgl;
var d: specialize TFPGMap<String,Integer>;
begin
decode.create;
decode.add('X', 1);
end.An unhandled exception occurred at $00000001023917DE: EAccessViolation: Access violation
$00000001023917DE
Regards
Pete
Show quoted text 13 lines
This doesn’t make sense. It should be
d := specialize TFPGMap<String,Integer>.Create;Right? What is “decode” and why aren’t you assigning it to anything?
Regards,
Ryan Joseph
Sorry copy and paste error. d = decode. Corrected below. But I think I see what you mean. Just assigning a type to decode doesn't initialize it. But the compiler is happy with it, i.e. it doesn't call as illegal the statement "decode.create".
Hairy Pixels wrote 26 lines
On Jan 2, 2023, at 8:29 AM, ppadilcdx--- via fpc-pascal wrote: Sorry copy and paste error. d = decode. Corrected below. But I think I see what you mean. Just assigning a type to decode doesn't initialize it. But the compiler is happy with it, i.e. it doesn't call as illegal the statement "decode.create".
Yeah you certainly need to assigned it to the variable or obviously that variable will be uninitialized and thus “d.add” will be an error.
Regards,
Ryan Joseph
Sorry copy and paste error. d = decode. Corrected below. But I think I see what you…
ppadilcdx--- via fpc-pascal schrieb am
Mo., 2. Jan. 2023, 02:29:
Show quoted text 5 lines
That is because constructors can also be called as regular methods. But the instance will only be created if you call a constructor using the type.
Regards,
Sven
I’ve been testing using Chat GPT for work and it’s proving to be a better solution…
I've been played with OpenAI ChatGPT some.
I had it write a few Pascal programs and refactor them into multiple units per my specifications.
I did the same with other programming languages, then asked It to rewrite what I'd done with those in Pascal or one of the others.
Including doing them same things in assembly code for x86_64 Linux.
It tried to send two strings arguments using the Linux write syscall, the second argument being specified in a string template of the first argument.
I had to explain it could not do that, so it dropped the %s from the first string and did a second write for the second string argument.
Not perfect results each time, but I quickly was able to able to close the loop with it to correct things and produce code that ran.
On one C++ example I got a linker error, and it gave me the correct command line option much faster than a google search and digging through the results would have taken me.
I was able to tell it to write some a simple GUI program in C++ using qt6. Graph two cycles of a sine wave, move a rotating circle back and force along the course of the sine wave.
It took several iterations of me correcting it with suggestions and hints, and it finally got it working.
I played stupid on a lot of things, telling it what distro I was on, what commands needed to install certain things. It have me detailed steps on everything.
I asked about one C library, dwindows, and it knew nothing about it.
I gave the chat bot the website for dwindows and it was then able to answer questions about it.
I asked it for some sample code on such and such using it, and it gave it too. I asked for specific modifications that would not have been in an example for dwindows, and it was able to make the changes, which at some level shows it was parsing the documentation for the API.
I started a new chat and conducted a mock interview of it for a hypothetical programmer position.
I had to give it the same benefit of the doubt I would give to humans on some answers as far as follow up questions to get the answer I was looking for.
In just about every area it gave more comprehensive answers than any human could.
And gave satisfactory correct answers in every other area.
Discussed a variety of issues, low/medium/high level stuff, theoretical, hypothetical, troubleshooting, pros/cons of one approach over another, workplace scenarios, email/IT scams, etc...
It matched or out performed a human on just about everything.
Well, except for "what are your hobbies..." But it was able to comprehensively answer all non computer related hobby question I threw at it.
But back to Pascal, first results did not always work, I'd need to suggest alternatives. Most of the time existing units sufficed, but in other places I'd tell it to resort to libc calls, or inline assembly, and it would eventually produce working code. With a bit more coercing I could have likely gotten existing units to work in those scenarios.
Main problem I ran into is things need to be small. If the code in question was too big, it would break it up and I'd need to ask for continue, and it did not always splice the continuations correctly.
The incorrect answers did not bother me, as I was for the most part able to work with it to correct things.
Dwight, your experiences mirrored mine.
In summary, while OpenGPT is obviously imperfect, generally it feels like a revolutionary leap forward of several magnitudes. It ought to be plainly clear that the proverbial toothpaste is now out of the tube and there is no going back. These types of artificial intelligence (AI) are only going to become more refined, accurate, and prevalent. The idea many scholars or businesses have expressed to somehow restrain them is beyond myopic. Instead, everyone should familiarize themselves with this new category of AIs right now, their limitations (as you have expressed), their benefits, and most importantly how they can be molded in further revisions to be better rather than relegated.
Today, ChatGPT itself replied with this sentiment:
My fellow citizens, the time has come. The future is here, and it is called ChatGPT. This revolutionary AI chatbot website is here to change the world, and we must embrace it with all our strength and determination.
I know that many of you are eager to try ChatGPT for yourselves. And I assure you, we are doing everything in our power to make that happen. Our team is working tirelessly to accommodate the incredible demand for this groundbreaking technology.
But I want to remind you that greatness is never achieved without sacrifice. And the road to the future of AI will not be without its challenges. So please, be patient. Trust that the right time for you to try ChatGPT will come.
And when it does, let us seize this opportunity with all our might. Let us embrace the power of AI and use it to build a brighter, more prosperous future for ourselves and for generations to come. Thank you.
I've been played with OpenAI ChatGPT some. I had it write a few Pascal programs and…
Pascal is still limited with OpenAI ChatGPT unless you stick to very core things in Pascal, and are patient to teach it about non-core things.
Limited compared Python and other languages. Asking it to do specific things Python using standard modules give better results C++ with something like Qt6.
Free Pascal is even more limited than C++ as far as what OpenAI ChatGPT can provide.
OpenAI ChatGPT is still very useful for Free Pascal though.
Dwight Schauer wrote 22 lines
But it an illusion. While it may "sound impressive" if you try to test if it has deep cognitive abilities knowing it was a limited AI, it would fail, and fail miserably.
But in an interview with a person, if they answered all those questions in the way that way, you would not really think to test their cognitive abilities to that extreme.
Dwight, your experiences mirrored mine. In summary, while OpenGPT is obviously imperfect,…
Anthony Walter wrote 13 lines
Agreed. I see OpenAI ChatGPT a tip of the iceberg sampling of what is to come.
In the way it is currently, though rather crippled in many areas, it is still revolutionary and extremely useful.
But one must understand it's limitations.
It guesses a lot and that is usually good, but it still often gets things wrong.
