The Keyboard Shall Set You Free

Jonathan Turner has released Keyboard Sith, a tool that disables your mouse and forces you to use the keyboard. Why would you want to do this? When I have taught courses on test-driven development and refactoring, I have noticed that the programmers that avoided the mouse and code completion facilities from their IDE (e.g. IntelliSense) always finished the exercise first. These programmers simply learned the keyboard shortcuts of their IDE to efficiently navigate around and simply learned to type their code faster than any browsing tool could complete it.

The Problem With the Mouse

Using the mouse means disengaging the language part of your brain and engaging the spatial motor skills part of your brain. It is a “brain interrupt”. If you’re right handed and keep the mouse on the right, there is this big numeric keypad on most keyboards over which your hand must travel to get to the mouse. Then you have to move the mouse to visually locate the cursor (it’s quicker to locate a moving cursor than it is to locate a still cursor). Then you have to navigate through menus and menu items or click somewhere in your editor and drag-select a chunk of text to highlight it. This all takes time and shifts your brain out of thinking about the text that represents your program.

The Problem With Code Completion

Most code completion features are basically training wheels for programmers. My #1 rule for a good “assisting” tool like code completion is that it should never take code that I type correctly and “complete” it into incorrect code. Who cares if I’m calling a method that doesn’t exist yet? It shouldn’t complete it to the name of some other method just because it doesn’t know about the method I’m going to create 5 seconds in the future. Sometimes it’s even little things that just insert things that you have to delete like “helping tools” that insert a close brace when I type an open brace. Most of the time when I’m doing this, it’s not because I’m inserting a new block, it’s because I’m enclosing a single statement block in a braced block or it’s because I’m restructuring some code. It’s just a nuiscance to assume all the time that I’m only adding code and therefore the closing brace is helpful. Most of the time we aren’t writing new code, but modifiying existing code.

Is code completion universally evil? No, in fact it can be very useful. But just like Hollywood, it should be “Don’t Call Us, We’ll Call You” — code completion, symbol completion, insertion of boiler-plate templates, etc., should be done on demand, not by default. Seriously, I can’t be the only person who has good enough typing skills that I don’t need to watch my insertion point, but instead my visual focus is on the few lines of code surrounding my insertion point and the constant popping up of “suggestions” by code completion tools is simply obscuring the code that I’m trying to read while I type. Dude, if I want help, I’ll ask for it. STOP ASKING ME IF I WANT ANY TOAST!

So when is code completion useful? For me, it has to have these fundamental qualities: it must be non-corrupting, it must be accurate, it must be responsive and it must be able to be made passive.

  • Non-corrupting: No code completion assistance should ever take a correctly typed sequence of source code characters and turn them into something else that is incorrect. This one is in the same category as those “spell checkers” that keep correcting your technology specific terms into generic terms and thereby change the meaning of the text. Voice recognition and spelling correction on phones often suffers from this and we see people sending us strange messages as a result all the time. Most of the time, had they just left in the improperly spelled word in the text, we would have gotten a clearer picture I bet.
  • Accurate: Who cares how quick the code completion is if it gives incorrect answers? .NET languages and Java have the facility of reflection that can increase the accuracy of these tools tremendously. For other languages, we end up with ad-hoc parsers and analyzers based on pattern matching that fail to understand the difference between Foo::data and Bar::data because they’re both named data.
  • Responsive: The whole point of this was to make me faster while coding, right? So if requesting code completion causes a busy cursor to appear, then it has failed completely. I’m now mentally slapped in the face with a big cream pie while I wait for the “assistance” to materialize. I might as well just learn how to type faster instead.
  • Passive: Constantly asking me if I want some toast and popping up a scrolling listbox filled with suggestions is annoying. It’s back-seat driving. I’m the developer and I know what I’m doing, so just leave me alone unless I ask for directions. Training wheels are useful when I’m learning to ride a bike. Once I’ve learned how to ride a bike, those training wheels just prevent me from taking turns at high speed because I can’t lean the bike over. When I’m in a high-speed train of thought and just need to have my fingers keep pace with my mind, the last thing I want is a bunch of windows popping up in my face. Get out of the way and let me code. If I want help, I’ll ask for it.

One of the main languages I use is C++ and unfortunately Visual Studio’s IntelliSense fails on all counts, even the improved versions in more recent editions of Visual Studio and even with add-ons like Visual AssistX. I can simply type code faster than these things can help me, so I turn off all their visually distracting suggestions. Unfortunately, the default configuration is to be a nuiscance under the guise of “helping” people. Honestly, they need to reconsider their position. People don’t stay at the beginner level of programmer for very long and gearing everything to the beginner sets up bad habits.

Is This News?

Not really. Other people have pointed this out before:

However, I still see people coding only at the speed of their IntelliSense, hobbling along on their crutches. If they put those crutches down and started walking and exercising their leg muscles, they’d soon learn that they could be jogging or running instead of hobbling.

You have nothing to lose but your chains! Set yourself free!

One Response to “The Keyboard Shall Set You Free”

  1. aditya menon Says:

    Agree completely. I use Sublime Text for my web development work. It does a good job of staying out of the way, but even this level of completion can be a hindrance and annoyance many times.

    Like


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: