
First, I believe the answer is absolutelynot"just write code for many years." I've interviewed quite a few programmers with 10 years of experience whose code is terrible. Experience is valuable, but experience alone is not enough. Just like playing chess: if you study, review, and constantly challenge yourself, you may become a master. But if you keep playing casually, even after 20 years you'll only be a "lousy player."
I think more useful ways to improve:
1. Learn to read code
Most programmers are only willing to use code they wrote themselves, but experts can usually easily call code written by others. On the surface it seems like a difference in work habits, but in reality it's a difference in ability. Reading code is many times harder than writing code.
I suggest doing code reviews for your teammates during work, and trying to read open source code on GitHub after work.
2. Review
Programmers are generally very busy, with an endless pile of work on their hands. But in some companies, you're just repeatedly doing the same things. Occasionally put down your work, set aside some time to analyze your weaknesses, change bad habits, read new books, or learn new languages.
3. Do personal projects
Programming at work generally only lets you become familiar with a portion of technology, creating gaps in knowledge. It's like practicing shooting by yourself in your backyard for a long time, but only when you play your first real game (and lose badly) do you discover that you also need concepts like passing, defense, and rebounding.
Facebook likes to hire so-called "full stack programmers"—people who can do everything from design to interaction to HTML, CSS, JavaScript, server, SQL, architecture, and data analytics. The best way to become a full stack programmer is to keep working on personal projects.
4. Q&A websites
Asking and answering questions are both great ways to learn. Sometimes writing a good question is harder than writing the code needed to answer it. Writing questions can help you organize your thinking. You can try every week tohttp://stackoverflow.comask a good question or write a good answer.
5. Join a good team
The best way to improve is to work with people who are better than you. Experts like to gather together, so many choose to join excellent early-stage startups. When I was starting up in Silicon Valley and at Innovation Works, I met many amazing people and learned a lot from them.