News for hackers. Stuff that matters.
Re:Typing Practice for Programmers by quotemstr on Sunday January 29, 2017 @05:23PM (#13517132)
Programming is a unique field: if you're doing it right, it should never be dull. Frustrating? Draining? Rage-inducing? Sometimes. But not mind-numbing. Why? Because we can build our own tools. If we find ourselves doing repetitive work, we can build a tool to automate that work. This automation is itself likely at least somewhat interesting. What isn't repetitive and that can't be automated should be interesting as well.

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.)

Re:Typing Practice for Programmers by tacon on Monday January 30, 2017 @12:05AM (#13518828)
From the preface of The Productive Programmer[0] by Neal Ford:

"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...

Re:Typing Practice for Programmers by dxhdr on Sunday January 29, 2017 @07:22PM (#13517709)
Being able to type quickly and accurately is enjoyable. It lets my brain stay focused on what I'm writing rather than how I'm writing it. No context switches necessary, no mistake every 10th key; typing should be fluid and easy. I highly recommend improving your keyboard skills if you struggle with touch typing.

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).

Re:Typing Practice for Programmers by jacoblambda on Sunday January 29, 2017 @10:52PM (#13518500)
Honestly I believe that a programming specific typing practice program such as this one does serve a purpose as even though I can type well in a normal setting, I am much slower with many of the special characters as they just aren't used as much outside of the programming environment.
Re:Typing Practice for Programmers by manojlds on Monday January 30, 2017 @03:58AM (#13519542)
Actually, this doesn't seem helpful at all. Rarely am I typing the entire program without any autocompletion and intellisense based assists.
Re:Typing Practice for Programmers by simias on Monday January 30, 2017 @05:06AM (#13519830)
Those generally complete identifiers, not the various symbols like "->" "*" "&" "{" etc... So I think the parent's point is still valid. If anything autocompletion increases the symbol-to-letter typing ratio.
Re:Typing Practice for Programmers by manojlds on Monday January 30, 2017 @10:04AM (#13521692)
I use snippets, expanders, zen mode etc. Lots of people do too. Typing has never been the issue for programming really.
Re:Typing Practice for Programmers by chjohasbrouck on Sunday January 29, 2017 @06:41PM (#13517547)
This is why no matter how much sense it makes to use something like vim or emacs as your primary development editor, I could never justify the amount of time it would take me to actually be totally comfortable and start seeing benefits (beyond just using it for small quick edits at the command line).

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?

Re:Typing Practice for Programmers by dasil003 on Sunday January 29, 2017 @07:36PM (#13517778)
If you don't think vim or emacs is worth it then fine, but you're setting up a strange false equivalency between learning new concepts and learning new tools. The fact is, you can't program without tools, and practice will make you better with the ones you choose. If you only ever learn new patterns and algorithms and just type your code into Notepad then you will be handicapped as a working developer.

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.

Re:Typing Practice for Programmers by dman on Sunday January 29, 2017 @06:53PM (#13517602)
I agree this things like typing speed and a good editor should not matter but in reality I think it does. I think the state of programming flow is very hard to get into, and very easy to fall out of. In fact the easiest way I find myself getting out of state of flow is if I find myself doing something mundane. Anything that allows you to do more while you are in the flow, or lessens the chance of breaking out of it is valuable in my opinion. Will share an anecdote here - before I started using clang-format for formatting my code, I expected that adopting it would merely save me the time I spent formatting. On the contrary what happened was that it has almost completely changed the way I write code when I am in flow since I now no longer have to worry about having to make it look good. In retrospect I now find that in the past I would often spend crucial parts of my programming flow doing mechanical indentation of code and doing such a mechanical activity was often a ripe target for me to fall out of flow.

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.

Re:Typing Practice for Programmers by davvolun on Tuesday January 31, 2017 @02:54PM (#13534572)
Wha, what? vim and emacs aren't about typing speed, they're about action speed. 99% of the reason I love using vim is because I can do exactly what I can do with a combination of mouse and keyboard actions, but without leaving the keyboard. And many IDEs have, for example, vim extensions so you can get the best of vim without manually building up your vim environment and extensions (although learning e.g. PyCharm is no different than learning and building my own vim env -- I use both).
Re:Typing Practice for Programmers by p10_user on Sunday January 29, 2017 @09:08PM (#13518156)
It doesn't take much time to be equally comfortable with vim/emacs as you are with your normal editor. Anything you learn after that is a bonus. It's hard to say how much faster I am using vim than a normal editor, but I'm a hell of a lot more efficient and comfortable doing it.
Re:Typing Practice for Programmers by wallace_f on Sunday January 29, 2017 @11:52PM (#13518780)
I'm just curious what code editor do you use right now?
Re:Typing Practice for Programmers by _gjav on Monday January 30, 2017 @03:01PM (#13524490)
I use the JetBrains family of IDEs (IntelliJ IDEA, PyCharm, RubyMine, PhpStorm, WebStorm) and I'm really happy with them.

I've also been playing around a bit with Atom lately.

Re:Typing Practice for Programmers by z1mm32m4n on Sunday January 29, 2017 @05:43PM (#13517229)
I see where you're coming from, but this tool is still valuable in a number of cases that I don't think you're considering.

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.

Re:Typing Practice for Programmers by mgcross on Sunday January 29, 2017 @07:04PM (#13517650)
I built a Planck, and as much as I appreciate the ortholinear layout, I'm having a hard time finding/configuring a keymap that has the necessary symbols somewhere that feels intuitive. I'll spend a couple hours acclimating to a keymap on typing.io, but if I need to an ANSI staggered KB, even for a couple hours, it seems to wipe my muscle memory. Guess I need to buy another Planck!
Re:Typing Practice for Programmers by mharrison on Sunday January 29, 2017 @07:36PM (#13517772)
Keep practicing. I've used an ergodox for about 4 years with the Norman layout. I am still proficient at qwerty on laptop style keyboards.

Though I'm not a musician I assume it is similar to playing two different instruments.

Re:Typing Practice for Programmers by gedy on Monday January 30, 2017 @03:34AM (#13519478)
This is why I went with an Atomic instead of the Planck. Ortholinear, but very close to a "normal" keyboard in the layout.
Re:Typing Practice for Programmers by widforss on Monday January 30, 2017 @03:08AM (#13519393)
I use a special dialect of Dvorak, called Svorak A5 [1]. I think it is somewhat similar to what you describe. It is really liberating to have special characters on the home row.

[1]: https://i.imgur.com/YKojP7B.png

Re:Typing Practice for Programmers by paulddraper on Sunday January 29, 2017 @07:23PM (#13517714)
I'm awful at typing. My friends make fun of my rapid chicken-pecking.

I shrug and say I don't type enough to mind.

Re:Typing Practice for Programmers by vacri on Monday January 30, 2017 @01:07AM (#13519047)
I encourage you to drink heavily. A friend of mine learned to touch-type because he came in to work hung over too many times, and felt queasy switching between looking at keyboard and screen... so it made him learn to touch-type...
Re:Typing Practice for Programmers by junke on Monday January 30, 2017 @02:27AM (#13519258)
Your advice is "drink heavily"? Is this a kind of joke?
Re:Typing Practice for Programmers by vacri on Monday January 30, 2017 @07:32AM (#13520627)
If you're a native English speaker, you really have no excuse for not detecting that it's a joke.
Re:Typing Practice for Programmers by junke on Monday January 30, 2017 @10:44AM (#13522059)
I am not a native English speaker, so I guess it just flew over my head.
Re:Typing Practice for Programmers by a_t48 on Monday January 30, 2017 @01:10PM (#13523550)
I think it was a bit tongue in cheek.
Re:Typing Practice for Programmers by dualogy on Sunday January 29, 2017 @08:35PM (#13518017)
Sure but the more you do this, the more tools/commands/libraries/modules have to ideally both document and remember, realistically neither..

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.

Re:Typing Practice for Programmers by trentnelson on Monday January 30, 2017 @04:27PM (#13525196)
Cutler Normal Form! I love it, use it exclusively now on all my projects.

    _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.
    
    --*/
Re:Typing Practice for Programmers by quotemstr on Monday January 30, 2017 @04:36PM (#13525267)
I wish there were explicit pre- and post-condition sections. The pointer-typedef stuff never made much sense to me either.
Re:Typing Practice for Programmers by trentnelson on Monday January 30, 2017 @06:44PM (#13526120)
I'm definitely on-board these days with the typedef-everything approach used by NT. Every public function gets a typedef with SAL annotations exposed in the module's public header file, e.g. in this case, TraceStore.h has:

    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.
Re:Typing Practice for Programmers by quotemstr on Monday January 30, 2017 @11:19PM (#13527565)
Oh, sure. I miss SAL terribly. The consensus outside Microsoft seems to be that we need annotation-less static analysis because developers will never add annotations --- annotation-less static analysis, IME, has a much higher false positive rate than prefast. Windows is proof that extremely robust static analysis works.

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.

Re:Typing Practice for Programmers by trentnelson on Tuesday January 31, 2017 @01:05AM (#13528132)
Ah, yeah, const-correctness definitely gets way more tedious, but eh, just like the ugly as sin typedefs, I think it's a net win.

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?