Code That Writes Itself

Two years of my programming career were greatly impacted by my mentor. She had an intelligent way of seeing deeper meaning in code. She moved on to an exciting new career opportunity, but her lessons stayed with me. I like to share them with anyone who will listen. Perhaps I hope they'll take the good parts, discard the irrelevant parts, and mix in their own experiences. And hopefully share their learnings with others. The interesting thing about my mentor, is she could "just write code". She was well versed in all the common styles of program design. Object oriented programming, functional programming, data-driven programming, structured programming, event-driven programming, top-down and bottom-up design, et al. (Excuse my long keyword spewing). The point being, she knew the classics.

Planning didn't seem necessary for her. Classes would naturally emerge as she wrote code. Design patterns would naturally spring up. She didn't set out to create so-and-so class, or use so-and-so design pattern. They just happened as she wrote code. She was merely a conduit for reality, and code flowed through her. Code didn't become unnecessarily twisted by how she thought reality ought to look or how the design ought to be, she was simply expressing reality. No more, no less. It was a lovely sight to behold, and reminded me of this passage.

Prince Wang's programmer was coding software. His fingers danced upon the keyboard. The program compiled without and error message, and the program ran like a gentle wind.

"Excellent!" the Prince exclaimed. "Your technique is faultless!"

"Technique?" said the programmer, turning from his terminal, "What I follow is Tao -- beyond all techniques! When I first began to program, I would see before me the whole problem in one mass. After three years, I no longer saw this mass. Instead, I used subroutines. But now I see nothing. My whole being exists in a formless void. My senses are idle. My spirit, free to work without a plan, follows its own instinct. In short, my program writes itself. True, sometimes there are difficult problems. I see them coming, I slow down, I watch silently. Then I change a single line of code and the difficulties vanish like puffs of idle smoke. I then compile the program. I sit still and let the joy of the work fill my being. I close my eyes for a moment and then log off."

Prince Wang said, "Would that all of my programmers were as wise!"

(The Tao of Programming)

Now a days, I've come to see Software Engineering as more of a political sport. As Peopleware, The Mythical Man Month, and many other people have pointed out- technical challenges rarely kill a project. The difficulty arises from the communication and bureaucratic overhead. However, it is disheartening to see code twisted from these complications. Framework X, Y, and Z must be used. Some inhouse tool or library must be mixed in. All mostly due to political reasons. And of course, so-and-so process must be followed. As we move farther and farther away from expressing reality purely, we move slower and slower. Reality is subjective and there's many good ways to skin a cat, but the above isn't code that writes itself; it's coding by committee.

I would love to see more code that writes itself and less code written by committee.¹

¹ The Design of Design