Wisdom of Programming by Wang Yin | Generated by AI

Home 2026.03

Question: What does the article at https://www.infoq.cn/article/wisdom-of-programming say?

Answer:

The article is titled “编程的智慧” (The Wisdom of Programming), written by Wang Yin (王垠) and published on August 29, 2016 on InfoQ China. It is approximately a 70-minute read (~21,000 Chinese characters). Wang Yin is a well-known and opinionated Chinese programmer/blogger. The article shares his personal philosophy and hard-won lessons on writing high-quality code. Here is a comprehensive summary of all the major topics covered:


1. Repeatedly Refine Your Code

Wang Yin argues that the most effective way to improve programming skill is to repeatedly revise and polish code, not just write more of it. He compares this to a writer who discards more than they publish — great programmers delete more code than they keep. You cannot write perfect code in one shot; insights come gradually over time.


2. Write Elegant Code

Elegant code has two key structural characteristics:


3. Write Modular Code

True modularity is logical, not physical. Splitting code into many files/directories does not make it modular. The real tool for modularity is the function — functions have well-defined inputs (parameters) and outputs (return values). He recommends:


4. Write Readable Code

Truly elegant code barely needs comments. Over-commenting is actually harmful — comments get outdated and clutter the code. Instead, make the code self-explanatory through:

He warns against making code look like natural language (e.g., the Chai.js assertion style), which actually reduces clarity.


5. Write Simple Code

Don’t blindly use every language feature. Stick to a reliable, battle-tested subset. Specific rules:


6. Write Direct/Intuitive Code

Choose the clearer, more explicit approach even if it appears longer. For example, avoid abusing short-circuit evaluation (&&, ||) as a replacement for if statements. This is confusing because logical OR/AND were designed for efficiency, not for control flow readability.

Instead of:

if (action1() || action2() && action3()) { ... }

Write the explicit version:

if (!action1()) {
  if (action2()) {
    action3();
  }
}

7. Write Bulletproof Code

Always have two branches in every if statement to force yourself to think about all cases. Don’t omit the else branch and rely on “fall-through” control flow — this creates spaghetti logic that is hard to verify as correct. Explicitly handle every possible outcome.


8. Correctly Handle Errors


9. Correctly Handle Null Pointers


10. Prevent Over-Engineering

Signs of over-engineering:

His principles:

He distinguishes between “code with no obvious bugs” (complex code + lots of tests) and “obviously bug-free code” (simple, direct code), and advocates for the latter.


References:


Back Donate