Thoughts on using ChatGPT as a software developer

QualityMinds | Aktualności | Blog | Development

As a frontend developer, I am already getting used to new frameworks popping out every second week and hype trains departing in each and every direction. Seldom a “NEW BIG THING” remains either new or big after some time. Sticking to foundations is usually enough to remain sane and keep the skills up to date. 

However, what happens if the whole concept of programming becomes obsolete by some newer and better paradigm? That’s the question virtually anyone in the industry has started asking since AI tools have gained momentum. With ChatGPT, it became too difficult to ignore.

We’ve decided to test the tool and to see if opening a carpenter shop is a more future-proof way to go. After several months of evaluation, we’re ready to draw some conclusions.

As a consulting house, QualityMinds also develop tailored software for our clients. So why not use the ChatGPT to generate some code?

Let’s imagine a chat feature. Users can send instant messages to each other. There’s an input field, a send button and a container holding the messages next to the user avatars or first letters of their initials. All of this is run by an Angular application with NgRx store in the background. Off we go!

Asking ChatGTP to render a chat component immediately gets me an Angular boilerplate for the new component, as `ng g c X` would do. The component for the message comes bundled with @Input()s – one for the message text, sender name, email and timestamp. All the information I’ve asked for using the prompt. Additional query generates a Jest spec file with the generic tests for the visual component. Some more prompts and we have an avatar with initials and chat messages with a speech bubble triangle – exactly as our UI Guru has imagined it to be. A look at the timer – 7 minutes 42 seconds time of work.

So, User Story done and I can get off for some mojitos?

No, not yet. First, some of the coding conventions are not applied. No wonder, as ChatGPT doesn’t know our code base and previous team agreement. I was too lazy to tell ChatGPT about all of that. Next, the components need to be put into all of the barrel files. Add some dependencies over Angular DI (translatePipe, custom project stuff etc.) and the TestBed setup of the component doesn’t fit anymore and needs to be fixed. Some tweaking here and there, connecting to the NgRx with all the selectors and effects, you know… Let’s see if I could complete this story on time.

Now let’s talk about some advanced topics we’re too busy to read up in the documentation. What’s the difference, say, between a switchMap and a simple map operators in RxJS anyway? ChatGPT, please explain how they are similar and what are the differences.

And here is where ChatGPT does wonders.

Not only does the tool explain in detail the differences, it also tells how to achieve similar functionality using each of the operators – and also what are the main areas of application for each of those. All of that using simple language and code examples that go far beyond your regular tutorial and the official documentation alike.

Speaking of which, it brings me another idea. Why bother googling things online if I can just ask ChatGPT? Indeed, for most of the time the results of the AI are more accurate and quick than traditional internet search. Instead of spending time trying to google an error and find its solution, asking ChatGPT gets to the intended result in close to no time.

What about POCs or trying to help your fellow colleagues using the stack you’ve never worked with before? Easy, ChatGPT takes care of syntax peculiarities as long as I can explain what my intentions are on a conceptual level. The more exact I define the problem, the better results I get. The daydream of getting multilingual without actually learning all other programming languages gets suddenly disrupted by the “There was an error generating your request” messages in the middle of the code block I was waiting for.

Now, let’s talk about the drawbacks.

First of all, ChatGPT doesn’t know all the context. Either you spend tons of prompts just setting the stage – without no guarantee whatsoever – or you get generic answers. The code snippets may be outdated, violate your coding guidelines, conflict with other parts of application or be simply wrong. Most usage of the generated code is achieved when applying “the power of the AI” to very limited, explicitly defined generic problems. It becomes a Junior Dev in your team that you get to micromanage.

Being very specific about the architecture can lead to the point of diminishing returns. That is, when explaining the tool what needs to be done under which constrains may cost more time than coding it yourself.

Mileage may vary depending on the programming language of your project. For TypeScript it produces fair results. For Unity, not as much.

Another thing: sometimes ChatGPT just lies to you.

It is notorious for inability to accept itself being wrong – even after being told so. ChatGPT is simply not capable of accepting the possibility of not being correct. We’re not sure if that’s a required feature in order to be a good chat partner or simply a side-effect of being trained on real, non-synthetic data.

Last but not least, some of us have started questions whether some additional luxury comfort during day-to-day work is worth a trade-off of GPU clusters sweating to generate some basic stuff and what are the climate implications of doing so.

To sum up, we came to a satisfactory conclusion:

We, the developers, are most likely to stick around for some more time.

There’s a whole lot of human responsibility when working with AI. A human being needs to take care of quality aspects. A human being maintains a big picture. A human being is capable of framing complex client problems in concrete steps – and of evaluating the most fitting solution out of the whole range of possibilities.

Along the way we’ve discovered qualitative difference in answers depending on formulations of the questions. Which means that prompt engineering is the next foundation skill that is worth investing into – unless you really don’t want or need to do anything with the chat based AI. The reward would be increased quality, speed and ultimately productivity when using this kind of AI for software development.

Never forget that software development is so much more than coding.

You as an individual have to live with the responsibility of thinking in abstractions, reasoning and being ready to admit not knowing anything or simply being wrong. It’s a social activity that ChatGPT is not capable of automating – at least, not yet.

0 komentarzy

Napisane przez

Boris Spivak