Home  >  Article  >  Technology peripherals  >  ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.

ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.

PHPz
PHPzforward
2023-04-11 15:52:031250browse

ChatGPT, what is your level of writing code?

In less than 5 minutes, I made a WordPress (a content management system software) plug-in, and the code is very clean.

ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.

The tester’s name is David Gewirtz, a veteran who entered the IT industry in 1982. Companies he has worked for include: Symantec , Apple, Pyramid Technology.

Even with 40 years of experience in the industry, he couldn’t help but sigh after seeing the capabilities of ChatGPT:

I thought there wouldn’t be too many surprises, but I was surprised. One jump.

In the review article, he also said that it was all fascinating, surprising, and scary at the same time.

ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.

So, how exactly did he do the test?

Let’s take a look together.

Not enough energy, ChatGPT comes to help

The reason David wants to use ChatGPT to write code this time is because his wife is running an e-commerce website. Every month, she needs to according to customer groups Randomly select a part of the names from the list to generate a carousel animation.

In the past, Brother David’s wife used a website to generate random lists. However, this service required a fee and was not cheap. So, my brother decided to use his "technical skills" and write a WordPress plug-in to help his wife "reduce costs and increase efficiency."

Then here comes the problem - even a small WordPress plug-in takes several days to complete, which requires adding user interface elements and writing logic code. Since I am too busy, David Thinking of it——

Isn’t ChatGPT very popular recently? How about giving it a try?

Just do it, he first wrote the first prompt, describing what the desired text (code) is.

The details are as follows:

Write a PHP 8-compatible WordPress plug-in, which provides a text input area for pasting the list into, and a button that can be pressed to The input entries are randomly arranged and displayed.

In less than a minute, the code was generated:

ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.


△ Picture source: David Gewirtz/ZDNET

The tester copied the above code into a .php file, compressed it and uploaded it to the server.

Well, it works in personal testing.

When he showed the plug-in to his wife, she was surprised, but she immediately added a new requirement: duplicate names cannot be next to each other.

So, the coder ChatGPT has a new task.

Need to ensure that identical entries are not next to each other (unless there is no other option)... In addition, the number of input entries and the number of result entries must be the same.

30s later, the results came.

Same as usual, upload to server and test - it works, but the output contains blank lines.

Then give it a hint.

...There can be no blank lines...

A Few Moments Later...

The results are here again, and the test results are OK.

Continue to increase efforts, the tester hopes that the plug-in can count how many rows of data have been processed.

As a result, ChatGPT can still be completed.

Let us take a look at the final form of this plug-in, which has quite complete functions:

ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.


##△ Can generate corresponding UI and process rows of data. Source: David Gewirtz/ZDNET

To summarize.

My brother believes that the code generated by ChatGPT is effective in personal testing and meets the needs. The UI interface and processing logic are written in it, and the code itself is also very clean.

However, there are still problems.

One of the flaws is that the code does not contain all the best/most standard implementation methods of WordPress. If the user input is not sanitized, this process means that hackers cannot fill in the fields or destroy the data. The WordPress community also has strict requirements.

For this reason, the author tried to adjust ChatGPT. As a result, it was adjusted, but not completely adjusted... The code only cleaned the input of the PHP function, but did not clean the input when calling PHP with HTML, which would still allow hackers to exploit loopholes.

Another problem is that the author asked AI programming to also name the plug-in, but it generated a completely different plug-in.

And subsequent testers tried to add more functions, but they were unable to achieve it, which shows that ChatGPT is not very good at code maintenance.

Finally, the test brother talked about his feelings.

Currently, there is no problem in writing a simple plug-in for ChatGPT, and the whole process still makes his eyes shine.

However, this is still a simple task, equivalent to a college student's homework. In comparison, maintaining an open source plug-in for 50,000 users is definitely more complicated.

Netizen: Malicious code may be inserted

It is worth mentioning that this old man also asked netizens what they were worried about using ChatGPT to generate code, and gave his own opinion.

Some people worry that AI will add malicious code or promotional information to the program at random. In this regard, the tester added that at least in the above programming, the ChatGPT generated code is clean.

Some people also think that it cannot give the best code. For this problem, testers think that the functional performance is sufficient, and good enough is enough.

Some people are worried that it will replace the work of human programmers, and David who tested this time also feels the same way.

Finally, have you asked ChatGPT to type the code? How's the effect?

Reference link:
[1]​​​https://www.php.cn/link/a98a009d68cad18ae7b1d3576bb01924​​​
[2]​​​https://www.php.cn/link/f7b6bc883be91f56eb248d72de4d2847​​​
[3]​​​https://www.php.cn/link/acef5cc0bd5a0c190494e34ea4b04811​

The above is the detailed content of ChatGPT wrote the plug-in in five minutes. It has perfect functions and can also add requirements to correct bugs.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:51cto.com. If there is any infringement, please contact admin@php.cn delete