A.I. as a programming assistant..?

What is the basis for reason? And mathematics?

Moderators: AMod, iMod

godelian
Posts: 2742
Joined: Wed May 04, 2022 4:21 am

Re: A.I. as a programming assistant..?

Post by godelian »

attofishpi wrote: Fri Jul 12, 2024 2:16 am these awful scripting languages such as PHP\JS.
I think that it is always better to first prototype an MVP.

Users may not know what they want but they certainly know what they don't want when they see it.

PHP and especially JS are eminently suitable for the purpose of prototyping. Furthermore, most software won't make it past the prototype stage anyway.

If it does, like the initial PHP code for Facebook, then at least it's worth reengineering. Facebook took control of the PHP scripting environment by replacing it first by HipHop for PHP (HPHPc) and then by HipHop Virtual Machine (HHVM).

If the internal data structures of the application are for business reasons immensely flexible, then porting the code to a system language won't make any difference anyway.

For example, porting Facebook to C, C++, or Rust won't make any difference. They even tried generating C with HPHPc but to no avail. Deeply nested arrays and objects, i .e. full-on JSON, yield very flexible data structures. They are not faster to deal with in a system language. Strongly typing hierarchical tree data structures doesn't work either. It won't be any safer than dynamically typing.

Hence, these awful scripting languages are almost always the better choice.
User avatar
attofishpi
Posts: 13319
Joined: Tue Aug 16, 2011 8:10 am
Location: Orion Spur
Contact:

Re: A.I. as a programming assistant..?

Post by attofishpi »

godelian wrote: Thu Jul 25, 2024 1:13 am
attofishpi wrote: Wed Jul 10, 2024 6:49 am
if (category === 'person') {
options = ['John Doe', 'Jane Smith', 'Bob Johnson'];
} else if (category === 'country') {
options = ['USA', 'Canada', 'Mexico'];
} else if (category === 'symbol') {
options = ['Heart', 'Star', 'Circle'];
}

Hey presto!! It gave me SAMPLE peoples names, country names, symbol names - just wow honestly!
I would rather write it as following:

Code: Select all

var optionsByCategory = {
"person":  ['John Doe', 'Jane Smith', 'Bob Johnson'],
"country": ['USA', 'Canada', 'Mexico'],
"symbol":  ['Heart', 'Star', 'Circle']
};

var options=optionsByCategory[category];
ChatGPT's suggestion inter-mixes data with a particular code fragment that happens to use it.

If another code fragment ever needs the same configuration data, you are going to have to copy and paste and therefore duplicate the same data.

It also becomes impossible to query the configuration data in other ways than initially expected. For example, "To what category does "Circle" belong?", cannot be answered by the data in the code suggested by ChatGPT.

It's usually a bad sign when you see heavy mixing of data and code.
Your sample code is way clearer. I'm really quite a noob at PHP\JS hence why I am using GPT a lot..when I've had GPT provide sample Javascript it really does look messy some times.
What I've done with PHP that generates the lists of category-->sub-category they are generated as variable elements from an array read in from *.txt files thus iterated as echo (of the messy way GPT generated the sample):-

⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀while($indx < $arrayMax) {
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀echo '"' . $countryArray[$indx] . '"';

..and that's messy - probably not the way to doit but it's working. It's just a hobby site I'm doing so not worried about it too much. I haven't worked on it for a few weeks, got to work out the best way to continue a PHP: session_start(); to work with the browser as selections are made with http POST back to the PHP- thus when a textarea is loaded with current (subcategory) selection (*all subcatgorys are unique) the text area populates with what is currently on file on the server, then this can be edited a the POSTed back to overwrite the original file. *I managed to get a single category/sub selection then edit and post working but from memory it was screwed when I attempted a second selection from the drop down - I gotta get my head around the session thang, so if you know of the best standard way of PHP<--->HTML/JS to continue a session where data can be transferred until the user clicks "DONE" then I'd appreciate it. :D
Last edited by attofishpi on Thu Jul 25, 2024 2:20 am, edited 1 time in total.
godelian
Posts: 2742
Joined: Wed May 04, 2022 4:21 am

Re: A.I. as a programming assistant..?

Post by godelian »

attofishpi wrote: Thu Jul 25, 2024 2:04 am it was screwed when I attempted a second selection from the drop down - I gotta get my head around the session thang, so if you know of the best standard way of PHP<--->HTML/JS to continue a session where data can be transferred until the user clicks "DONE" then I'd appreciate it. :D
I never use the session for anything else than checking that the user is properly logged in. If you use it for anything else, chances are that it is a bad idea.
User avatar
attofishpi
Posts: 13319
Joined: Tue Aug 16, 2011 8:10 am
Location: Orion Spur
Contact:

Re: A.I. as a programming assistant..?

Post by attofishpi »

godelian wrote: Thu Jul 25, 2024 2:16 am
attofishpi wrote: Thu Jul 25, 2024 2:04 am it was screwed when I attempted a second selection from the drop down - I gotta get my head around the session thang, so if you know of the best standard way of PHP<--->HTML/JS to continue a session where data can be transferred until the user clicks "DONE" then I'd appreciate it. :D
I never use the session for anything else than checking that the user is properly logged in. If you use it for anything else, chances are that it is a bad idea.
Ok. I got the username\password session working with a fail counter of the standard 3. I do find the concept of the rather stagnant browser talking to PHP in some form of 'synchronous' way a tad confusing..will need to do some research of the standard
User avatar
attofishpi
Posts: 13319
Joined: Tue Aug 16, 2011 8:10 am
Location: Orion Spur
Contact:

Re: A.I. as a programming assistant..?

Post by attofishpi »

Oui tis.
Post Reply