Unless you’ve been living under a rock, you probably heard about OpenAI releasing ChatGPT for a free research preview.
After the release, a bunch of different posts across Reddit and Hacker News started to emerge — outlining all the possible reasons why AI and ChatGPT will now replace jobs such as: Product managers, software engineers, tech bloggers etc. Usage of ChatGPT exploded, leading to sites like StackOverflow — to implement temporary policy to ban ChatGPT generated answers (source).
Look — I’m a technology lover. I like messing with technology; I like using technology to improve my life. I automate certain tasks using software; I adore my robotic vacuum and window cleaners, and after getting a dishwasher last year — I don’t understand why I didn’t get one earlier. But, I, personally, can’t share the enthusiasms or doom–like prophecies that we all, are soon, going to be replaced by AI.
Understanding AI
I’m not an AI engineer, and apart from messing a little with artificial neural networks and genetic algorithms many years ago, my AI knowledge is very limited. According to my understanding, AI, and especially the GPT–3 model — built upon feeding on initial content. This means that those models are analyzing existing texts or source code — and learn to generate meaningful content based on that. According to Wikipedia, GPT–3 was trained mostly on crawled websites (source). The famous GitHub CoPilot was trained on source code from GitHub repositories. And so, in my uneducated opinion, current AI models are limited by the knowledge we — humans — have created.
Taking AI for a ride
At first I was skeptical, but ChatGPT was topping Reddit and Hacker News front pages, as well as talked a lot among my colleagues, so I’ve decided to take it for a ride. It’s open for public, for a free research preview: https://chat.openai.com/.
Hey AI – write me a blog post
Before jumping to find whether I’ll be replaced as software engineer, I was wondering will I be replaced as a blogger. On Wednesday, I’m going to publish a new blog post that talks about cursor based pagination. You should totally subscribe to my newsletter to be notified when it’s published, as well as stay updated about any future posts. But in the meantime, I wanted to see — would ChatGPT be able to generate a blog post on that topic. And so I’ve asked AI the following:
write a blog post about cursor based pagination and comparison with traditional pagination, including examples for usage as well as cons and pros of each approach
It generated a nice post, but when it came to comparing pros and cons — the results became messy. It listed 3 pros for cursor based pagination, and while the first two were okay-ish, the third one is a big miss:
It’s more user-friendly. With traditional pagination, it’s difficult for the user to know how many pages there are in total, or to go directly to a specific page. With cursor based pagination, the user can see the cursor value and use it to navigate to a specific position in the dataset.
This is a complete lie. There is an easy way to both (1) know how many pages are there in total, and (2) go directly to a specific page. We’ve been doing it for decades. Moreover, depending on the implementation, the user is not always able to know and use the cursor as he desires. On complex datasets — cursors are opaque and meaningless to the user.
You could say that this is a mistake that can be easily fixed by a human later on, but wait! There’s more! When ChatGPT generated the cons of cursor based pagination, it wrote this:
It’s less predictable. In traditional pagination, the user always knows how many records will be on each page. With cursor based pagination, the number of records on each page can vary depending on how many records have been added or deleted.
The first sentence contradicts the pro outlined earlier. If I know how many records are on each page, I can know how many pages there are. The second sentence — is not entirely true, in fact it is possible (and recommended) to include a limit on the amount of records you retrieve using any type of pagination.
While I am amazed by the ability to generate, generally, good structured and informative post — it’s far from replacing a human, such as myself, who performed a good research combined with personal, and professional experience.
sudo ai – generate me some code
I’m safe with writing blog posts. Let’s see if I can be replaced as a software engineer.
I’ve asked ChatGPT to generate me some code:
Write a function that streams data from external API endpoint and caches it, using typescript and nodejs
And it produced the following result:
import * as request from 'request';
import * as fs from 'fs';
// Function for streaming data from external API endpoint and caching it.
async function streamData(url: string, cacheFile: string) {
return new Promise((resolve, reject) => {
// Check if the cache file exists.
fs.access(cacheFile, fs.constants.F_OK, (err) => {
if(err) {
// Cache file does not exist, so create it and steam data from the API
const fileStream = fs.createWriteStream(cacheFile);
request(url)
.pipe(fileStream)
.on('finish', () => {
resolve(true)
})
.on('error', (err) => {
reject(err);
});
} else {
// Cache file exists, so read data from the cache file.
fs.readFile(cacheFile, 'utf8', (err, data) => {
if(err) {
reject(err);
} else {
resolve(data);
}
});
}
});
});
}
ChatGPT suggested using a deprecated module — request
. Also, the code itself will fail linting because streamData
is defined as async
but there is no need for that function to be async, since the code uses callback style fs
and has no await
statements. Nitpicking, I know.
When I asked ChatGPT, what is wrong with the above code — it was smart enough to output this:
One potential issue with this code is that it uses the request
module, which has been deprecated and is no longer recommended for use. Instead of using the request
module, the code should use a more modern HTTP client, such as the axios
library, to make HTTP requests.
Another potential issue with this code is that it does not handle errors properly. In the case where the request
module throws an error, the code does not reject the promise, which means that the error will be silently ignored. To fix this, the code should add a catch
block to the request
call, and reject the promise with the error if one occurs.
It was able to catch the deprecated request
module, but said nothing on the unnecessary async
keyword, or suggested to use fsPromises
instead of callbacks for a more readable code.
Programming is more than just writing code
For some reason, people keep thinking that a programmer’s job is to write code, while in reality — our job is translating client requirements into code as well as designing, and maintaining complex systems. Writing new, fresh code — is relatively small part compared to maintenance and modification of existing code.
Questions, such as how to sort an array, were long ago solved with all possible algorithms. ChatGPT is no different from Google search for such question, except for being more convenient than performing your own search, while potentially producing wrong or outdated code. The power of communities such as StackOverflow — is that answers are audited and updated. I keep getting notification about new comments or updates to a question I’ve asked more than 7 years ago!
Don’t get me wrong — those are amazing results. I’m happy for the OpenAI team, and the people behind GPT–3 are, undoubtedly, incredible and talented engineers. But I believe that current AI models are limited by our existing knowledge. They are unable to create new things. They are able to remix existing knowledge. Takes bits from different sources, and try to put them in context. Those tools, in their current state, can be a great addition to other tools like searching in Google or using StackOverflow. But I don’t believe we are anywhere close to having an AI that can truly create new things — and thus replacing us in our jobs. Don’t trust me? At least trust an AI, then.
#WrittenByHuman