|
Post by Carl Gundel on Nov 11, 2023 10:58:49 GMT -5
So, I keep hearing about how ChatGPT can replace programmers. I think it is a fascinating technology, and I used to work in the AI field at a company what actually did something similar twenty years ago, with some PhD computational linguists who were famous in their own field so I know at least a little bit about this.
I thought it might be interesting to ask ChatGPT 4 (the paid version) to write a little Liberty BASIC code. I wondered what if it could give me something like the dictionary key+value lookup functionality that I created and wrote about in my blog.
I asked it: Can you write me a simple string lookup by string key in Liberty BASIC, storing the keys and values in a much larger string. There should be a function for setting and getting the key value pairs.
For the record, it's reply explicitly said that this is Liberty BASIC code.
' Large string to store key-value pairs dim data$(1000) data$ = ""
function setKeyValue(key$, value$) ' Check if key exists and update pos = instr(data$, ";" + key$ + "=") if pos > 0 then endPos = instr(pos + 1, data$, ";") if endPos = 0 then endPos = len(data$) + 1 data$ = left$(data$, pos) + key$ + "=" + value$ + mid$(data$, endPos) else ' Add new key-value pair data$ = data$ + ";" + key$ + "=" + value$ end if end function
function getKeyValue(key$) getKeyValue = "" ' Find key in the data string pos = instr(data$, ";" + key$ + "=") if pos > 0 then startPos = pos + len(key$) + 2 endPos = instr(startPos, data$, ";") if endPos = 0 then endPos = len(data$) + 1 getKeyValue = mid$(data$, startPos, endPos - startPos) end if end function
' Test the set and get functions setKeyValue "name", "John Doe" setKeyValue "city", "New York" print getKeyValue("name") ' Outputs: John Doe print getKeyValue("city") ' Outputs: New York The eagle eyed here will notice a bunch of things wrong with this. I had to make a lot of changes to make it run.
' Large string to store key-value pairs
global dict$ ' Test the set and get functions a=setKeyValue("name", "John Doe") a=setKeyValue("city", "New York") print getKeyValue$("name") ' Outputs: John Doe print getKeyValue$("city") ' Outputs: New York print dict$
function setKeyValue(key$, value$) ' Check if key exists and update pos = instr(dict$, ";" + key$ + "=") if pos > 0 then endPos = instr(dict$, ";",pos + 1) if endPos = 0 then endPos = len(dict$) + 1 dict$ = left$(dict$, pos) + key$ + "=" + value$ + mid$(dict$, endPos) else ' Add new key-value pair dict$ = dict$ + ";" + key$ + "=" + value$ end if end function
function getKeyValue$(key$) getKeyValue$ = "" ' Find key in the data string pos = instr(dict$, ";" + key$ + "=") if pos > 0 then startPos = pos + len(key$) + 2 endPos = instr(dict$, ";", startPos) if endPos = 0 then endPos = len(dict$) + 1 getKeyValue$ = mid$(dict$, startPos, endPos - startPos) end if end function Now, I hear people say that ChatGPT is good for learning to program. How is the beginner supposed to know how to deal with the various incorrect things that this example illustrates.
I guess that ChatGPT wouldn't make such mistakes for Python or Java or Javascript.
|
|
|
Post by tsh73 on Nov 11, 2023 13:57:07 GMT -5
There is a things to diff two textfiles. Here I used "Compare" plug in for Notepad++. 1) It needs global data$. Obviously dim data$(1000) does something different... Oh, wait - arrays in LB are global Let as change all data$ to data$(0) That fixes it. (ugly I admit, but gets job done. GLOBAL is neater) 2) it did messed up order of parameters for INSTR I'd likely mess it too Ha-ha, it is QBbasic (QB64 etc etc) version of INSTR Easy fix, two lines "endPos = instr(..." 3) function getKeyValue should be function getKeyValue$ , and then calling, too Pretty obvious 4) setKeyValue "name", "John Doe" actually behaves as call setKeyValue "name", "John Doe" So let's convert it to sub. 5) now we got rid of errors, but to make it work we should move testing code (4 lines using functions) up front That's all, it runs and gets right result.
1) I am DEEPLY IMPRESSED it did not made any LOGIC errors 2) to fix errors it introduced one needs to KNOW Liberty BASIC, first so about I would quote
|
|
|
Post by Rod on Nov 11, 2023 14:17:06 GMT -5
I suppose if you had given it a set of expected outcomes it might have refined its code.
AI is coming, we have had it in the background in the financial services industry for years. It has faults, tellingly less faults than humans.
|
|
|
Post by Carl Gundel on Nov 11, 2023 14:33:55 GMT -5
I suppose if you had given it a set of expected outcomes it might have refined its code. AI is coming, we have had it in the background in the financial services industry for years. It has faults, tellingly less faults than humans. It actually wrote a program that should work in some hypothetical BASIC language. I don't see any logic errors (I didn't look too hard) in the code. It did an admirable job of interpreting my (carefully) worded request, so props for that. As for AI, most of what we call AI isn't very ambitious. Mostly tools and heuristics, etc. There are people really trying to advance the state of the art. ChatGPT is pretty cool, but it isn't as smart as people think.
|
|
|
Post by Carl Gundel on Nov 11, 2023 14:39:57 GMT -5
1) I am DEEPLY IMPRESSED it did not made any LOGIC errors Yes, that is impressive. Liberty BASIC has been around for LONG time now, and on the Internet since 1995 and ChatGPT supposedly has been reading everything, and there's plenty of LB code and discussion to read. PLUS, it claimed in its response to me that the code is written in Liberty BASIC, so 2) is less impressive than 1). So, this makes one question how smart this large language model thing really is that ChatGPT is based on.
|
|
|
Post by Rod on Nov 11, 2023 15:00:03 GMT -5
The word smart is interesting. AI will regurgitate intelligence incessantly, and so appear smart. It will also out perform humans at assessment and analysis because it has such accurate, structured memory. Neither does it tire or have bias.
But it can’t create new intelligence, so Einstein, Edison, Farady and Tesla, Sikorsky et all should relax.
Perhaps it should be called MI , mimic intelligence.
|
|
|
Post by Carl Gundel on Nov 11, 2023 15:09:36 GMT -5
The word smart is interesting. AI will regurgitate intelligence incessantly, and so appear smart. It will also out perform humans at assessment and analysis because it has such accurate, structured memory. Neither does it tire or have bias. But it can’t create new intelligence, so Einstein, Edison, Farady and Tesla, Sikorsky et all should relax. Perhaps it should be called MI , mimic intelligence. Mimic intelligence is good. However, systems like ChatGPT do not have accurate memory (or information?). When you get your information from the Internet then your information is inherently inaccurate and biased.
|
|
|
Post by tuppsoft on Nov 13, 2023 6:52:31 GMT -5
Claude.ai response
' String containing key-value pairs separated by "|" dim LookupString as string LookupString = ""
' Set a key-value pair in the lookup string sub SetLookup(key as string, value as string) LookupString = LookupString + key + "|" + value + "|" end sub
' Get the value for a key from the lookup string function GetLookup(key as string) as string ' Find position of key pos = instr(LookupString, key + "|") if pos = 0 then ' Key not found GetLookup = "" else ' Get value after key GetLookup = mid(LookupString, pos + len(key) + 1, instr(pos + 1, LookupString, "|") - pos - len(key) - 1) end if end function
' Example usage: SetLookup "name", "John" SetLookup "age", "30"
print GetLookup("name") ' Prints "John" print GetLookup("age") ' Prints "30"
|
|
|
Post by Carl Gundel on Nov 13, 2023 9:18:01 GMT -5
Claude.ai response ' String containing key-value pairs separated by "|" dim LookupString as string LookupString = ""
' Set a key-value pair in the lookup string sub SetLookup(key as string, value as string) LookupString = LookupString + key + "|" + value + "|" end sub
' Get the value for a key from the lookup string function GetLookup(key as string) as string ' Find position of key pos = instr(LookupString, key + "|") if pos = 0 then ' Key not found GetLookup = "" else ' Get value after key GetLookup = mid(LookupString, pos + len(key) + 1, instr(pos + 1, LookupString, "|") - pos - len(key) - 1) end if end function
' Example usage: SetLookup "name", "John" SetLookup "age", "30"
print GetLookup("name") ' Prints "John" print GetLookup("age") ' Prints "30"
At a quick glance not even covering how it isn't Liberty BASIC, that is fundamentally broken because it doesn't even check for duplicates when adding an entry.
|
|
|
Post by Chris Iverson on Nov 14, 2023 21:18:36 GMT -5
I've generally used ChatGPT as a reference or starting point for things when I've played with it, and I've overall been satisfied by it.
My best experience was when I had it generate example configurations for various scenarios for a Juniper SRX router, and it gave me better examples than Juniper's own documentation.
I don't trust its output directly, but it usually does get me going in the right direction with a good starting point.
|
|
|
Post by meerkat on Nov 15, 2023 5:11:40 GMT -5
I've been using chatGPT for about a year. I'm converting my RunBasic systems to PHP. Overall I'd say it does about 85% to 90%. I waited as long as possible to see if LB would eventually have what's needed for web and html. So sorry to say I'm moving to PHP. I'ts not a big job, only about 300 programs. It takes days to do with chatGpt, what would have taken me weeks. Basically very happy with it.
|
|
|
Post by Carl Gundel on Nov 15, 2023 9:52:53 GMT -5
I've been using chatGPT for about a year. I'm converting my RunBasic systems to PHP. Overall I'd say it does about 85% to 90%. I waited as long as possible to see if LB would eventually have what's needed for web and html. So sorry to say I'm moving to PHP. I'ts not a big job, only about 300 programs. It takes days to do with chatGpt, what would have taken me weeks. Basically very happy with it. It's a useful tool, but it's not as smart as people think it is. If you are skilled in asking the right questions it can give you useful answers. I asked ChatGPT to give me the angle between the opposite extremes of Earth's orbit around the sun against Alpha Centauri. It's answer was "The angle is negligible." LOL Not an acceptable answer my opinion. By asking it some more probing questions I was able to strongarm it into giving me an angle. Many people probably would not have been able to get there. So, it's useful for the right kinds of people.
|
|
|
Post by xxgeek on Nov 15, 2023 14:54:17 GMT -5
I have to agree, ChatGPT is not ready to take jobs away from programmers YET. It is a good helper though.
I only played with it a couple of times, and I had to be very specific with my questions, but in the end it solved my problem, or at least led me to something I hadn't considered that led me to a solution.
Even though it told me it knew how to program in LB, it did not truly understand the simplest syntax. Every time, I had to adjust the code to make it work. But at least it did help.
For now anyway, the programmer will be needed to verify the code is written properly.
|
|
Kuron
New Member
Posts: 20
|
Post by Kuron on Nov 16, 2023 21:42:40 GMT -5
AI prototype wows devs by turning drawings into working software: arstechnica.com/information-technology/2023/11/ai-powered-drawing-app-stuns-developers-by-turning-sketches-into-functional-games/As to Chat GPT, well it really depends on the language you are asking it for coding help with and I have asked with one language far more obscure than LB and it did pretty good. Its accuracy in general is lacking at times and it seems to make stuff up, but when it does, I call it on it and usually get it to admit it made a mistake and was wrong. Chat GPT is extremely interesting, . I truly wish I could have a local install of Chat GPT that was as capable of everything the free version knows and can do. I could unplug from the internet and happily spend the rest of my life using Chat GPT for entertainment. Ole' Kuron loves old westerns like Gunsmoke, The Rifleman, etc. I have used Chat GPT to generate several seasons worth of scripts for some of my favorite old B&W TV series. What it generates for these old series is far better than anything on TV today. The only time I ventured into color TV was a memorial episode of Seinfeld where they honored my Dad who passed away. Simply amazing as I only gave it his name and it managed to nail things in the episode he liked, like trains. I do not post much, or read here too much, but do give it a proper lurking now and then and try and keep up on things. I need to find my reg info for LB4, and get it installed again.
|
|
|
Post by meerkat on Nov 18, 2023 7:18:06 GMT -5
I've been using GROK the last few weeks. So far, for me anyway, it gives me better results than chatGpt. Simple stuff, we all understand, like placement of info using <script> document.getElementById('list').innerHTML = ";chr$(96) chatGpt can't seem to understand, but GROK does.
I'm still testing, but so far it seems to understand languages better than chatGPT.
|
|