Coding in Notepad
August 25, 2014
Vim is my code editor of choice. But lately I do more and more code writing in Notepad.1
I find it useful to keep a dated, stream-of-consciousness “project log” for each codebase I’m working on. Last year, I published a few of these (example), written in Markdown. These days, they’re unpublished and plain text, which means I can be even more casual and sloppy in them.
The project log is as much a whiteboard as a journal. In the project log for Gentest, I:
- Pondered how to emulate the Reader monad and/or dynamic bindings in JavaScript.
- Since I didn’t find a good way, investigated how test.check (a library with similar functionality to Gentest, but in another language) handles the underlying situation.
- Wrote pseudocode for a test runner.
- Brainstormed use cases for testing and what interface would best suit each one.
- Realized a potential interface wouldn’t work when I sketched out code using it and saw that certain things weren’t possible.
What I find remarkable about project logs is how often I end up actually running the pseudocode in them. For example, in a recent day’s notes, I wrote:
I think we need some lower-level thing for forAll to sort of desugar to that’s fully programmable.
And maybe what it is is like,
function forAll(args, name, prop) { _props.push({ prop: prop, name: name, gen: Array.isArray(args) ? gentest.types.tuple(args) : gentest.types.tuple(gentest.types.shape(args)) }); }
This was just to illustrate a possible solution to a problem. _props
didn’t exist; I made it up. There was no module to put this in, no
code calling this forAll
function. And yet, I copy-pasted this into
Vim, made a few changes, and it’s now part of the v0.1.0 release of
Gentest.
Writing in a notes file is low pressure. I can go straight from prose to code and back, shrugging off the precise demands of the computer. Using a lightweight editor emphasizes the difference. When I code in Notepad, I’m in a realm of pure thought just as if I were hand-writing in a physical notepad. The computing in computer science fades away and the “science” takes the foreground.