Skip to content

The limitations of ChatGPT

Posted on:May 3, 2023

Back in February I wrote a short blog about my initial experiences with ChatGPT, which was a fairly glowing review of the technology. After a few months of us getting to know each other however, I thought it might be worth giving an update on our relationship. Here are some scenarios I found myself in recently whilst using it...

Can it make my binary search more efficient?

As a little coding challenge I set myself the task to write a binary search in vanilla javascript. I completed the task no problem, tested every value in the array, and also gave it a target outside of the limits of the array. It was working well but I was curious to know if there was a more efficient way I could code it.

It told me the code was pretty good except I could swap the 'Math.floor((x + y) / 2)' for the bitwise right shift operator '( x + y ) >> 1' to divide by 2 and round down to the nearest integer. The bitwise operator was slightly more performant as it works on the binary level and didn't need to call a javascript function. I was pleased to discover a technique I'd not come across before so started to rewrite my code with this in mind.

I then wanted to challenge it further by asking it to test every number in the array and whether it could be found or not using the new conditions I'd written. It gave me a very confident response that everything was ok, all values in the array could be found if they were indeed the target. However, it then went further and supplied me with some more code which included my original solution using Math.floor()!

In the course of just one exchange it appeared to have no knowledge of what it had just suggested me. Alarm bells were going off...

Can it give me a list of packages that can generate Storybook stories?

I was looking into how to quickly create Storybook stories for a set of components and thought to myself, there must be a package out there that can generate stories in each component folder based on the types and component structure...surely. So I turned to ChatGPT to suggest me some npm packages that could do this. Here's the question and the very confident reply:

I then go off and try installing it from npm using the standard commands, but I get an unexpected error in my terminal. So I go searching manually on NPM and it turns out the packages don't exist. This is what happened when I confronted ChatGPT with this fact:

"...not a real package, but rather an example of a package name that could potentially exist...", woooaaah! This is some post-truth darkness right there. 

Can it generate Storybook stories from React code?

After that revelation I discussed the exchange with a friend of mine, and he mentioned he uses ChatGPT to actually generate code for Storybook stories...rather than ask it about npm packages that don't exist 😂. So I chucked an accordion component into ChatGPT and asked it to spit me out a story. It did very well, with just one line of code I had to tweak to get it to work. The alternative is usually to duplicate the story from another component and tweak multiple lines and mock data, so this was definitely an improvement.

Where do we go from here?

These experiences have certainly made me hesitate to turn to ChatGPT when I have a problem to solve, that's for sure. I'm turning to good old fashioned Google search, and real living human beings, aka colleagues, friends, acquaintances. All of which is no bad result of course. Who would have thought AI would turn us back towards eachother in search of a deeper connection.

But also, I'm sure I'll find a way through this rough patch by appealing to ChatGPT's strengths in ideation, inspiration, and draft code...rather than treat it is as some omniscient ultimate truth giver.