Writing code with pencil and paper (2022)
css-tricks.com
css-tricks.com
Writing out pseudocode on paper is… okay… although not my preference. It’s okay if you get stuck and want a context switch.
Writing out syntactically correct code, including commands like “sudo” on paper on the other hand is an enormous waste of one’s own time. God help this man if he ever takes up Java programming. Just type actual computer code like this on computers so you can run it and see if it works. Then if it doesn’t you can just use backspace instead of an eraser.
I'm surprised no one has mentioned it here yet.
However i fear his message is lost on the young'uns today (witness the comments in this thread :-). As he says in this interview, while the trivial/easy parts of programming have been automated (using IDEs/tools etc.) the hard parts will always remain and that is where thought and rigour are needed. This is where paper and pen/pencil reign supreme. They engage the whole mind and body to focus on one single task in a totally natural and free manner.
I haven't had an interview like this in about 10 years
- whiteboard / paper is just so slow
- extremely poor editing functionality on whiteboard / paper
- some people's handwriting is not legible
The only one I remember that involved a sheet of paper was 20 printed pages of code which I had to find the bugs in. And that was actually quite a fun exercise. (I did apparently find more bugs than most, I also subsequently found some bugs in their contract and NDA.)
It was a strong signal I didn't want to work there.
There were even stronger signals that followed. It was by far my worst interview ever, I haven't really gotten over it yet.
It even caused me to sign up to glassdoor just so I could leave a negative review.
I can’t even think of the last time I did an interview without a computer in the room.
Really not sure this is relevant to me.
https://www.vintagecomputer.net/browse_thread.cfm?id=372
I remember the moment it clicked that "if statements.. strings... I can make a text adventure!"
It feels like that experience helped me develop, but on the other hand, don't we all think that about most of the hardships we experienced when young? It's hard to know for sure.
If you're finding yourself reaching for pen and paper to write actual code, then your tooling sucks.
Your IDE isn't suitable for prototyping, or something else is going wrong.
I'm not suggesting that nothing in the planning phase should be white-boarded, but pen is the wrong medium for code.
You should have a tool where you can fire up your tooling and be writing the same thing you would write on paper, but with autocompletion, error feedback and browsable interactive output.
In my experience that's far more appropriate an environment for rapidly getting something down and working through the problem.
By all means, start with pen and paper to get a feel for the problem domain, but that process should stop short of actual code, and this article doesn't really sell me on the benefits.
I'd rather test my assumptions in something like LinqPad, where I'll get real feedback not just a "feeling" about what I've written.
The first part is something I believe in this case. It’s ok to think with pen and paper (and I do when trying to find an algorithm) But I stop short of implementation details, instead typing out code. Why? Because text editors is much more flexible in this particular case (live programming environment, REPLs, or a quick code-compile-run cycle are much more useful)
And the second part is why I don’t like LLMs for code generation. Snippets are more deterministic. I’m ok with it for suggestions of ideas I can explore (in books, not with the LLM)
Or maybe it's horses for courses?
Personally I found the idea of going beyond prototyping on paper as a rule not for me, though there are sometimes final snippets reveal themselves better away from the screen when I'm stuck in the mud on something.
My point is though that we really ought to allow others to find their own way and what is best for them rather than dismissing it so emphatically because we don't personally get it.
Taking a format that only a computer can interpret, code, and choosing to write it down on a medium a computer can't read, hand-writing, is not typically a productive exercise.
Even in interviews I'd rather hand a candidate a laptop.
There are more worthwhile things to hand-write, such as sequence diagrams, and there are more worthwhile places to write code, such as an IDE.
If someone is finding it easier to write code on paper than in an IDE, I'd rather not ignore that signal and try to discover why their IDE is proving such an impediment.
Maybe it takes 10 minutes to start up, maybe it throws up so many errors for each syntax mistake that it's distracting and hard to see the wood for the trees. Maybe it doesn't actually produce useful output. Maybe it doesn't have real time debugging and step-through.
Who knows, but something is causing it to be mentally easier to write down the same code on paper than the IDE, and that's not something that should be ignored, that's something that should be fixed.
Coding on the IDE helps me to experiment and quickly put something together that works.
But thinking while writing things down or while walking is a slower process, so it helps me focus on nothing but the problem obvious edge cases, different solution designs, etc...
So by thinking about the code away from the IDE first, then by polishing my ideas on the IDE, I usually end up with higher quality code.
But since it's less fun to do things that way, I just tend to do everything on my IDE.
Its obviously a given - except where people are commenting in a way that indicates they are expressing the one true way, as you did, and have done again.
The OP's way is not for me, but I'm ok with it being for them.
I agree that if there is a problem in their process or workflow that is influencing an inferior (for them) approach it is better to try to help them fix it.
The post isn't about writing code on paper, but about the planing and ideas collection before writing effective code.
> write down the same code on paper than the IDE,
No, pseudo-code and notes and flowcharts aren't the code (maybe the later on some visual language environment.) You're missing the whole point, sorry.
Regardless, I don't see why the parent would have necessarily mentioned pseudocode for any reason?
(Also, even Python is at more risk of funneling you in some direction that might be suboptimal, at least more than pseudocode.)
More, I find that forcing myself to run the code in my head is a good idea.
That all said, I don't do the paper thing often. Really only when thinking at a level other than the symbolic of text. Some system diagrams. Sometimes numeric. I suspect if I got good at Mathematica, I'd do more numeric thinking there.
Actually, this way you catch a lot of poor design decisions that you would otherwise fall into. If starting out with code, I might attempt to "fix" poor design through hacks due to the "sunk time fallacy" of code already written, that kinda works, but isn't maintainable.
Honestly, no "tool" on a computer would let me print my imagination as easily as pen and paper. Perhaps a drawing tablet, but that's an additional thing I would need to plug into my PC.
Oh bull. At the level of thinking where you’d pull out pen and paper, ALL digital tooling sucks. Not one single solitary tool can beat pen and paper at that level. Not one.
We appear to agree there's a place for pen & paper, and we appear to agree that's a different level to coding implementation.
Writing down code, complete with correct syntax, parentheses, indentation, etc, as the article wants, is not in my opinion that level.
At that level, the tooling does not suck.
So yes, I agree, "At the level" where pen & paper shines it should be used.
That level is not writing correct code, unless you can convince me otherwise?
With the hard evidence you can then refer back to. So, when you are ready to expand your design you already have the foundation on page.
It acts as a pillar to the psuedo code that comes with design later on. If that is the going to be foundation to that function, it might as well be written correctly on paper.
Not every problem I'm solving is just a hunt for the code implementation. I like to reason about solutions beyond the syntax. I use pen and paper a lot, including for code, and I'll use shorthand to represent longer-form code blocks. I find that approach better because I can hide the noise that code blocks can introduce in an IDE. I want code to support my solution -- not a solution to fit into code. IDEs and frameworks can have that affect on people, in my experience.
As with this comment and the one preceding it, your mileage may vary.
> but pen is the wrong medium for code.
Pen & Paper is really excellent for many people, maybe not you but it's fine some others. You may use an electronic device (some people are using Remarkable and alikes) or chalk and black board, or MindMapping app; the key idea is to first forethink and analyse the problem before diving into coding.
> your tooling and be writing the same thing you would write on paper, but with autocompletion, error feedback and browsable interactive output.
What kind of tooling do you use for pseudo-code (not a real language, but textual informal prose) with that features?
For many years the only way I could program was pen and paper, and a bit later a Citizen SRP-175 programmable calculator with mind-blowing memory to run 128 instructions. I would go to a library, borrow a bunch of books some of which were programming, and knock myself out writing programs on paper that I could only ever "execute" in my mind.
If you have an old computer, there probably is a child who would give an arm and a leg to have a chance to have fun with it.
I usually take notes or lay my thought using a text editor, I find it easier to edit, manipulate, and store. I occasionally use a graphics tablet or my phone with a stylus when I need more than text (ex: drawing schematics), essentially like paper, but more editable and I can save it as a file.
But if you find that pen and paper works best for you, go for it. Maybe one reason I went the opposite route is that the author likes to think in advance before going for the implementation, that's a top down approach. Mine is very bottom up, I go straight to coding, sometime even before reading the specs. It feels like putting ideas into code makes me think more clearly. I can always scrap that code later, I often do, it is cheap when things are just getting started. And pen and paper is not really suitable for that kind of rapid prototyping.
Ok, not easily.
The problem I have with a ton of computer based sketching tools, is that I just don't sketch with a mouse that well. And doing it with the keyboard is ridiculously difficult for me. The Wacom can mostly work, but it takes a ton of getting used to having the pen detached from what you are drawing. Easier than the mouse, but still hard.
Even in college, the computer was in the computer center. So in the dorm I'd still code in spiral notebooks, listening to ELP and Jethro Tull.
I kinda miss that a teensy bit.
On college I remember having to code on paper and you simply can't test your code for typos or small error, even if your logic was perfect professor give you marks for a missing ';'
note: the class was evaluating the Logic / algorihtm not basic code syntax
By contrast when I write code I see in my minds eye what the code should do, tinker with it, formulate an algorithm, and only then do I try to translate what's in my head into syntax.
When asked how people can learn this skill (or get better at algorithms in general) I always say they should practice writing code by hand.
How does writing code by hand fix this? They can still write the same things from the same understandings. I've had some luck having people explain things to me, without looking at the code/math.
Writing things by hand can just help facilitate that because it removes the ability to run the program and get the final result.
People can lean on their tools to 'guess and check' their work. Write a loop, run the program, and get an out of bounds error. They'll have learned oh this error means I need to subtract one from my loop bounds. And sometimes that works, though many times, it means there's an edge case they didn't properly handle.
When you only have pencil and paper and you need to explain to me what your code does you have to write down a representation of what's in memory and then how it changes step by step as the code runs.
The main benefit is getting things generally straight in your head before committing to data entry into a tool or coding.
It's a false saving to spend days / weeks at a computer to save a few hours of design time.
Outside of that - life is short, and this is waste of it.
Job interviews with pen and paper are hardly a selling point for me, I had one 10years ago and still dreaded it. My 2 cents are, if a company hires you to work on a computer in X environment then that's what they should test you on - or as close to it as they can.
Later when code was typed in at the terminal, I used a notebook and pencil to record bugs one per line which is still the best bug tracking system for initial development IMHO. Checkmark on the line when it is fixed, and capital T when it has been tested as fixed.
This was written in 2022??
Such a complete turnoff right off the bat, how out of touch do you have to be to write something like that? Maybe the author should have spent some time hand-writing their article first. /eyeroll
It doesn’t seem silly but saying it’s inevitable does seem silly…
I do not remember the last time I or someone else has had an in-person interview; saying impossible would have been more accurate than saying inevitable
However, I do see this being possible and beneficial for students who are at the whims of the professor and if the professor prefers the old-fashioned approach; you will end up writing some logic by hand
I can use the tub surround as a white board for my "ah-ha!" shower moments.
I haven’t done this a single time in my life and I’ve interviewed for no less than 25 positions.
I always admired his patience and skills, me using an assembler on an Amstrad to write my games.
nah, wanna go old-school, use inkwell pen, or better still feather + ink for hard-core hackers! focuses the mind, you've gotta know your grammar, syntax etcetera. non of that autocomplete sorcery for me
And not saying don't think just pointing out that careful handcrafted logic takes almost the same time to implement anyway.
Most problems are such that it's hard to know what really needs to be accounted for initially due to some janky interface or the language not behaving as you expected which can nuke the whole plan.
Writing stuff down can make you more confident about the approach and ironically lead to a dead end because you assumed everything was accounted for.
Anyway, not sure if it's "guaranteed" to be worse than using a computer. Yes, you'll definitely get less help with pen and paper. But you'll probably end up understanding the problem better, without relying on GPT completion of code etc...
Even if it did, having to write down thoughts or code by hand at slow speed and without convenient way to modify it is significantly worse. Not to mention I'd constantly get distracted by my ugly handwriting.
If you prefer doing it the oldschool way that's fine, but don't force it on others assuming their brains work the same.
It was Machine Code.
It has been suggested ([1],[2]) that writing by hand helps with memory retention and probably other aspects of cognition; in my case, it may just be that writing [edit: by hand] "feels calmer," so, if I have a hard problem to think through, the pen usually comes out.
[1] https://pubmed.ncbi.nlm.nih.gov/33815075/
[2] https://journals.sagepub.com/doi/abs/10.1177/095679761452458...
I need to write down my thoughts for everything on paper, sticky notes or drawing boards if I want to be sure that Ive thought about it well enough. I find most people don’t have this immediate drive for quality, though. Most developers just want to splash words on the keyboard and see an initial result to see if it works. I work the opposite way, I need to see it work in my mind or on paper before coding it. But neither of us is right or wrong, we just work differently.
Also, when thinking of a solution, and I'm starting to form an idea in my head, typing it into an IDE can make me lose focus unless the idea is already very clearly outlined in my head. It's happened to me before that while I have a partially formed idea in my mind, I type it into the IDE, and a large window of completion suggestions, or a red underline from a typo, distract me and I forget the idea I was thinking about, and I have to start over.
I was diagnosed with ADD; it could be I'm just more easily distracted than other programmers.
And yeah, I draw tables, write pseudo code, draw outlines of the program, sketch data structures, etc.