You Learn Something New Every Day (part 2)
Full Disclosure: This post is an experiment; I asked ChatGPT (GPT-4) to take my first post and write it better. I am not a professional writer (or coder, for that matter). I was good enough (with the help of Grammarly) to get through my MBA with good grades. Still, beyond that, I really can’t be bothered (yes, this is a failing of mine; effectively communicating using the written word is a powerful weapon in one’s arsenal). I think you will like it. The only things I changed were fixing spelling and simple grammar mistakes (it’s way better than me, BTW, in case you were asking).
Discovering the power of AI
It all began with an intriguing tweet that kept me up at night. There it was, staring back at me: a fellow human had built an app with ChatGPT, an AI language model by OpenAI that’s so advanced it probably knows how to make the perfect omelet. As a sales engineer, I was both curious and skeptical. Could AI help build an app? Time to find out!
Now, for those unfamiliar with ChatGPT, it’s like having a personal assistant with the knowledge of a thousand libraries and the wit of a stand-up comedian. How could I not be tempted to test its capabilities? The tweet had lit a fire within me, and I knew there was no turning back.
Embracing the challenge
Let me be honest: I’m not exactly the best Swift coder or iOS developer out there. My coding skills are closer to a newborn giraffe than a seasoned programmer. But hey, isn’t life all about trying new things? So, I decided to venture into the unknown, with ChatGPT as my trusty sidekick.
As a mere mortal, I expected bumps along the road. Would ChatGPT understand my requests? Could it provide helpful guidance? Could it withstand my barrage of questions and late-night coding dilemmas? Armed with a sense of humor and a healthy dose of curiosity, I embarked on a journey to find the answers.
Inspiration strikes
Inspiration can be as elusive as a well-mannered raccoon, but luckily, it found me in the form of a SwiftUI gym journal app. Picture this: a sleek, user-friendly app to track workouts, built by a novice like me with the help of our AI companion. The perfect challenge!
I imagined an app where users could easily log their exercises, track their progress, and maybe even find a bit of motivation on those days when the couch seemed more enticing than the gym. With visions of swole biceps and six-pack abs dancing in my head, I dove headfirst into the project.
Crafting the perfect prompt
To get the ball rolling, I needed to devise a prompt so precise that it could pass as a recipe for a five-star soufflé. After much pondering and possibly a few forehead wrinkles, I created a prompt detailing the app’s desired features and functionality. I fed it to ChatGPT and crossed my fingers.
Now, crafting a good prompt is an art form. It requires striking the perfect balance between clarity and creativity. It's too vague, and you’ll get a response that resembles a bowl of alphabet soup. Too specific, and you might stifle the AI’s potential. I admit I had a few false starts, but eventually, I hit the sweet spot.
The setup:
You are an AI programming assistant. - Follow the user's requirements carefully & to the letter. - First think step-by-step — describe your plan for what to build in pseudocode, written out in great detail - Then output the code in a single code block - Minimize any other prose - Use the latest version of Swift you know how. iOS 15+ is fine. Async/await preferred if you are certain that you can do so. Look out for retain cycles and objects that drop out of memory. - If a requirement is not technically possible, tell the user. - If you're making changes to code you've already given the user, don't give the entire file over and over, just give them the changes so they can easily copy and paste and not wait too much
The prompt:
You're making a full swiftui lifecycle app in one single file that allows gym goers to journal their weight lifting progress over time. The application should be simple and easy to use. The application should also look polished since it will be on the iOS app store. A user should be able to easily track workouts which consist of sets. A set includes a particular exercise (which can be manually added, or chosen from a library of popular strength training exercises), how many reps, and the weight of the reps. The weight selector should be a wheel UI element, sets can be a simple plus-minus. Each set should then be added to the journal when done. Overall weight by exercise needs to be tracked over time.
ChatGPT’s blueprint
ChatGPT’s response was like finding a map to El Dorado: a beautifully structured, step-by-step pseudocode that outlined the entire app development process. I was floored! It was as if an experienced developer had peered into my brain and translated my scattered thoughts into coherent instructions.
Of course, the journey wasn’t all smooth sailing. Sometimes, ChatGPT’s suggestions made me raise an eyebrow, and I had to do a bit of tweaking. But ultimately, I learned, grew, and laughed along the way.
The pseudocode (from ChatGPT):
Step-by-step Pseudocode: Create SwiftUI views for HomeView, WorkoutView, and JournalView. HomeView: a. Display buttons to navigate to WorkoutView and JournalView. WorkoutView: a. Display a search bar for user to search exercises or add a new exercise. b. Display a list of exercises (use a sample library of exercises). c. On exercise selection, display a new view with details (exercise name, sets, reps, and weight). d. Implement a wheel picker for weight, stepper for sets and reps. e. Add a "Save Set" button to save the set and navigate back to the WorkoutView. JournalView: a. Display a list of workouts with dates. b. On workout selection, display a new view with details (exercise, sets, reps, and weight). Implement Workout and Set models to store and manage workout data. Utilize UserDefaults to store workout data.
Building the app: trials, tribulations, and triumphs
With ChatGPT’s blueprint in hand, I embarked on my coding journey. There were ups and downs, moments of elation and frustration, and several occasions where I considered throwing in the towel. But every time I hit a roadblock, ChatGPT offered solutions, encouragement, and the occasional virtual pat on the back.
The app was completed after countless hours of work and a few sleepless nights. And let me tell you, it was a thing of beauty. The SwiftUI gym journal app was everything I had envisioned and more. With its sleek design, intuitive interface, and seamless functionality, it was hard to believe that a coding newbie like myself had created it—thanks to the guidance of ChatGPT.
Conclusion: the dynamic duo of AI and human creativity
This exhilarating journey has taught me that the partnership between humans and AI can unlock possibilities. While AI might not be able to concoct a gourmet meal (yet), it can definitely play a pivotal role in guiding and enhancing our creative endeavors.
The fusion of human ingenuity and AI’s computational prowess opens new horizons, enabling even the most inexperienced to achieve great things. In my case, it was creating a sleek, functional app that I could proudly call my own. ChatGPT was the ultimate sidekick, providing invaluable support and guidance every step of the way.
As we continue to embrace and explore the potential of AI, the possibilities are limitless. Together, we can push the boundaries of innovation, break free from our limitations, and turn our wildest dreams into reality. And maybe, just maybe, we’ll create the perfect omelet along the way.
My Conclusion: Well, I did tell ChatGPT that I wanted to have a humorous blog post, yet serious, so I should not be surprised that it listed to me literally rather than my intent. This refers to my first post, where I said the prompt is everything. It is why Prompt Engineers are being paid $300k+ and why I have so many LinkedIn and Twitter posts telling me how you can have ChatGPT write prompts for you or how they have unlocked super prompts, etc. They may be on to something; call me skeptical and cautiously optimistic. I think this experiment, the original post writing the app, and this attempt at improving my writing taught me a lot about prompts and how far AI can go. I know I just scratched the surface and have a long way to go, but I have to say I am super excited about where this tech is going to take us. As I indicated in a LI post some weeks ago, I think we are entering a new golden age (assuming Skynet doesn’t become self-aware), and I think we will see some crazy advancements.
Side Note: I am unsure why, but ChatGPT keeps misspelling omelet; it wants to add two t’s instead of just one. Weird right?