how I solved the problem without writing a single line of code

Have you heard anything about AI coders? These are programmers who do not know how to write code. They all scare us, that they will come and take away our jobs. To what extent are these fears justified? Do you know that they are already among us?

It's not easy for them yet, they still have to go through interviews pretending to be regular programmers and learning SOLID principles. No candidate in their right mind would tell an employer: “I can't write code, ChatGPT writes it for me”, and employers also don't yet understand what to do with them, whether they can create good products, they don't understand how to evaluate their work, how much they are worth, how to interview them.

I am also still a skeptic, but since I consider myself a person with strong critical thinking, I asked myself: what if?

I decided to conduct an experiment and do the task without writing a line of code, with minimal technical knowledge, and this is what I got. In order for this post to fit into the framework of a 10-15 minute article, I made the assumption that the project already exists, someone helped me deploy it on their machine. I have PhpStorm, the settings for which were prepared by senior comrades, and I know where the command line is, into which I will copy-paste the commands. The task that I will solve will be junior+ level.

So, the input data is a small ready-made Symfony project with a little more than 200 code files and about 35,000 tokens (words). The project has advertisements where users can upload photos and videos. Uploading photos and their post-processing has already been implemented (resizing, removing meta information). Post-processing occurs asynchronously via Messenger. While the photos are not processed, they and the ad itself are in the ENQUEUED status. After processing they receive the ACTIVE status. The task that stood was to do post-processing of the video. There is no need to re-encode the video, but removing the meta information was very important because the phone video contains the coordinates where the video was taken, and this is very personal information.

Since we don’t know how to write code, the first thought that comes to mind is to download the entire AI project and write a task for it. I wrote a small script (I still had to write one line of code!), which collected the entire project into one file:

find . -type f \
  -not -path './vendor/*' \
  -not -path './var/*' \
  -not -path './assets/fonts/*' \
  -not -path './assets/vendor/*' \
  -not -path './.*' \
  -not -path './public/assets/*' \
  -not -path './public/uploads/*' \
  -not -path './*.lock' | \
  while read file; do
    echo "# $file";
    cat $file;
    echo "";
  done > project.txt

The file size I got was 424K, which is a problem since the maximum size of the ChatGPT context is 32K. But then there is Claude, and its size is already 200 thousand tokens (words). My project has 35 thousand tokens, so it should be enough. Especially since the new version 3.5 Sonnet was released just a few days ago. Well, let's try.

I upload the project to him and before he starts writing code, I want to discuss the task with him and listen to how he will implement it:

Analyze project code, use its content and stylistics as a reference. I need to implement the following task:

When posting new ads, it's possible to upload videos. Currently, the video is uploaded and then publicly available as it is, which causes some security issues. We need at least to remove meta tags.

First let's talk about how you will implement this task. Suggest ideas.

Claude gives a very reasonable solution: create a new event for video and a handler for it, similar to image processing. Call the event in the controller when loading the video. He suggests using the FFmpeg library for editing video, suggests changing the video status during processing, and changing the video output so that unprocessed videos are not shown. As a bonus, he suggests creating a preview for the video. I didn't have such a task, but I didn't immediately notice it and didn't tell him anything about it.

Here I need to make a small digression. It's great when I have experience and can understand that the advice is reasonable. But how can a person with no programming experience understand that he is not advising complete nonsense? The answer to this question is actually simple. Just like understanding that a professor at a university is not telling some nonsense – firstly, he does sometimes tell it, and there is nothing wrong with it, mistakes can and should be made. Secondly – well, we don't need to be a great chef to say that a steak is delicious. Common sense will sooner or later tell us what can be done, and what should not. Plus, after communicating with AI for some time, you begin to feel well where the AI ​​is confident in its judgments, and where it is not so much. In the end, if you are not sure, you can ask it again! But even if your “gut feeling” is not yet sufficiently developed, you can always just take on faith the fact that what it does is more correct than not. We do this every day in our daily lives, I don't see any problem in doing it here too.

So, I accept his decision as appropriate. And we move on. I need to somehow get the changes that need to be made. If I simply ask for everything that needs to be changed, then with a high degree of probability, after a couple of dozen lines, he will say something like: “Well, you can add it here yourself.” I need to ask him to give the result in parts, and I ask him to give a list of files in which there will be some changes.

Print a complete list of files that need to be changed

Claude gives me a list of files to add, change, or potentially change, along with a short description of what each file contains. In the same order he gave me the list, I ask for their contents.

print the content of src/Message/ProcessVideo.php

It gives some code, I create a file and copy it there. I ask for the following file:

