ChatGPT has become a controversial figure in software development circles.
Some view the AI assistant as just another programming tool, while others see it as a threat to human coders. Lost in the debate is a more nuanced understanding of how ChatGPT interacts with the coding process. Specifically, its tendency to excel more at reading code than writing it.
Reading and Writing Code: Humans vs. LLMs
For humans, reading code is twice as hard as writing it, but for ChatGPT and other large language models (LLMS), the opposite is true.
- Humans find reading and understanding unfamiliar code quite difficult compared to writing new code.
- ChatGPT struggles to write completely correct code, but has an easier time reading and explaining existing code.
- The relative difficulty reversal stems from humans using contextual knowledge and ChatGPT relying on pattern recognition.
ChatGPT: Code-Writing Intern
When writing code, ChatGPT will often provide a 95% correct solution. This eliminates a lot of typing for programmers, but it takes an expert to identify the 5% of the solution that's incorrect.
- Due to its training data limitations, ChatGPT's generated code usually contains some flaws.
- The code allows developers to skip repetitive programming tasks and focus creativity on tricky parts.
- Still, developers must carefully review the code to catch subtle errors before implementation.
ChatGPT: Code-Reading Mentor
When reading code, ChatGPT is much less likely to hallucinate. Having read a large variety of code, it's also much better at understanding the thought processes of other developers.
- Code reading taps more into ChatGPT's interpolation abilities versus extrapolation for code writing.
- Exposure to such a wide breadth of programming patterns enables insightful analysis of unfamiliar code.
- ChatGPT's code summaries help developers quickly orient themselves in large codebases.
Rather than view ChatGPT as friend or foe, developers should appreciate its complementary coding abilities.
ChatGPT struggles to write flawless code, but excels at summarizing and explaining unfamiliar code. Leverage ChatGPT to eliminate coding drudgery, but rely on human diligence to catch the devil hiding in the AI-generated details. Developers can also leverage ChatGPT's uncanny ability to quickly analyze and explain unfamiliar code to speed up ramping up on new projects.
With the right collaboration, humans and ChatGPT can build better software together.
- Article excerpt generated with the help of Claude-2-1ook
- Initial draft generated with the help of Claude-2-1ook
- Cover images generated with DALL-E-3