AI-First Programming: A Revolutionary Approach to Learning and Coding
AI-First Programming: A Revolutionary Approach to Learning and Coding
Dive into the world of AI-first programming and discover how it's revolutionizing the coding landscape. From the basics to its potential future, get a comprehensive look.
Programming has always been a human first step, we do the thinking, the coding, the testing. What if AI could change that?
A.I. Definitely changed that for me. I’ve coded a few things by now the A.I. first way with Python, I can’t think of any other way to do it anymore.
Understanding AI-first Programming:
To first understand A.I. first coding, let’s revisit human-first coding.
Human First Coding
Say you want to use Python to code, albeit simple, you first need to learn variables, syntax, loops, what is considered text, what is considered numbers?
After you learn that and you go through the “Hello World” phase, you meet your first challenge. Let’s say write a program that changes an audio file to mp3. How do you take an input? How do you convert the file? Now maybe you do some googling, end up on stack overflow or skim through the python documentation.
You finally get an answer, you need a library that handles file conversions. Now you found out you needed the pydub library. Now you learn about imports and how to use the library, 2-5 hours in you’ve ended up learning all that and more and finally got a program.
In essence, you need to memorise everything, then apply.
A.I. First Coding
You don’t know anything. You only know that you want to use Python.
Prompt “Write a Python program that takes a wav and converts it to an mp3 then downloads the mp3. I’m writing in Google Collab.”
from pydub import AudioSegment
from google.colab import files
def convert_wav_to_mp3(wav_file_path, mp3_file_path):
audio = AudioSegment.from_wav(wav_file_path)
audio.export(mp3_file_path, format="mp3")
# Upload the .wav file
uploaded = files.upload()
wav_file_name = list(uploaded.keys())[0]
mp3_file_name = wav_file_name.replace(".wav", ".mp3")
convert_wav_to_mp3(wav_file_name, mp3_file_name)
# Download the converted .mp3 file
files.download(mp3_file_name)
I used GPT4 for this, you can see the full reply Here.
The Difference
Human first coding was slow, you had to learn, then build. You still have to memorize a lot of things and practice a lot of coding to stay sharp.
A.I. First Programming, It was quick, you didn’t need to learn too much. You didn’t need to memorize all the libraries to solve problems and it was fun.
I believe A.I. first coding is a much for fun and enjoyable way to learn.
My Journey with AI-first Programming:
I discovered A.I. first programming on a video explaining how to build A.I. agents, specifically, it mentioned the skill stack required. From there I’ve been coding everything A.I. first, learning more about Python as I go along.
I first started with a few simple use cases, using GPT4 to write small programs on Google Collab, asking it whether I could create certain automation, possibilities. I even ended up creating my own automation that opens up the Chrome tabs I need in the morning. All the while asking GPT to also explain the code it wrote so I understood it more.
Creating a program with Whisper: A Practical Application of AI-first Programming:
I wanted to use OpenAI’s whisper model to take a WhatsApp voice note and transcribe it for me. I decided to use Google Collab just because of how quick and simple it was to start coding.
My first challenge ended up being that when I downloaded WhatsApp audios they came out in a .opus file format. This was an issue as the Whisper model only took a small subset of file types.
I did describe it above but solving the process was rather simple. I prompted GPT, I specifically wanted a code piece that would handle any file format, regardless, and then turn it into a .pm3. I also asked it to validate if the file was in the right format first. Here is the end result:
import os
# Determine the file's extension
file_extension = filename.split('.')[-1].lower()
whisper_allowed_extensions = ["flac", "mp3", "mp4", "mpeg", "mpga", "m4a", "ogg", "wav", "webm"]
# Check if the file's extension is not in the list of allowed extensions
if file_extension not in whisper_allowed_extensions:
converted_filename = filename.rsplit('.', 1)[0] + '.mp3' # Create filename with .mp3
conversion_success = os.system(f'ffmpeg -i "{filename}" "{converted_filename}"') # Convert to mp3
if conversion_success == 0:
file_to_transcribe = converted_filename # Update the file to transcribe to the converted file
else:
print("Error converting the file.")
raise SystemExit("Conversion failed!")
Initially, there were some issues with GPT’s initial response, it used Pydub, but Pydub’s use of ffmpeg was limited and couldn’t actually convert a .opus file. After asking a follow up GPT turned to a more direct approach, straight calling ffmpeg through the os. Using A.I. to solve this ended up being way quicker than browsing the web.
The Advantages of AI-first Programming:
The Good and The Bad
AI-first coding literally makes coding accessible for almost anyone because of how simple it becomes to learn coding. Using A.I. to learn coding breaks down a lot of the traditional barriers to coding, the memorisation, even syntax is made simpler.
With A.I. first, a beginner could jump into a full stack project without even knowing how to put the stack together. It would be an enjoyable project filled with challenges and learning opportunities.
But never so challenging that you would give up. Around the corner is a Developer ready to help answer any questions you need. It even helps debug!
A few things can be said about the negative effects, you might have to play catch-up on some fundamentals of programming, AI won’t simply mention in passing what the Single-Responsibility Principle is, it also won’t tell you to split up your programs into pieces and not code all of it in one single file.
AI-first programming benefits for Beginners
Initially, A.I. first programming will help speed up your learning process. But later on, you will also be more prepared for an AI-first world. You will be able to code quickly and fluently be able to communicate with AI to help you solve problems!
AI-first programming benefits for Experienced coders
We all know by now that AI is here to stay, and AI is already majorly impacting a lot of industries. Learning AI first programming will speed up your workflow, speed up your problem-solving process, and Speed up your debugging. Never manually enter code comments again! (A sneaky suggestion: Try Cursor.so It’s awesome for AI-first programming)
AI-first Programming Across Different Languages:
I’m certain AI-first will be able to be applied to any language, but for beginners, I would suggest starting with Python. It’s basically the best place to start for anyone wanting to get into programming. Even easier with AI.
Models like GPT’s ability to code will depend on how much a certain language was talked about and how much code about it was available online at the cut-off point of its training. If a language might have changed a lot between 2021 and now GPT’s response might be less accurate.
There are probably a few great teams out there crafting fine-tuned models for languages or
Looking Towards the Future: The Potential of AI-first Programming:
AI-first programming just seems to be where the future is heading. I reckon soon coders will be hired not on their ability to code but their ability to integrate AI into their workflow to code faster and better.
Hired based on their ability to communicate clearly with AI to be able to get the right outputs.
Eventually, they’ll become managers of AI models doing the programming, being quality control.
I think every experienced programmer should be exploring AI first programming and its capabilities. If not for it’s benefits, for the fun!
A passionate blend of marketer and coffee enthusiast, James delves deep into the world of branding by day and explores the art of brewing by night. Delivering a diverse mix of insights - from the intricacies of the marketing landscape to the rich tales of coffee cultures and the ever-evolving realm of artificial intelligence. Fascinated by the potential of AI and its intersections with daily life, James remains at the forefront of tech trends. Outside the digital realm, he cherishes hands-on experiences, always keen to take on a new project or refine his coffee-making technique. Join him as he shares his brewed thoughts, tech insights, and adventures, one post at a time.