Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save brianspiering/b78d0d86220523e52fbd7d8203cd869a to your computer and use it in GitHub Desktop.
Save brianspiering/b78d0d86220523e52fbd7d8203cd869a to your computer and use it in GitHub Desktop.

Techniques to improve as a programmer

Do not be the person who has practiced 10,000 things once, but be the person who has practiced one thing 10,000 times.
— Intentionally misquoting Bruce Lee

  1. Write a lot of code. Physically type code and run it (if either part is missing, it is not quality code practice).
  2. Think of coding practice as a portfolio. It should be a mix:
    • 40-60% Easy-for-you fundamentals. Practicing Pythonic idioms to solve common atomic problems. This develops fluency to solve novel challenges and build up to more advanced coding.
    • 20-30% Difficult-but-possible problems. LeetCode and similar is good for this level.
    • 5-10% Impossible-for-you-right-now code. This could be advanced concepts in Python, learning another programming language, or fundamental Computer Science concepts.
  3. Brian's Method
    1. Try a problem without any resources.
    2. If stuck, just look at documentation to get unstuck.
    3. Look-up a collection of great solutions (Stack Overflow is good for this - books are better).
    4. Reflect, synthesis, and refactor into a solution that is uniquely your own.
    5. Make a flashcard and drill over time until over-learned.
  4. Cover Method
    1. Watch great programmer actually program (e.g., Joel Grus live-coding playlists).
    2. Type along with them.
    3. Later apply Brian's Method to the same problem.

Advice from Andrew Ng

Dear friends,

I’d like to share a programming tip that I’ve used for years. A large part of programming involves googling for code snippets you need on Stack Overflow and other websites. (Shh. Don’t tell the nondevelopers. 🤫) But that’s not enough if your goal is to maximize your own learning. When the relevant code snippet is just several lines, rather than copy-pasting them from a web page into my code, I usually retype them myself. The physical practice helps train my brain to internalize the concept and syntax.

To gain skill as a programmer, you need to internalize both the concepts and the syntax. When I’m trying to help friends get started on coding, I ask them to type print(“Hello World”). By typing it out, you can be sure you know the command’s syntax, such as whether it requires parentheses ( ), square brackets [ ], and so on.

You can’t learn to ride a bicycle by reading a book on the theory of bicycling. You have to do it yourself! Coding is more similar to this type of physical skill than most people realize, and practice makes perfect.

When you’re trying to master a programming technique, consider these practices:

  • Read a line of code, then type it out yourself. (Bonus points for doing it without looking at the reference code while typing.)
  • Learn about an algorithm, then try to implement it yourself.
  • Read a research paper and try to replicate the published result.
  • Learn a piece of math or a theorem and try to derive it yourself starting with a blank piece of paper.

Many creative artists start by replicating the works of artists who came before; so, too, in coding. By replicating examples of good programming (being mindful of copyright and attribution, of course), your brain masters the ability to create them. This frees you to focus on higher-level tasks so you can rearrange what you’ve learned into new, original works.

So next time you’re tempted to copy and paste a few lines of code, I hope you’ll start typing instead.

Keep learning!

Andrew Ng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment