Home/Blog/You Cannot Craft Software Faster Than Your Understanding - A Reflection on AI Assisted Coding

You Cannot Craft Software Faster Than Your Understanding - A Reflection on AI Assisted Coding

Feipeng Liu
8 min read

Lesson learnt from AI-assisted software development.

I've been coding a lot with AI coding tools over the past one year. These tools are amazing and I don't think I can ever go back to coding without them. And they will only continue to get better over time. However, one thing I've realized is that no matter how fast these AI tools can help me write code, I cannot move faster than my own understanding of the problem I'm trying to solve.

Code is a Communication Medium

In software engineering, code is not just a set of instructions for the computer to compile and run, but more importantly, a way to communicate with other developers in the team, and even with my future self. When conversing with another person, we listen and interpret what they say, and speak to express our thinking. Similarly, we read code to understand the context, and write code to express our intentions.

This is particularly true in complex systems where the codebase is intricate and a large number of people are working together. In such environments, we spend lots more time reading and understanding the code, the context, the problem, the requirements, and often write design docs and have discussions before even start writing code. The actual coding is sometimes the trivial part of the work.

In the "Vibe coding"[1] era, writing code is becoming easier and faster. People are saying every engineer is 10x more productive with AI tools. However, we can speak 10x faster doesn't mean that we should. Ultimately, someone needs to read and understand the code, and the more code there is, the higher the cognitive load is for the reader. And often, code is written once but read many times, so that recognitive load compounds over time.

How About Letting AI Read and Understand?

There are many stories online about how a developer vibe coded an entire project with AI tools, some without programming background. It's true that AI tools can write the entire software in one shot in some cases. But these are mostly hobby projects.

If the software is valuable, it will live and evolve for a long time. There will be bugs to fix, features to add to existing code, small and delicate polishes and changes to make. I found many times, I end up keeping instructing the AI tools to make changes and it will get stuck and add lots of irrelevant code. Almost it's always because I myself don't fully understand the code, and couldn't maneuver the tool properly.

Software Engineering is Building a Mental Model

One way to think about software engineering is as a process of building a mental model of the system we're working on. This model helps us understand how the different parts of the system interact with each other, and how changes to one part might affect the rest of the system.

When we read or write code, we're building the mental model. What matters is the software system reflects the mental model we have, and it solves the problem we aim to solve.

With AI coding tools, it's very easy to fall into the trap of just generating lots of code and solving the problem superficially, or even worse, incorrectly (but appearing correct on the surface). However, we don't really understand the code, and our mental model is vague or non-existent. We end up spending more time fixing bugs.

Be Lazy on Blind Coding

One of the three great virtues of a programmer is laziness [2]: write programs to automate tasks, write documents to avoid repeating explanations. As coding becomes easier with AI tools, I think we software engineers should also be lazy on coding or prompting AI tools.

From time to time, I found myself "working hard" to blindly prompt the AI tools to generate the changes I need, keep iterating on the chat session. It can easily take hours and end up with lots of garbage code. It's more effective to read the code, understand the problem, think about the solutions myself, and also ask AI to help to understand the code. These tools are actually quite good at explaining code and tracing the code path as well.

The real work is to build the mental model of the system to solve the problem, including reading, thinking and writing.

Conclusion

AI coding tools are great. They're amazing at creating demos or small projects. For complex systems, or software that is built to last, the real work for software engineers remain the same: build a mental model to solve the problem, which requires us to read, think more, and write less.

References

[1] https://en.wikipedia.org/wiki/Vibe_coding

[2] https://wiki.c2.com/?LazinessImpatienceHubris