DEV Community

Cover image for Stop Asking AI to Write Your Code. Ask It to Explain Like You’re 5.

Stop Asking AI to Write Your Code. Ask It to Explain Like You’re 5.

Let’s be honest. I use AI tools daily. Most of us do 🤷‍♀️.

But there is a massive difference between using AI as a crutch 🩼 and using it as a rocket booster for your brain 🚀.

At first, when I got stuck on a tough concept, I would paste the problem into ChatGPT and ask for the solution. It gave me the working code. I felt productive for about five minutes. ⏱️

But then I realized something scary: if the AI disappeared tomorrow, I wouldn't actually know how to solve the problem myself. I was outsourcing my understanding. 😱

The Feynman Technique Meets AI 🤝

There's a concept called the "Feynman Technique," named after the physicist Richard Feynman. The core idea is simple: You don't truly understand a complex topic until you can explain it in simple terms so that a beginner (or a five-year-old) can grasp it. 🧠

AI is incredibly good at generating complex, technical documentation. But surprisingly, it's even better at generating dead-simple analogies. ✨

Instead of asking AI to do the work for me, I started using it as the world's most patient tutor. 👨‍🏫

The "Aha!" Moment: Python Lists and Zippers 💡🐍
Recently, I was looking at some Python code involving list comprehensions and the zip function. It looked something like this:

def mulTable(n):
    return [n*i for i in range(1,11)]

l1 = mulTable(3) # [3, 6, 9, ...]
l2 = mulTable(6) # [6, 12, 18, ...]

# The confusing part:
s = [x + y for (x,y) in zip(l1, l2)]
Enter fullscreen mode Exit fullscreen mode

If you ask a standard documentation search what's happening in that last line, you get an answer like: "The list comprehension iterates over tuples generated by the zip object, aggregating elements based on their corresponding index." 😵‍💫

Great. Accurate. But it doesn't stick in my brain (especially for slow learners like myself, having to read stuff over and over again to understand it for a brief moment, and forget it the next 2 minutes).

So, I changed my prompt. I asked the AI: "Explain this code to me like I am 5 years old." 🧸

The explanation completely changed how I visualized the data.

The ELI5 Explanation 📖
Instead of "iterating tuples," the AI told me a story about baskets and zippers:

Imagine l1 and l2 are two long baskets full of numbered balls 🧺.

The zip command is like the zipper on a jacket 🧥. It pulls the two baskets together, side-by-side.

It takes the first ball from basket A and the first ball from basket B and squashes them together (adds them up) ➕.

It moves down the line, zipping up the next pair, until it has a brand new basket.

Suddenly, the code wasn't abstract anymore. It was visual. I could "see" the zipper pulling the lists together. 👀🤐

How to make this work for you 🛠️
When you are learning a new framework, language, or algorithm, don't just ask for the "how." Ask for the analogy.

Here are some prompts I use constantly:

"Explain the difference between Docker and Kubernetes using an analogy about shipping containers 🚢."

"Explain recursion like I'm a kindergartener stacking blocks 🧱."

"Don't give me code 🚫. Give me a real-world example of why I would use a Linked List instead of an Array 🔗."

AI isn't going to replace developers who truly understand their craft. But developers who use AI to deepen their understanding will replace those who just use it to copy-paste. 📋

Some people might argue that AI has done more harm than good, but in my perspective, if used properly, AI is the best tutor you can have to teach absolutely anything, if the correct prompts are used!

Top comments (0)