print the contents of src/MessageHandler/ProcessVideoHandler.php

It gives you the contents of the file and says you need to run a command to connect FFmpeg. Having not the slightest idea what FFmpeg is or what Composer is, I blindly execute the command, and it works.

There was already more code in this file. Suddenly, the inner programmer in me woke up and I saw that FFmpeg is used explicitly in the handler, and in our project it is customary to transfer all dependencies from the outside. I don't think this is a big problem. Indeed, every project has its own practices, we have it this way, Claude did it differently. In a good way, along with the project, I should have given our coding standard in the initial prompt, which would probably have said something about SOLID and Dependency Inversion, and I’m almost sure that he would have written it correctly right away. Since I did not give him such a document, I simply asked him to transfer all dependencies from the outside.

Then the problems began, because I am an attentive person. I saw that PhpStorm allocates separate pieces of code to me. When he hovered over them with the mouse, he displayed some text saying that he could not find something. I have no idea what it is, but if PhpStorm tells me about it, it means it considers it important, and I copy it to Claude, it generates new code, the error goes away.

Seems like method stripMetadata does not exist in $video->filters()

My inquisitive mind noticed that among the pile of incomprehensible code, sometimes there was quite human text. For example, my eye caught these words:

// Generate a thumbnail (optional)
// Create a new video format
// Remove metadata and save the processed video
// This removes all metadata
// Use H.264 codec for video
// Use AAC codec for audio
// Remove the original unprocessed video

I was a little surprised, because I didn't ask to generate a preview (thumbnail), and I was also confused by the fact that it uses some codecs. Why, if I just need to remove metadata? The task clearly stated that there was no need to recode.

I'm not sure, so I decide to ask questions.

1. Remove code related to video thumbnail generation, I don't need thumbnails for video.

2. I'm wondering about the performance of your approach. Will it re-encode the entire video file or just remove meta tags?

Claude agrees that he has indeed done too much. Mentions of thumbnails disappear from the code and comments like this appear:

// Create a format that copies streams without re-encoding

It seems like that's what's needed, but now PhpStorm starts highlighting words again. According to the old scheme, I throw all the errors at it, and sooner or later it writes code that at first glance can be run.

Likewise, I applied all the changes he suggested to me. I wrote to him about all my thoughts and experiences that arose during the process, and he corrected them. He made mistakes, sometimes it turned out just subjectively ugly, sometimes he suggested adding code that already existed, but in general, he didn’t do anything for which I would need the ability to write code.

So, all the changes are applied, I try to upload a video, there is an error on the screen and a lot of other text:

App\Message\ProcessVideo::__construct(): Argument #1 ($videoId) must be of type int, null given, called in /home/eug/PhpstormProjects/my-project/src/Controller/UserController.php on line 148

Although it seems to me that if I had simply selected the entire contents of the window and copied it to the chat window, then Claude would still have understood where the error was, but I helped him a little and went to the debug console for a machine-readable backtrace. It seems to me that soon we should see how frameworks will output debugging information that is not only beautiful to the eye, but also convenient for AI.

It wasn't hard for Claude to figure out that he was calling getId() before doing flush(), and therefore instead of id he was passing null to the handler.

In the latest version the error has gone away, the video has been saved successfully, the meta tags have been successfully removed.

In principle, we could have stopped there; the task as a whole was successfully completed. But I noticed that the video is processed synchronously when loading. Of course, I understood why – I needed to configure the routing for the new message to use the async transport, but that’s not interesting. I want him to figure it out for himself. After all, he himself wrote at the beginning of the task that the video will be in the ENQUEUED status until it is processed. I ask him a question:

I uploaded a video, but it's in active state in the database, shouldn't it be enqueued?

And he also did an excellent job with this issue, offering several options as to why this might be so, one of which was to reconfigure the routing.

conclusions

So, what do we have in the end? The task is done, the code review is done, yes, there were errors, but they were found and fixed, I personally did not write a single line of code (okay, just one).

The main question: can a person who doesn't know how to program write code? My answer is yes, it is already quite possible. It seems that the chat interface is not very convenient yet, because you have to copy pieces of code. It would be much more convenient for the AI ​​assistant to create and edit the necessary files in the project directly in the IDE, but I think this is a matter of a few months.

I seriously urge you to stop asking during interviews about different types of sorting and the difference between B-Tree and AVL-Tree, and start testing your ability to use AI assistants. Whether you like it or not, AI coders are already appearing among us, and they already sit for days in front of monitors and solve real problems no worse, and in some places better than “traditional” programmers, while not knowing how to write code at all.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *