Typing Practice for Programmers
speedcoder.net
speedcoder.net
If you find yourself bottlenecked on typing while programming, it's a signal that you should stop what you're doing and write some automation or abstraction. Sometimes you can just structure a program so that it requires less typing --- almost always a good thing.
In the rare cases where you need to be verbose in source code, you can use build-time source code generation, or failing that, an editor snippet library. I like yasnippet for that purpose.
Back at Microsoft, NT kernel style requires a big doc-comment before each major function. (These comments are extremely helpful --- but that's beside the point.) The doc comment's style is a bit more complex than Javadoc; there are multiple sections (e.g., description, arguments) and specific indentation requirements within each section.
I found it very annoying to write and format these comments. Instead of just cursing doc comment writing all day, I took a week and solved the problem. I taught Emacs to highlight and indent these comments. I taught M-q to reformat paragraphs exactly as needed. I added code to automatically generate a skeleton description from the function prototype. And after all that, I was never bothered by the doc comment stuff again.
(Incidentally, in a big monolithic IDE, I think the barrier to this kind of extension would have too high to bother with, and I'd have been left cursing this code.)
I recently got a new mechanical keyboard, which had special "layers" for punctuation. "Common" punctuation like periods and commas are still there, but other punctuation like curly braces, brackets, etc. require new key combos. [1]
I agree with you that a lot of the time programming requires modifying rather than composing, but not all the time. In particular, I blog in Markdown, which requires a certain amount of extra symbols that I wouldn't normally be typing. (Goes hand in hand with the previous point).
[1] You might be wondering, "Why get a new keyboard, if you're typing slower with it?" The new one is easier on my hands, wrists, and fingers, as well as being an actual pleasure to use.
Though I'm not a musician I assume it is similar to playing two different instruments.
Typing speed is never the bottleneck. You could double most developers' typing speed when they code and it'd probably have a negligible impact on their overall productivity.
There are benefits, but do they really outweigh the benefits of those same hours spent studying a data structure or design pattern or trying new tech?
My typing speed and accuracy are both pretty low, when and if I correct that, I hope to have a similar efficiency gain as I did when I adopted clang-format since I won't be falling out of flow for mundane things like typos. Not every moment spent programming is equal, and in my humble opinion it really helps to invest in making your "special moments" more productive.
Personally I choose vim for the exact reason you choose not to: that is I want the ability to edit files in any language on any system I touch with maximum efficiency. This accelerates my ability to try new languages because I don't need to rely on language-specific tooling. Also, vim has more longevity than many design patterns which are susceptible to obsolescence by new language features, and new languages themselves which have a half-life proportional to their age.
I've also been playing around a bit with Atom lately.
That said I agree that "Typing Practice for Programmers" on "SpeedCoder.net" is a little silly. Just learn to use a keyboard (and learn to spell, that helps too).
I shrug and say I don't type enough to mind.
Cognitive overload. Shell commands with their args ... core syntaxes for half a dozen languages ... a couple base class libraries and 0-2 frameworks for each ... plus all your own abstraction/automation stuff on top? Admittedly this all used to be quite a bit simpler back in a sole "Win32-app world": VisualStudio+MSDN=done, no shell to speak of, no web layer / stack, One GUI Way, etc. But 15-20-years-ago ain't coming back for at least another decade.
"Many years ago, I taught training classes for experienced developers who were learning new technologies (like Java). The disparity between the productivity of the students always struck me: some were orders of magnitude more effective. And I don’t mean in the tool they were using: I mean in their general interaction with the computer. I used to make a joke to a few of my colleagues that some of the people in the class weren’t running their computers, they were walking them. Following a logical conclusion, that made me question my own productivity. Am I getting the most efficient use out of the computer I’m running (or walking)?"
[0] https://www.amazon.com/Productive-Programmer-Theory-Practice...
_Use_decl_annotations_
PVOID
TraceStoreAllocateRecordsWithTimestamp(
PTRACE_CONTEXT TraceContext,
PTRACE_STORE TraceStore,
ULONG_PTR NumberOfRecords,
ULONG_PTR RecordSize,
PLARGE_INTEGER TimestampPointer
)
/*++
Routine Description:
This routine allocates records from a trace store. It can be considered
the TraceStore-equivalent of a calloc()-type interface, in that the record
size and number of records are specified rather than the total size.
The memory to satisfy the total size is sourced from the trace store's
active memory map. If sufficient space is available, allocation is simply
a matter of adjusting the relevant pointers and returning.
If the required size can't be satisfied by the remaining memory in the
map, this routine consumes the "next" memory map that has been prepared
asynchronously in a threadpool if one is available. If the prepared map
is not yet available, the allocation fails and NULL is returned.
N.B. This routine should be called indirectly through the TraceStore's
AllocationRoutine function pointer.
The total size that can be allocated is limited to the maximum size of the
memory map. The allocator is geared more toward lots of small allocations
versus larger ones.
Arguments:
TraceContext - Supplies a pointer to a TRACE_CONTEXT structure.
TraceStore - Supplies a pointer to a TRACE_STORE structure that the memory
is to be allocated from.
NumberOfRecords - Supplies the number of records to allocate. The total
size is derived by multiplying RecordSize with NumberOfRecords.
RecordSize - Supplies the size of the record to allocate.
TimestampPointer - Optionally supplies a pointer to a timestamp value to
associate with the allocation. When non-NULL, the 64-bit integer
pointed to by the variable will be written to the allocation timestamp
metadata store. This should be NULL if the trace store is a metadata
store, or if the trace store's traits indicates that it is a linked
store (implying that allocation timestamp information will be provided
elsewhere).
Return Value:
A pointer to the base memory address satisfying the total requested size
if the memory could be obtained successfully, NULL otherwise.
--*/ typedef
_Check_return_
_Success_(return != 0)
PVOID
(ALLOCATE_RECORDS_WITH_TIMESTAMP)(
_In_ PTRACE_CONTEXT TraceContext,
_In_ PTRACE_STORE TraceStore,
_In_ ULONG_PTR NumberOfRecords,
_In_ ULONG_PTR RecordSize,
_In_opt_ PLARGE_INTEGER TimestampPointer
);
typedef ALLOCATE_RECORDS_WITH_TIMESTAMP *PALLOCATE_RECORDS_WITH_TIMESTAMP;
typedef PALLOCATE_RECORDS_WITH_TIMESTAMP \
volatile VPALLOCATE_RECORDS_WITH_TIMESTAMP;
That allows me to include it in a public struct via: typedef struct _TRACE_STORE {
...
VPALLOCATE_RECORDS_WITH_TIMESTAMP AllocateRecordsWithTimestamp;
...
} TRACE_STORE, *PTRACE_STORE;
Basically I've resigned to living with the ugliest possible function typedefs, complete with SAL annotations and whatnot, at the benefit of much cleaner interaction elsewhere in the code, e.g. to call it I'd just do: Foo = (PFOO)TraceStore->AllocateRecordsWithTimestamp(
TraceContext,
TraceStore,
4,
sizeof(*Foo),
&Timestamp
);
_Use_decl_annotations is a life saver.Back when I was in Windows, the system was so robust that if the static analyzer reported on your code, it was your code that had the problem, not the analyzer. It did bounds checking, nullability analysis, and tons of useful stuff. It's fantastic.
The thing about NT-style pointer typedefs is that they discourage const-correctness: it's enough of a pain to make a PFOO. You want a PCFOO too? That said, I'd be more than happy to live with poiner typedefs if I got SAL back.
BTW, I also used a hacked-up cc-mode that understood all the SAL annotations and fontified them using font-lock-keyword-face. It worked great.
I've been contemplating doing a little project that scans all the SDK/DDK headers for SAL annotations in use and making a big cross-reference where you can, like, click on the #defines in <sal.h> and see all the places where there are real examples of it being used.
Some of the complex uses are really hard to grok just from MSDN documentation alone; I've found looking around at the WDK/DDK headers much more useful.
Unrelated question: why'd you leave Microsoft? Were you doing NT kernel development there? Is that what you've done in the past?
Which is quite a good speed for typing, and I have _never_ found that to really help me at all when coding. Usually when coding you are still thinking about what to write and the speed at which you write code is never actually hindered by the typing speed that you have.
There are a few exceptions to this, as I like doing live-coding when giving presentations it does help me write the code faster, but I already know what I am going to write to a large degree and people seem to like the live coding.
But for day-to-day programming, I don't feel like this matters..
It's all preference in the end though!
A more expensive keyboard does not make you type better in my opinion, but it does improve the comfort of typing for a longer time. It also depends on what you are used to.
Another one that is fun is typeracer, it let's you race against others by finishing a typing test as fast as possible. These are fragments from literature that you are typing and thus adds some difficulty as well compared to 10-fast-fingers, as you need to keep in mind punctuation :-)
I wish there was a modern sequel so deeply!
http://store.steampowered.com/app/3450/ https://www.youtube.com/watch?v=4Hr6drzeFgs
Maybe there's some artists/developers here that would want to collaborate to reduce the time burden a bit? :P
Nowadays I load the game up once every few months and I tend to beat X-Treme first shot every time, unless I get unlucky with the toxic sharks. It seems you need around 110-120wpm and decent reaction times to finish it.
I ended up switching to Speedtype on Emacs, which I've found to be far more useful, and very easy to add exercise and drills.
I don't think it's sold anywhere anymore; you should be able to find it on some abandonware website, with a bit of googling.
The menus are in japanese but the text to type is all either in english or at least uses english characters. If you want the proper english version you could try with wine, the tests on winehq seem to report decent compatibility.
Isn't there a saying "weeks of programming can save hours of planning".
Plus a decent IDE will eliminate the need for this type of thing.
And if you don't know all the hot keys they know, then they will probably think you are ignorant. It's unfair, but happens.
“In the early days of Silicon Valley, there was an annual programming contest on Memorial Day. When Donald Knuth (the world’s greatest programmer) entered, they gave him an old batch computer to work on. He had to carry punch cards back and forth. The others, great programmers of the time like Alan Kay, John McCarthy; got the ‘modern’ time-sharing systems.
“Donald Knuth had that old, punch card computer, but finished his program an hour before anyone else, and his algorithm was the fastest executing. They asked him how he did it so well, and he said, `With that kind of computer, you think carefully before typing. You don’t want to make mistakes, like carving in stone.”
Sounds like your old programming friend has learned that lesson.
Pretty sure he meant it the other way. He doesn't want to work with people who would judge him for typing slowly.
In Visual Studio C# land, long identifiers are compensated by really good autocomplete. Most of the characters on screen aren't hand-typed. Frankly, if we're going to have computer-aided-software-engineering then the computer can damn well do the typing too.
On the other hand, if I can make typing less of a strain, my brain will find better things to do, like thinking ahead. I'll try working without looking down for a few weeks to lose my habit of looking at the keyboard. I've had partial success in the past, but with some keys I never gained the motor skill. The most annoying for me are the keys 9 and 0. I always fumble on these when I try to reach them.
Could someone like Steph Curry or Kobe Bryant be an effective basketball player if dribbling the ball took conscious effort? Probably not.
Code is typed. Typing it slowly slows you down. Just like a slow compiler does or a slow IDE or even a slow computer with spotty internet.
Remove bottlenecks until speed of thought and imagination is the bottleneck.
It's possible that typing is a bottleneck, but I bet if you calculated your actual keystrokes, you'd find that it's very few words per minute.
The point is that you shouldn't need to be particularly fast.
There is a different side of this coin, actually. Having a compiler that takes a really long time to compile the code gives a different type of friction than a compiler that works blazing fast. The former makes the programmer want to avoid unnecessary compilation, which works amazingly well for some types of people (I am this type, so I speak from experience).
Though this doesn't work for a text editor, I believe. Editor should be as powerful and fast as possible, and I wouldn't trade my Vim for anything else (maybe Emacs, but I'm too deep to go back and invest in learning it, only to discover that I got no further than with my current setup).
Edit: Spotty internet connection has its good side, too. One learns to read locally stored documentation instead of relying on StackOverflow, which is a big gain in the long run. Similarly slow desktop computer: if the program runs acceptably on my (slow) machine, it will be so much faster on something better. (Though I only write command line tools and network daemons, so I may be biased here.) All boils down to friction profile, which bubbles different things up to the surface.
Slow typing doesn't capture your attention, if you touch-type. Your hands are typing while you go on thinking.
If you get to the point where typing is the bottleneck you are not thinking enough and you should be working on some more difficult problem instead.
Building simple things that solve real problems pays really really well.
VimSpeak: https://www.youtube.com/watch?v=TEBMlXRjhZY
Using Dragon: http://ergoemacs.org/emacs/using_voice_to_code.html
Using Kaldi: https://www.reddit.com/r/speechrecognition/comments/5p3uxb/p...
This toolkit seems to be the most widely used: https://github.com/dictation-toolbox
Better predictive typing would also be useful. Computer languages often greatly narrow what you probably want to type next, because of scope, for example.
You still want predictive typing, for example. If I want to refactor a variable name, indent a region, or create a class from a template, having a smart assistant that could be invoked with voice would be helpful.
As for people being able to type faster than voice recognition, I think voice recognition at 100 won would be fine for most people:
https://www.ncbi.nlm.nih.gov/pubmed/10166812
It certainly would be nice on my iPad.
If you know you want to type "for.bar(new Baz(qux))" and you have to wait for a menu after ".", after "new" and after "Baz(", the line mat take 6 seconds rather than one.
Even if this is not an issue, most IDEs require you to know lots of keyboard shortcuts by muscle memory to be efficient anyway.
I think there's something to the idea that typing faster could help you think faster when it comes to text, but not sure it applies to software development.
I am convinced, although only based on anecdotal evidence, that a lot of the vim/other-editor vs IDE debate is significantly based on how fast you can type.
2. There are a significant number of programming tasks where the typing-to-thought ratio is relatively high. Refactoring is one. Debugging is another. UI code, or anything with a tight feedback loop to something visual, and particularly CSS, is another. In my experience, the faster you can type, the more likely you are to solve these problems by trying things, rather than attempting to guess what is happening in your head. IMO the former is radically more productive.
3. Slower typers tend to look for GUI tools for things that are probably best used from the command line (git is the paradigm example here).
I am passionate enough about this that I have gone as far as organizing typing speed competitions on my team.
Obviously there are exceptions to the rule. I have also worked with excellent programmers who can barely touch type, although they still suffered from some of the above issues.
There are numerous ways to achieve results here, and typing speed falls behind simple automation in many cases.
Getting a habit to automate away repetitive tasks is, in my eyes, the number two skill a programmer should develop and rely on.
(Number one being relentless improvement of skills.)
I might agree for a few cases of repetitive refactoring, but debugging? Definitely not, that's really something where you spend 99% of your time observing, conjecturing, thinking.
Edit: Oh, I had not read the following sentence with care:
> In my experience, the faster you can type, the more likely you are to solve these problems by trying things, rather than attempting to guess what is happening in your head.
That's not debugging. It's just trial and error until the output randomly happens to be the expected thing. That's a terrible way of doing. Gee... if you don't understand what is going on, you cannot consider the bug is fixed. You may even have introduced more problems than you corrected. What's wrong with thinking to sort the problem out once and for all, instead of rushing anywhere like a headless chicken?
But it seems to be the current method, especially in web development. It probably explains a lot of things about the sad state of those applications.
I can't really think about a problem while I'm typing. I can think, or I can type what I've already decided to type. Worse, the longer I'm not thinking about the problem, the more I lose my place. So for me, typing speed is critical. I need to get the part I'm working on out as fast as possible, so I can get back to thinking about the problem.
Now that said, we tend to justify the abilities we have, and discount the abilities we don't. I'm a very fast typist, so I do have some skin in the game to think typing is important. I suspect that people who are not fast typists also have some impetus to think that typing speed is unimportant.
Nonetheless, I do think what I said above is a factor, at least for some people.
I suffer from eyestrain headaches when I stare at a computer screen for a long time. I can type very fast, including all of the numbers and symbols, but if I slow down just a tiny bit, then I can type quite accurately. As a result, I can type long stretches of text or code without looking at the screen for mistakes.
Because of that kind of eyestrain, IDE's don't really help me. Having all of that info on the screen and requiring me to look at it, just makes it more painful sooner. So I code in a plain text editor. Stackoverflow is my IDE. ;-)
If you use a laptop, bring it with you. If you use a desktop with external monitor, measure the distance from your eyes to the screen.
But if you are currently doing something like getting up close to the display and squinting so you can see it better, don't do that. Instead, pick a distance that would be comfortable if you could see clearly at that distance.
For typical laptop use, this is probably around 20". Maybe a couple of inches farther for a desktop monitor, but measure to be sure. If you use both, maybe stick with the laptop distance since you can position your desktop monitor at the same distance.
Don't ask for a "reading" prescription: that is typically around 16", much too close for most computer use.
Once you know the distance, your optometrist can make a prescription adjusted perfectly for that distance, and you can try out the prescription on the spot with their collection of test lenses.
I avoided doing this for years. I thought I just wasn't the kind of person who needed glasses. Turned out I was, and it was such a relief for my eyes when I could see my screen with no strain.
I think the best practice is putting your skill to use. When I play with a new keyboard style (e.g. Dvorak / Programmer's Dvorak) or editor, I give myself a period of acclimation where I _know_ I'll be slower, but the investment in time will potentially pay off dividends once I get used to it. I've gone down a few roads that didn't work out, but also a few that have. When it comes down to plain old typing speed, short burst typing like messaging or command lines have proven to me more productive than typing exercises that mean nothing to me and don't apply to the things I regularly type.
Regardless, the developers here have put together a nice interface and figured out a good way to apply it across multiple languages. If they added a few shortcuts that are commonly present in IDEs to get real completion strokes I think this kind of a tool might get pretty popular.
But despite that I still managed about 60 wpm and 95% accuracy on the snippets I tried.
I have a new split keyboard (Kinesis Advantage) lying around that needs some breaking in, so I'll definitely try this.
But the thing is that typing fast and accurately feels wonderful. Conversely, it's incredibly frustrating to be constrained by a different layout or hardware.
I can be reasonably fast/accurate on my preferred keyboard, but I can't touch type very well and I envy the fluidity when I watch someone do it.
I have tried a few times to learn it, but the process is infuriating. I'd love to find something a bit more tolerable.
I would agree with that to some degree, but I think typing faster can help the thought process, in the sense that you can write down your ideas faster, so that you can free them from your memory and keep moving forward with your thoughts.
Think -> decide that you need to extract a method -> using the keyboard, and your editor, do that -> think again.
The step w/ the keyboard will involve your custom editor environment, and typing. If you get it done, you can shorten the cycle from Think -> Decide -> Act -> Think, and get into a smoother workflow. If your keyboard and tools need your active thought on how to succeed, you get derailed in that Act step, and have to restart your thinking about the real problem.
For example I'm a heavy IDE user and I know exactly what kind of autocompletes it will present me when I write something or what kind of shortcuts I can use, which made this really weird to use.
For example I rarely write 'function', I write 'fun' and press enter because I know 'function' will be the first item in the autocomplete list. When I'm writing a variable for the second time I feel the latency at which the IDE will autocomplete me. If there are more variables with similar names I know which characters to type to make it autocomplete the right one. If I have a variable named weirdNamedLongAssVariableName I will write wNLA and press Enter.
This confused me a lot on a subconscious level when I first tried the examples on the website.
If you think fast typing makes you a better programmer chances are you are a typist and not a programmer.
The problem is that programming overuses a bunch of character sequences that rarely come up in standard english and thus in most of your typing practice, e.g. special characters, and mid-word capitalization. If you want to improve your typing speed for programming faster than you would just writing code normally you have to focus on those sequences.
You would probably want to practice with something that looks more like obfuscated code than beautifully formatted segments. Ideally you could even generate such segments so as to work out your least performant two character sequences while not slowing you down too much by being too random looking. Though even just repeatedly typing "jf" then random characters using the right pinky will be more helpful than this or https://typing.io
A great quote from Lambert:
1. Decide what the program should do. 2. Decide how the program should do it. 3. Implement these decisions in code.
Only the last part is actually coding.
In other words, you are not paid for typing fast. You are paid to type as little as possible to solve problems!
Doing a quick 1 minute typing test comes up at 90 wpm. However programming, with all the mistakes from jumping around I think brings me down a lot more than this. So I found it surprisingly useful.
$ curl -I https://www.speedcoder.net/
curl: (7) Failed to connect to www.speedcoder.net port 443: Connection refused
$ nmap -p 443 www.speedcoder.net
Starting Nmap 7.40 ( https://nmap.org ) at 2017-01-29 17:18 PST
Nmap scan report for www.speedcoder.net (52.36.71.201)
Host is up (0.066s latency).
rDNS record for 52.36.71.201: ec2-52-36-71-201.us-west-2.compute.amazonaws.com
PORT STATE SERVICE
443/tcp closed https
Nmap done: 1 IP address (1 host up) scanned in 0.20 secondsI've been using it for a few months. Around ten minutes per day, five days a week. It has a few small issues, but overall I would definitely recommend both the site and the habit.
It's probably much more boring but quite comprehensive for most things.
The real challenge usually comes when you're touch typing and mixing different hot keys and autocomplete functions (vim plugins in IDEs, for example).
But I'm still not typing with the ten fingers like recommended and this could be of great help to change my way of typing to a more optimized one.
Thanks
(Edit: for spelling, oh, the irony)
If I did lose the use of a hand permanently, I would probably try making a custom map with chording, there's definitely a payoff there.
I'd say it would be worth learning alternative keyboard maps if: A) you work remotely and have a single computer or set of computers you can permanently configure with your preferred layout. B) You're a wordsmith/writer and produce large amounts of textual input as fast as you can type.
I think getting a base touch-typing competency matters far more than optimised layouts, even though the latter can improve comfort/accuracy/speed even further.
In comparison, the text-input methods for smartphones and portable devices need to improve drastically. I find myself getting frustrated whenever I need to input more than a single sentence of text into a smartphone. Using terminal emulators or trying to write technical code/information is a nightmare.