June 7, 2021.
I was sitting at my desk, watching WWDC (Apple's big software event) during my summer school US history class.
And suddenly, Craig Federighi (and his iconic hair) dropped it: people like you and me can build apps on an iPad with the Swift Playgrounds app.
That was one of the few moments in my life where I was genuinely excited for a software update.
I procrastinated on my app-building dream for 2 years. But then, our lord and savior ChatGPT was born.
What I Knew Before I Started 🧠
Before this experiment, I didn't know much.
I had a bit of experience in Python, and beginner knowledge in JavaScript, HTML, and CSS. For non-technical people, I can build a basic website and write a couple computer scripts.
As I was learning Swift, I knew what a string was, what an int was, and some of the basic math operations.
Everything else was as confusing as the The Emoji Movie.
The Task 🔨
When I was little, my friends and I would play a "higher or lower" game during long car drives.
If you don't know how this game works (did you not have a childhood?), here's a simple explanation:
1. Player A picks a number between 1 and 100
2. Player B guesses a number
3. Player A says higher or lower if their selected number is higher or lower than the guess
4. The game goes on until Player B can guess Player A's number
Here's an example of how a game might play out:
• Player A selects 33
• Player B guesses 50, Player A says lower
• Player B guesses 25, Player A says higher
• Player B guesses 37, Player A says lower
• Player B guesses 31, Player A says higher
• Player B guesses 34, Player A says lower
• Player B guesses 33
With this experiment, I'm going to recreate this game.
Learning Swift 👨💻
I kinda sorta knew a little about Swift from a few tutorials. I tried getting myself into app development in the past, but the habit never stuck.
In other words, I forgot almost everything.
The only "tutorial" I did before this experiment was the "Get Started With Apps" tutorial in the Swift Playgrounds app. The tutorial is completely free and taught me how to navigate the programing interface.
As I worked through the tutorial, I also used ChatGPT to explain any concepts that I thought were confusing.
For instance, Swift has this weird thing called a view. I had no idea what it meant, so I opened up a tutoring session with ChatGPT to wrap my head around this concept.
Using ChatGPT 💬
Once I finished the tutorial (with the help of ChatGPT), it was time for the main course: using ChatGPT to write the code to build this mini-game.
After a few failed attempts, here's the prompt that led to an almost-perfect result: "write the code to build a swift "higher or lower" game app using the Swift Playgrounds app on iPadOS"
If you're another beginner looking to recreate this experiment, I would use that prompt structure. Other structures led to ChatGPT writing the code for Swift playgrounds rather than apps, as well as other mistakes.
Fixing It Up A Little 🪛
Though ChatGPT is all-powerful, it isn't perfect.
When I first copy-and-pasted the code into the Swift Playgrounds app, I was confused—I kept seeing an error message.
At first, I thought it was a glitch. After all, it's ChatGPT.
Nope. There was a small issue around the end of the code that ChatGPT printed out (to be fair, this was only a small formatting issue).
This is where my 47-minute tutorial experience came into play. Knowing the structure behind Swift apps helped me fix the problem that came up.
After a few seconds, boom 💥. My app was complete.
What This Could Mean 🤔
Ok, this is kinda scary.
If I can build app like this, you probably can too.
Pre-ChatGPT, it would've taken me weeks if not months to learn how to code something like this.
That's freaking terrifying (especially since I'll be majoring in a tech-related field for the next four years).
Final Thoughts 💭
"I imagine a world in which AI is going to make us work more productively, live longer, and have cleaner energy"—Fei-Fei Li
Thanks for reading!
Adi
PS—This was written by ChatGPT 💀
PPS—Just kidding
PPPS—Or was it????