Programming for fun and profit

A blog about software engineering, programming languages and technical tinkering

Sat 19 October 2024

Developer PSA: Learn to type!

Posted by Simon Larsén in Programming   

Humans aren't great at multitasking. You can focus on just about one thing at a time. This doesn't mean that you can only do one thing at a time, because not all things you do require your full attention. For example, try walking around, but before taking each step, really focus on moving that foot forward. Think each step out loud like you haven't walked before. It will probably work out fine: the movement is itself the end goal and holds all of your attention. However, what if you turn that movement into a means to an end, where that end is to do something far more complex, such as playing soccer? You will find that it is near impossible to focus on the individual steps while at the same time achieving that higher goal. But, clearly, people play soccer just fine, because they aren't actually focusing on moving their body. It's so engrained in their muscle memory that it just kind of happens. Like an auto pilot.

Programming is similar. The higher goal is to build a program, while the means to an end is typing on a keyboard. To be able to fully focus on the former, the latter needs to be on auto pilot. Many programmers that I've worked with or trained have not had typing on auto pilot. They frequently need to pause what they're doing to search for the $ symbol for the umpteenth time, or struggle to get a pair of brackets in place. The typing requires some amount of focus, which detracts focus from actually building the program. They are effectively multitasking on something that should be a single activity. This is further exasperated by pair-programming situations, where there's also a level of communication involved.

You need to get the typing on auto pilot. It should just happen. Some will make a counterpoint in saying that the vast majority of time in programming is spent reading code rather than writing code, and so becoming faster at typing doesn't really gain you that many benefits. Except it's not about becoming faster, it's about reducing mental strain while programming, so that counterpoint completely misses the mark. The fact that becoming a more proficient typist also makes you faster is simply a neat side effect. And becoming proficient really isn't very difficult. Let me tell you how I did it.

Learning finger placement

The first thing to learn about typing is the very basics: finger placement. You shouldn't be using your right index finger to do 90% of the typing, and your left pinky shouldn't be completely unutilized. They all need to contribute.

A good place to start is TypingCat. It shows you where to position your fingers while typing each character. I used it frequently when learning the Colemak layout and it worked great for me1. You very likely have some nasty habits to unlearn when it comes to finger placement, so be judicious about using the fingers indicated. Go very slow until you feel like you're starting to utilize all fingers at your disposal.

The TypingCat online typing tutor

Practice this 10-15 minutes every day before you start work, and you should see improvements to your typing fairly quickly. Keep in mind that accuracy and comfort are more important than speed. The end goal is not to become blazingly fast, but to reduce the amount of focus you need to put into the typing.

Speed will however come with time, and combined with accuracy, you have two easy to measure metrics to gauge your improvements. Seeing such concrete improvements can be a fun motivator to keep you practicing. I will however refrain from providing any hard numbers about what speeds you should reach as it's fairly arbitrary. But in terms of accuracy, you should aim for near perfect scores at all times. If you are inaccurate, you are typing too fast and need to slow down.

At this stage, you will also likely be looking at your keyboard quite frequently. However, you should be touch typing comfortably and accurately before you graduate to the next level of practice.

Leveling up

Once you've gotten the basics down and can touch type comfortably, I would suggest proceeding to monkeytype as it's a lot more customizable. Use the basic configuration in the beginning, and practice 10-15 minutes a day until you start to feel comfortable and get near perfect accuracy.

Then start adding in punctuation and numbers2. Finally, you can change the "language" to whatever programming language you're currently using and you'll get words and symbols drafted from it3. This will allow you to practice the special characters that are relevant to your programming language of choice.

You can even go so far as to upload your own custom text (perhaps some code) by clicking custom and then change to the very far right of the toolbar! It's not something I ever did as, at that point, I think it's better to practice typing in your editor instead, but it's an option if you really like monkeytype.

Even though I consider myself a highly proficient typist, I still practice on monkeytype every now and then.

Some words about keyboard layout

While I don't think there's good reason for most people to switch from the standard QWERTY keyboard layout, there is good reason to choose a variant of that layout that's well suited for programming. A layout that I find absolutely atrocious for programming is the Swedish and Finnish multilingual layout (both very similar).

The Finnish multilingual keyboard layout

The Finnish multilingual keyboard layout, sourced from Wikipedia4

The big problem with this layout is that the hard brackets ([]) and curly braces ({}) require some real hand acrobatics, where you hold down alt gr and press one of 7, 8, 9 or 0. I personally started getting some wrist pain from doing that very awkward movement over and over again. I found relief in the US ANSI QWERTY layout, where the same characters are conveniently located just above the home row, and hard brackets don't even require pressing a modifier key.

The US ANSI QWERTY layout

The US ANSI QWERTY layout, sourced from Wikipedia5

It made quite the difference for me. So if you live in a country with a quirky layout, where some frequently used programming characters are in awkward positions, consider adopting a layout that is more appropriate for programming.

Closing words

Trust me when I say that learning to type properly will really benefit you in the long run. I'm not advocating that you practice for hours a day and become the fastest typist in town, but that you become proficient enough with typing that it's not something you have to think about when you're working on complex problems. All your focus should be toward solving the problem at hand, and having to divert attention to the typing is such an unnecessary distraction to have. If I could switch keyboard layout from QWERTY to Colemak within a couple of months and without too much effort spent, you can become proficient with the layout you're already using without too much effort as well.

  1. You do not need to switch to another keyboard layout. The scientific evidence for the superiority of alternate layouts is dubious at best. I did it only because I like to try new things.
  2. There is a toolbar above the typing area where you can adjust such things
  3. The language can be selected just above the typing area. All programming languages are called code <language>, e.g. code javascript.
  4. By KB_Sweden.svg: adapted by StuartBrady from File:KB United Kingdom.svgderivative work: Simo Kaupinmäki (talk) (created in Inkscape; text converted to paths due to use of the uncommon FreeSans font) - KB_Sweden.svg, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=10276924
  5. By No machine-readable author provided. Denelson83 assumed (based on copyright claims). - No machine-readable source provided. Own work assumed (based on copyright claims)., CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=508928