Programming with Chatgpt
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Programming with Chatgpt
Just finished viewing this presentation on ChatGPT and found it easy to follow and interesting.
https://dronebotworkshop.com/chatgpt/
Wonder if it can also write a FreeBASIC program from a text description.
https://dronebotworkshop.com/chatgpt/
Wonder if it can also write a FreeBASIC program from a text description.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
I asked this: tell me about melissa o'neil's pcg32 prng
The response was concise but spot on.
I then requested this: write code in freebasic using pcg32 prng
The code generated used Uint64 and Uint32, so I included windows.bi. It also used C's bitwise shifts >> and << so I replaced them with shr and shl respectively.
A Quick Run in WinFBE worked fine, and it generated 10 random Ulongs as a test.
I checked the code and could not fault it apart from the include and bitwise shifts.
Considering Chatgpt is a prototype of only a few months, it is impressive.
The response was concise but spot on.
I then requested this: write code in freebasic using pcg32 prng
The code generated used Uint64 and Uint32, so I included windows.bi. It also used C's bitwise shifts >> and << so I replaced them with shr and shl respectively.
A Quick Run in WinFBE worked fine, and it generated 10 random Ulongs as a test.
I checked the code and could not fault it apart from the include and bitwise shifts.
Considering Chatgpt is a prototype of only a few months, it is impressive.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Programming with Chatgpt
@deltarho[1859]
Wow. Thanks for letting us know what you found about Chatgpt's abilities.
What if you ask it a simple beginner problem like:
"Write a FreeBASIC program to print out the nine times multiplication table."
Wow. Thanks for letting us know what you found about Chatgpt's abilities.
What if you ask it a simple beginner problem like:
"Write a FreeBASIC program to print out the nine times multiplication table."
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
"Write a FreeBASIC program to print out the nine times multiplication table."
I got this:
with
This program uses two nested for loops to iterate over the numbers 1 to 9. The inner loop performs the multiplication and uses the print statement with a format string of "##" to print out the result with two digits. The outer loop then prints a newline character to separate the rows.
The output was:
Which is not what we asked for.
I had to add declarations.
I clicked 'Regenerate response' and got this:
with
This program uses two FOR loops to iterate over the numbers 1 to 9, and within the inner loop, it calculates and prints the product of the current values of i and j. The semicolons are used to separate the elements printed on each line. The final PRINT statement adds a blank line after each row of the multiplication table.
The output, after replacing END with SLEEP was:
It is still not getting it. The last block only is what we should be getting.
Regenerating again and got this.
The output, after replacing END with SLEEP, was:
It finally got there.
It obviously got embarrassed because it didn't explain the code this time.
So, it was making a right dog's dinner out of a simple job.
The secret is to force it to rethink if you dislike what you are looking at.
I got this:
Code: Select all
for i = 1 to 9
for j = 1 to 9
print using "##"; i * j;
next j
print
next i
This program uses two nested for loops to iterate over the numbers 1 to 9. The inner loop performs the multiplication and uses the print statement with a format string of "##" to print out the result with two digits. The outer loop then prints a newline character to separate the rows.
The output was:
Code: Select all
1 2 3 4 5 6 7 8 9
2 4 6 81012141618
3 6 9121518212427
4 812162024283236
51015202530354045
61218243036424854
71421283542495663
81624324048566472
91827364554637281
I had to add declarations.
I clicked 'Regenerate response' and got this:
Code: Select all
FOR i = 1 TO 9
FOR j = 1 TO 9
PRINT i; " * "; j; " = "; i * j
NEXT j
PRINT
NEXT i
END
This program uses two FOR loops to iterate over the numbers 1 to 9, and within the inner loop, it calculates and prints the product of the current values of i and j. The semicolons are used to separate the elements printed on each line. The final PRINT statement adds a blank line after each row of the multiplication table.
The output, after replacing END with SLEEP was:
Code: Select all
1 * 1 = 1
1 * 2 = 2
1 * 3 = 3
1 * 4 = 4
1 * 5 = 5
1 * 6 = 6
1 * 7 = 7
1 * 8 = 8
1 * 9 = 9
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
4 * 1 = 4
4 * 2 = 8
4 * 3 = 12
4 * 4 = 16
4 * 5 = 20
4 * 6 = 24
4 * 7 = 28
4 * 8 = 32
4 * 9 = 36
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
6 * 1 = 6
6 * 2 = 12
6 * 3 = 18
6 * 4 = 24
6 * 5 = 30
6 * 6 = 36
6 * 7 = 42
6 * 8 = 48
6 * 9 = 54
7 * 1 = 7
7 * 2 = 14
7 * 3 = 21
7 * 4 = 28
7 * 5 = 35
7 * 6 = 42
7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
9 * 1 = 9
9 * 2 = 18
9 * 3 = 27
9 * 4 = 36
9 * 5 = 45
9 * 6 = 54
9 * 7 = 63
9 * 8 = 72
9 * 9 = 81
Regenerating again and got this.
Code: Select all
FOR i = 1 TO 9
PRINT "9 x "; i; " = "; 9 * i
NEXT i
END
Code: Select all
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
9 x 6 = 54
9 x 7 = 63
9 x 8 = 72
9 x 9 = 81
It obviously got embarrassed because it didn't explain the code this time.
So, it was making a right dog's dinner out of a simple job.
The secret is to force it to rethink if you dislike what you are looking at.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
I am working on a project which requires a 128-bit counter. FreeBASIC has not got a 128-bit datatype. There are a few ways to do this so I got Chatgpt to look at it.
The first attempt used a 16 byte array and was cumbersome, so I forced it to think again. The second attempt was not much better.
The third attempt started with:
Now we are getting somewhere because that is what I would do. I had to use windows.bi for LongLong; which is MSDN speak.
The rest of the code was respectable and failing any improvements by yours truly may end up in my project.
For FreeBASIC coding purposes Chatgpt works, but it is lazy and will churn out the fastest response it can get away with. To get the best out of it, we may have to lean on it by clicking on the 'Regenerate response' button.
It is not infallible, so DO NOT use in your code without getting your fine tooth comb out.
The first attempt used a 16 byte array and was cumbersome, so I forced it to think again. The second attempt was not much better.
The third attempt started with:
Code: Select all
Type UInt128
LowPart As Longlong
HighPart As Longlong
End Type
Now we are getting somewhere because that is what I would do. I had to use windows.bi for LongLong; which is MSDN speak.
The rest of the code was respectable and failing any improvements by yours truly may end up in my project.
For FreeBASIC coding purposes Chatgpt works, but it is lazy and will churn out the fastest response it can get away with. To get the best out of it, we may have to lean on it by clicking on the 'Regenerate response' button.
It is not infallible, so DO NOT use in your code without getting your fine tooth comb out.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
During testing, the logic wasn't quite right, so I went back and tried a few more regenerate tasks.
It just couldn't get it right.
It seems to fail with simple requests, which is a pity because it did a remarkable job with pcg32 prng.
It just couldn't get it right.
It seems to fail with simple requests, which is a pity because it did a remarkable job with pcg32 prng.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
I went back to the third attempt and used:
with Ulongint replacing LongLong.
I'll do a few tests, but it seems to be working.
It doesn't understand that when we overflow signed, we go negative, but when we overflow unsigned, we go back to zero.
Code: Select all
Type UInt128
LowPart As Ulongint
HighPart As Ulongint
End Type
I'll do a few tests, but it seems to be working.
It doesn't understand that when we overflow signed, we go negative, but when we overflow unsigned, we go back to zero.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
It is worth pointing out that if you register, you will not get your Inbox bombarded with emails. I have not heard from openai.com since I registered. At some point, they may contact me about a commercial version, but I have no objection to that. I have no idea why they waned my mobile number – perhaps it is a security issue.
So go ahead and register.
Added: The Pro version is likely to cost $42 (34.08 GBP) per month. Chatgpt costs a lot to run. Perhaps the free version will be phased out. The Pro version will see much less 'At capacity notifications' and will be faster, but even so I won't be buying into it.
So go ahead and register.
Added: The Pro version is likely to cost $42 (34.08 GBP) per month. Chatgpt costs a lot to run. Perhaps the free version will be phased out. The Pro version will see much less 'At capacity notifications' and will be faster, but even so I won't be buying into it.
Re: Programming with Chatgpt
I don't understand what the fuzz is all about, it seems that the whole world is going gaga over this Chatgpt, before you know it people will deify Chatgpt and treat as a superior intelligent entity
Re: Programming with Chatgpt
I'm starting on some hymns.
I'll try them out at closing time.
I'll try them out at closing time.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
I think I have shown that it isn't. On the one we have the wow factor with pcg32 prng for example and on the hand we have “Oh boy are you struggling with this one.”srvaldez wrote:people will deify Chatgpt and treat as a superior intelligent entity,
Last edited by deltarho[1859] on Jan 31, 2023 17:36, edited 2 times in total.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
It is worth mentioning that my only experience with Chatgpt is with coding. I have seen a few videos describing other uses. I can imagine many professions more than happy to part with 42 dollars a month.
Of course, criticism not evidence based doesn't cost anything.
Of course, criticism not evidence based doesn't cost anything.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Programming with Chatgpt
I have just read about someone who didn't ask for code, but presented code which was not working. Chagpt came back with working code, and it explained why his was not working.
Chatgpt as a debugger? That had not occurred to me.
Chatgpt as a debugger? That had not occurred to me.
Re: Programming with Chatgpt
A single event doesn't help much, it must be somewhat reliable. Even a broken clock is shows the right time twice a day.deltarho[1859] wrote: ↑Feb 01, 2023 16:09 I have just read about someone who didn't ask for code, but presented code which was not working. Chagpt came back with working code, and it explained why his was not working.
I only half followed the noise about chatgpt, but it seems mostly demonstration, and running own instances seems to be difficult (much more massive machinery required for training than for running)
Re: Programming with Chatgpt
It was on the TV a couple of days ago as well.
Another money spinner coming up the ranks.
But if you like it, fair enough.
Another money spinner coming up the ranks.
But if you like it, fair enough.