Nathan Wailes - Blog - GitHub - LinkedIn - Patreon - Reddit - Stack Overflow - Twitter - YouTube
Becoming a better / more-efficient / faster programmer (Programming)
Table of contents
Child pages
Related pages
- Being Productive / Time Management / Fighting Procrastination / Focusing
- Games related to programming ← The idea here is to use these games to figure out how to program more quickly. There's a "lessons learned" section, and the TIS-100 entry has a bunch of useful things. I should maybe move that section in here.
Journal
- 2017.02.15 - I noticed yesterday that I started to think about web programming differently: I became totally OK with developing a page without doing any styling at all, so that I just had text and buttons in the top-left, one on top of the other. So it may be good to get into the habit of developing pages like that, and then later going in and getting the styling to look right.
Techniques
Rest / breaks
- Get enough sleep.
- This is just like when I was taking the LSAT.
- Mike Krieger talks about this.
- Take naps if you're feeling tired.
- Bryton also brought this up; he doesn't try to work when he's tired.
- If you slept well, try to start coding as soon as you wake up in the morning, before you do anything else.
- Reason: I find that I'm "freshest" as soon as I wake up, and that if I delay in starting to code, I can end up procrastinating for hours.
- Do something to help you relax / unwind. (Source)
- Watch TV
- Play a videogame
- Do some exercise
- Go for a walk
- Hang out with people
- Read
- Cook a meal
- Get away from the computer
- Meditate
- Misc articles
Environment
- I've found my favorite work environment when doing work that requires concentration is a library-style environment: open-office (so I can see other people if I look around), but with noise rules (so it's quiet, like a library), and with me facing a wall (so I don't have things moving around in my field-of-view when I'm working that distract me). My next-favorite environment is an office with a door that's away from any loud noises, with me facing away from the door if it has a glass facing, so I don't get distracted by movement outside. Working remotely allows me to
Journal
- 2017.12ish - I was struck today at how much easier it seemed to feel ready to work when it was quiet and I had a desk.
- I need a quiet, preferably dark place with a desk and chair.
- I really need to be left alone for eight hours a day.
Equipment
Consider having your monitors oriented vertically.
- Rec'd by Andy.
Consider using multiple monitors.
- Andy used two.
If you only have one monitor (eg a laptop screen), use multiple "desktops".
- Example: At the moment I use three desktops: the first contains all and only windows that are for whatever I'm working on now, the second desktop contains time/task-tracking windows (my Google calendar and trello on the left, and notepad on the right), and my third desktop contains windows related to any background music I'm playing (including a page on my wiki where I can note good songs I hear).
Consider using multiple browsers simultaneously, each dedicated to a single use-case
Consider dedicating a single browser to play YouTube music videos so your 'main' browser doesn't slow down
2023.11.03 - I've noticed that Chrome on my laptop seems to slow to a crawl and needs to be restarted after I've been playing music via YouTube for a while (like a few hours). I was actually looking at buying a new laptop and even switching to a MacBook because I found my slow browsing to be so annoying. I noticed that it was far more pleasant to work on my desktop gaming PC because everything would load so much faster (especially new webpages) and wanted a similar experience on my laptop.
- So the idea is that if playing YouTube uses up so much memory in this browser that it needs to be restarted, I won't lose my other browsers that I'm using to do research or work on apps.
Consider dedicating a single browser to running your apps locally
This is the browser which needs to have devtool browser extensions installed: Vue devtools, Angular devtools, etc. As I write this, I'm thinking I'm going to use Chrome for this.
Consider dedicating a single browser to doing research (using ChatGPT, searching Google)
The idea here is that this browser shouldn't need your devtools extensions. I suspect (but I'm not sure) that using as few extensions as possible may speed up the loading speed of new webpages. As I write this, I think I'm going to try using Brave for this since I read online that it's supposed to be very fast at loading new webpages.
- I'm not sure yet if this browser should also be used for Jira.
Get psyched up / motivated / set the mood
- One thing I've noticed that can help me get motivated is to read my "Praise for my work" page. It reminds me that I'm capable of doing great work.
- Videos that I've watched that have gotten me psyched up to start coding
- Put on some good music
- Thoughts
- Music can be distracting, so if you're in a quiet environment and have been working in quiet, but are also struggling with daydreaming (wandering thoughts), you may want to try putting on music (to stop the wandering thoughts) but at a very low volume (so that the music doesn't itself distract you).
- Keep in mind that one option is to have it playing, but softly. The volume at which you play the music should probably vary depending on the situation.
- Notch
- Search Google for 'site:https://twitter.com/notch/status/ music'
- He apparently has a soundcloud account where he (at least) posts clips of songs he's created, but a quick search on Google didn't lead me to it.
- Songs I know for sure he was listening to while coding:
- Boys Noize - Kontact Me - "This is the music I will listen to all day on repeat while I code"
- He doesn't explicitly say he was working while listening to these:
- µ-Ziq - Grape Nut Beats Pt.1 - "Too lazy to change playlist, but music not to listen to during a headache", "Oh wow, I totally forgot this wonderful piece of music exists"
- Kid606 - Ecstasy Motherfucker - "Too lazy to change playlist, but music not to listen to during a headache"
- Ventolin (the song by Aphex Twin?) - "Too lazy to change playlist, but music not to listen to during a headache"
- Autechre - Second Bad Vilbel - "Too lazy to change playlist, but music not to listen to during a headache"
- A custom song he created named 'calm4.ogg' - "[the song] wasn't made for the music [for Minecraft], it was just a test song I put in there to try the mp3 loading."
- DOG BLOOD - Next Order - "dog blood is amazing beyond words. The combination of Alex's old school and Sonny's crowd is incredible."
- IDM (Intelligent Dance Music?) - "I got into electronic music via IDM."
- Dense & Pika (artist) - "I'm a full-on Dense & Pika fanboy now. This is almost as intense as my Knife Party era."
- NW: I liked this. It's somewhat minimalisic, industrial(?) electronic music. I liked this more than Knife Party.
- Knife Party (artist) - "I'm a full-on Dense & Pika fanboy now. This is almost as intense as my Knife Party era."
- NW: I thought this was alright. I was able to listen to it as a softer volume. It's a more-jarring type of electronic music than I normally like.
- Boards of Canada - Music Has the Right to Children (album) - "Music Has the Right to Children is a masterpiece that seems to get better for each passing year."
- NW: Yep this is a good one. Chill electronic music, sounds good when played softly.
- Artists that were recommended to him:
- Pig & Dan, Nicole Moudaber, Kaiserdisco, Stephan Bodzin, Sasha Carassi, Paul Kalkbrenner, GoldFFinch, Eekkoo - "Into techno? Check out [...]"
- di.fm/electro
- Source: https://news.ycombinator.com/item?id=3811332 "He's listening to http://www.di.fm/, specifically the Electro House stream."
- Someone in the HN thread rec's the "A State of Trance" sets that you can d/l here (the red links): http://www.teamliquid.net/forum/general/316887-music-a-state-of-trance-550
- Source: https://news.ycombinator.com/item?id=3811332 "He's listening to http://www.di.fm/, specifically the Electro House stream."
- Pieter Levels
- YouTube - Panda Mix Show ← This is Pieter's previous project.
- YouTube - hurfyd - Pieter sub'd to this channel
- PlayMyInbox.com - Demo ← This is a list of songs from Pieter's inbox (Source)
- rinse.fm ← He posted two songs from this radio show on his YouTube, one was really good. It seems to play both rap and electronic music.
- I forget which coder I saw post this on his twitter: https://soundcloud.com/benzi
- Zach Adams (random coder) - https://zach-adams.com/2014/05/music-to-listen-to-while-coding/
- Thoughts
While coding
Starting
- It's normal to feel overwhelmed by the size of the task in front of you
- "98% of dev is just pretending you're not overwhelmed with the massive amount of work left to do"
- Before starting on a task, set a limit on how much time you're willing to allocate to it
- Examples
- I wanted my flask app to autoreload when I made changes, but I didn't want to waste hours on it, so next to the task I wrote "10" (meaning "spend 10 minutes on this"), and then I wrote the actual time range I should use (ie "10:13 - 10:23"). I ended up finishing the task in under a minute, which was a pleasant surprise, but I think knowing about the limit I'd placed helped me to not waste any time.
- In one of the links below a guy describes how Notch cut a feature after spending 40 minutes on it because he realized it could end up taking up a lot more time. So he may not have thought of a time limit before he started on it, but he had some sense of the big picture.
- Examples
- Don't overthink it!
Communication-related
- Communicate solely through chat, even with people you're sitting right next to
- Examples
- Facebook
- Get the quote from 'The Facebook Effect' where the guy says the programmers were all around a desk, talking to each other through chat.
- John Collison
- https://web.archive.org/web/20080905124255/http://transatlanticitinerant.wordpress.com/2007/07/13/slightly-more-substantial-post/
- 1am: The four of us are seated around our 2 metre square desk. None of us can see each other, because there’s monitors in the way. None of us can talk to each other because we all have noise-isolating earphones in. All four of us are on the #auctomatic channel on irc.freenode.net, discussing the site. Someone says “so, what’re we going to do about dinner?” and the discussion goes there.
- Facebook
- Examples
Coding-related
- Consider using keyboard shortcuts instead of the mouse
- Tools
- Vimium
- Related page: Vimium
- Adherents
- Dan Luu - Is the keyboard faster than the mouse?
- Cody does this.
- Andy also does this.
- Yang also does this.
- Training
- Train on a per-software basis.
- Keyboard navigation:
- Train people to find particular important keys (alt / ctrl / Windows)
- To find 'alt', I first find the space bar with my thumb and then drag it to the next key to the left.
- Train people to find particular important keys (alt / ctrl / Windows)
- Chrome:
- Train people to switch between tabs quickly, in both directions.
- Tools
Dealing with being stuck
- Debug efficiently.
- When asking for help, consider phrasing your question in this form: "I wanted to do X, so I wrote <some-code>. I expected to see Y when I ran this code, but instead I saw Z. What am I missing?" (Source)
1. What makes you say your code isn't working?
2. What did you expect your code to do and why?
3. What did your code do instead and how do you know?
- Listing And Testing (Hidden) Assumptions - most bugs are caused by the assumptions we didn't realize we were making, ranging from the forehead-slapping (e.g., "My code is free of typos") to the more fundamental (e.g., "I understand how this-or-that component works and I'm using it correctly.")
- Create a minimal version of your code that reproduces the issue.
- Step-by-step process:
- Commit all of your "real" code (stuff you want to keep) so that you can easily delete all of the changes you end up making and go back to this saved state.
- ...
- Examples
- https://stackoverflow.com/a/40047125/4115031
- "while I was removing boilerplate to get a minimal working Flask project to upload it to a git repository to link it here, I found the cause."
- https://stackoverflow.com/a/40047125/4115031
- Step-by-step process:
- When asking for help, consider phrasing your question in this form: "I wanted to do X, so I wrote <some-code>. I expected to see Y when I ran this code, but instead I saw Z. What am I missing?" (Source)
- Figure out what's making you feel confused, and attack that issue
- Examples
- 2015.12.06 - I was procrastinating for hours, staring at my screen, and then eventually I realized that what was holding me back was that I didn't have a clear folder structure for organizing my code, and so I wasn't sure where I should be putting my code. After a few minutes clearing up what the folder structure should be I was back in business.
- Examples
- Have a friend you can ask for help.
- Mark Zuckerberg
- Get the quote where he says he learned most of what he knows from his friends rather than from books.
- TypicalProgrammer
- He said something to me like "I always had someone more experienced to pull me out of the weeds."
John Collison (of Stripe)
- https://web.archive.org/web/20090819010430/http://transatlanticitinerant.wordpress.com/2007/07/
Yesterday I had a problem with Seaside linking to a stylesheet multiple times (don’t ask). After 15 minutes I gave up and decided to ask Patrick. He wasn’t on MSN and I was about to email him asking him to when I realised I prod him onto MSN a lot – the time I spend sending him emails to go on is an inefficiency. I decided to write a script to be able to poke members of the Auctomatic team from the command line. After 15 minutes of debugging (I could have sworn it was chomp that takes off trailing new newlines. Maybe I was just hungry) it was finally working and at my shell I simply had to enter:
$ poke p
Of course, emailing him would have just taken 10 seconds more so I’ll have to do a lot of poking before I can chalk this up as a saving
- https://web.archive.org/web/20090819010430/http://transatlanticitinerant.wordpress.com/2007/07/
- Mark Zuckerberg
Don't waste time stressing about how little time you have left.
- This is surprisingly similar to when I was studying for the LSAT. I'm noticing the same feeling of "stay concentrated and try not to panic" that I had when I was doing LSAT sections.
Food / drink / drugs
- Eat high-quality food.
- This is just like when I was taking the LSAT: Protein (fish / chicken), carbs (broccoli / peas), and fat (cheese / almonds)
- Alcohol
- Mark Zuckerberg
- “9:48pm. I’m a little intoxicated, not gonna lie. (...) It’s taking a few tries to compile the script…another Beck’s is in order.“ (Source)
- http://www.nathanwailes.com/blog/alcohol-may-reduce-anxiety-while-programming/
- Another article mentions that he'd had a fight earlier that day with his girlfriend.
- “9:48pm. I’m a little intoxicated, not gonna lie. (...) It’s taking a few tries to compile the script…another Beck’s is in order.“ (Source)
- Yang drinks sometimes while he's coding.
- Mark Zuckerberg
- Caffeine
- Chung is a big fan of espresso. I think Yang also drinks it.
- John Collison (of Stripe)
- "My attack on bugs and lameness in the app was fuelled by adrenaline and ridiculously strong coffee, tea and sugared Red Bull." (Source)
Lessons learned
USACO Puzzles
- If you're having trouble with a certain task, see if you can break it into smaller pieces. This is one of the most useful things I've gotten practice with from these puzzles. It's kind of cliche advice, but if you're staring at something for half an hour and can't figure out how to get it working, you NEED to have the thought/motivation to try hard to break it up.
- If you're having trouble with a certain task, see if you can describe / write out how you would do it in the real world, without a computer. This helped when I was trying to write a function that would convert from base 10 to another base. If you get too bogged down in how to execute things in the programming language it can make it harder to brainstorm.
- Be OK with having your first version be ugly / sloppy. You can always go back over and smooth things over later. Trying to make everything perfect the first time around often makes it take LONGER to get to a great version.
- Don't get too sucked into a particular way of doing things if it's hard to execute. Be willing to look for easier methods. On one puzzle I had the idea that I could use a fancy way of doing things, but it was so hard to figure out how to execute my idea that I burnt out and stopped working on the problems for a month or two.
- It's extremely important to have a compiler set up so that you can quickly compile your code and see what happens. You should NOT try to figure out how to create the program without ever running your code. This held me up for literally 10 months with the USACO puzzles: I was having trouble learning all the C / C++ code necessary to do certain things so that I could create an entire program and hand it to the USACO website to compile, when I should have just been typing stuff up, handing it to my own compiler, and seeing what happened. I should have been starting with the most simple part of the puzzle and incrementally getting more complicated, just like that Stanford professor recommended in his Python class at Google.
Articles
- 2016.08.16 - Gamasutra - Programming principles from the early days of id Software
- 2011.03.19 - Robin Wilson - Want to write some code? Get away from your computer!
- 2011.11.21 - YouTube - Coding with Notch (from Minecraft: The Story of Mojang)
- 2014.08.07 - Medium - Johnny Lin - How I Got from Idea to Product Hunt in 4 Hours
Crap, already behind schedule. It was time to pull out the big guns. It was then that I applied the most valuable skill I learned from my 4 year degree in Computer Science and 2 years working at a big tech company: looking things up on Google.
People
- Jesse Farmer
Quora - How do programmers code quickly?
They know how to use their keyboards to do work. Keyboards are way faster than mice once you know how to use them. They're also more amenable to muscle memory. Are you clicking around to open new files? When I'm coding I barely touch my mouse.
They are good typists. I probably type around 80 WPM on average and 100-120 WPM if I'm focusing on my typing, for example. Go practice! I like http://play.typeracer.com/ and https://typing.io/.
They know how to use their tools, especially on the command-line. Ctrl+R for reverse search, Ctrl+A/E for beginning/end of lines, <Tab> for autocompleting filenames, etc. These become muscle memory after a point.
They are very good at debugging and are likely to isolate, identify, and resolve a bug 100x quicker than a beginner. This isn't just because they "know more." Oftentimes they know just as much as you, but have a more disciplined approach to finding the source of unexpected problems.
They have a better sense of where to look for information and aren't afraid to navigate through manpages or even source code to understand how some other system is behaving. If I'm having trouble with a poorly-documented Ruby gem, for example, I'll often look at the gem's source code to see if I can make sense of what's going wrong. I'd say 90% of the time this is quicker than Google.
Regarding debugging, I wrote a blog post (Teaching Novice Programmers How to Debug Their Code) that outlines how to teach people to be better debuggers.
- Notch
- 2011.09.13 - Gun.io - What I learned from watching Notch code
- Notch tests continuously, and he tests completely thoroughly, playing through the entire game every time he makes a change.
- When building the engine, Notch wrote a function which would continuously pan the camera around and clip through the walls and keep the view on top, so he could make changes to the code and see the effects they made in real time. I’m used to testing by writing a function, building it, installing it on the device I’m testing on, and then seeing the result, which can take up to a minute at a time, so it’s easy to see how HotSwapping could save a lot of development time.
- Notch's testing is mind-bogglingly thorough. 'Prelude of the Chambered' takes about 10-15 minutes to play through if you know what you're doing, and Notch played through the whole game every time he made a change. (...) the benefits in terms of user experience are obvious: More play-throughs mean more chances to spot bugs and inconsistencies.
- 2011.09.15 - MrSpeaker.net - Code like you're Notch
- Holy crap that guy knows his stuff.
- For a time-based comp it's probably worth scaling back your ideas until you know exactly how you're going to do it.
- The internet is, and distractions are, stupid. (...) Notch...worked eerily distraction-free. He went to Twitter only once (and that was to post an update on his progress). He played Doom for 15 minutes while he ate lunch. He went to sleep for 8 hours on Saturday night. I think he snuck in a toilet break at one stage - I'm not sure. Apart from that, he coded and he drew and he play-tested and THAT'S ALL.
- Streamline your process. (...) I saw file dialogs maybe, a dozen times throughout the weekend. There was no export phase, no "are your sure?", no "save as interlaced?" - just one keyboard shortcut and the changes were ready to be loaded into the game. What I learnt: Ok, your tools aren't important - but they have to let you work extremely fast. Don't do something with 2 clicks that could be done with 1. Favour simplicity.
- Have a plan. From the start his pacing was perfect: never rushing but never wasting time. When he finished one aspect of the game he moved straight on to the next. By the time the deadline arrived he was casually adding minor level tweaks. (...) What I learnt: Timing is everything. Spending time on fancy effects like dynamic lighting reduces time for the truly important aspects of play testing and level design. If you're ahead of schedule you can add some bells and whistles, but the clock is always ticking.
- 2011.09.13 - Gun.io - What I learned from watching Notch code
- Tom Francis
- Tom Francis playing Human Resource Machine
- http://www.pentadact.com/2011-03-12-analysing-happiness/
Do what you want to be in the mood to do. You can also get stuff done that you don’t feel like doing, just by starting to do it. Your brain only resists up until the point you actually start the job, at which point it starts to focus on doing it. You do what you want to be in the mood to do, and soon you’re in the mood to do it. It sounds ridiculous, but it’s the single most useful piece of information I’ve discovered about the way my brain works in 29 years of having one.
Books
- The Effective Engineer
- He doesn't use the term in the title, but by "effective" he really means "10x".
- TODO: Summarize this.
- Nightowls: Why programmers work at night
Misc articles to organize
- https://sites.google.com/site/steveyegge2/practicing-programming
- https://danluu.com/programming-blogs/
- https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/
- https://github.com/tarmstrong/longcv/blob/master/bio.md
- http://blog.nullspace.io/ticket-to-ride.html
- https://danluu.com/learning-to-program/
- 2017.01.21 - antirez.com - The mythical 10x programmer
- 2017.08.31 - malisper.me - How to Improve Your Productivity as a Working Programmer
- rec'd by Dan Luu
- Summary
- Eliminating Distractions
- Getting into the Habit of Getting into Flow
- Scheduling My Day Around When I’m Most Productive
- Watching Myself Code
- Tracking My Progress and Implementing Changes
- Being Patient
- 2017.11.03 - Twitter - Dan Luu - Is there other writing like this on improving programming productivity? Rigorous measurements, not just handwaving.
- someone links a picture of a Knuth paper where he says he logs every error that forces him to debug things:
- someone else links this: http://humane-assessment.com/