I rarely use ChatGPT or any other AI for writing code. I've tried it on complex code I don't want to figure out, and usually it comes up all sorts of wrong. But today's post is an adventure in ChatGPT completely showing me up and making me feel inadequate.
Background
I'm an above average web developer. Well... I think I am. Everywhere I've worked, I've always been told that I'm the best webdev they've ever hired.
That isn't because I'm great (though I might be? I have been doing this for decades...), but probably more because companies (not talking big-tech here) don't know how to hire web developers.
The pre-interview is keyword focused. The takehome test is rudamentary at best. The interview questions by managers border on misunderstanding what they are actually asking.
My Companion/Competition
All of this to say: that while I am better than at least 50% of corporate web developers (I'd hope better than 75%), I'm worse than GPT-4 by an order of magnitude if not more.
I use ChatGPT multiple times a day, not so much on my software development, but random thoughts that pop into my head.
Some of my favorite subject matters to ask ChatGPT:
- Alternative history
- Clarifying historic events (I still cannot believe that no one on Columbus's ships had met an actual Indian before thinking that the Americas were the eastern shore of India)
- Questions about business
- Product description generator
- Social media post ideas
- Reading an email/document before I send it out
- Obscure luxury brands that new-money don't know about (I'm neither new-money, nor old-money and I cannot vouch for ChatGPT's correctness)
The list goes on and on. But occasionally, I don't feel like writing some boring bit of code, and I'll have ChatGPT write it so I can implement it. Usually silly things like a reduce function to get a specific output from an input.
This morning, I was writing some javascript, and I was about to bring in my library, linq.js, I wrote a long time ago (2018) that wraps the javascript array functions in some C#-y function names.
I wrote linq.js
as a fun little project just to teach myself and a few other people the "newer" javascript prototype functions (map, filter, etc). It took a couple of hours over a couple of days to conceptualize it, write it, test it, document it, and abandoned it. Could I have done it faster, sure.
I will occasionally bring it into a project so I can quickly query an array, but today I decided to let ChatGPT take the code I wanted to run, and make the library for me.
My Prompt
Can you create a modern javascript library that would make the following code work:
var arr = [{name: "Jeremy", age: 35, isAdmin: true}, {name: "Austin", age: 33, isAdmin: true}, {name: "John", age: 29, isAdmin: false}]
var oldestUser = arr.orderByDesc(a => a.age).first(); // return {name: "Jeremy", age: 35, isAdmin: true}
var youngestAdmin = arr.where(a=>a.isAdmin === true).orderBy(a=>a.age).first(); // return {name: "Austin", age: 33, isAdmin: true}
var nonAdminsUnder30Names = arr.where(a => !a.isAdmin && a.age < 30).select(a=>a.name); // return ["John"]
var nonAdminsOver30Names = arr.where(a => !a.isAdmin && a.age >= 30).select(a=>a.name); // return []
In under a minute, it had spit out a library that implemented all of these functions on the array prototype.
What took me a few hours, took ChatGPT a few seconds. I know this isn't news to anyone, me included. But this is the first time I've actually felt inadequate when paired up against it.
Most things I ask it to do, I ask it because I can't be bothered to do it. I don't want to research something. I don't want to write the same code I've already written a thousand times before. I don't want to fuck arround with css grid or flex until I figure out the exact set of properties and their values I need for the expected layout. These are all tasks I can do in a few minutes if I care to do them.
This library took me a few hours. I could have possibly written in in under an hour, possibly been slightly less "safe," but I could never have written it in 30 seconds or 300 seconds.
Conclusion
I will always be a better-than-average (better-than-median, at least) corporate web developer. Experience has taught me that the typical hire is not very good (especially with HTML/CSS/JS and understanding how HTTP works), and the ones that are good usually leave the corporate environment for higher paying jobs in tech.
As AI advances, there is no doubt that ChatGPT will be better than me at every task eventually, and not just the simple things. It already has the entire internet stashed away inside it's... transformers? I still don't actually understand AI...
But how I utilize the tools will hopefully help me keep relevant in this quickly evolving world. ChatGPT might "know" more, but it has a hard time "reasoning" still, and that is my evolutionary advantage, for now.