How I Write Code: Pen and Paper
noteflakes.com
noteflakes.com
We bought the books, wrote the BASIC code and rewrote it many times until we thought it was good.
Once the computer came though, all that went out the window. But to this day, my desk is covered in notebooks that help me visualize problems before writing any code.
I sketch out UI. Design database schemas. Draw data flow diagrams and end up with many, many, many notebooks finished up every week. I don't know if it makes me any better as a developer, but whenever I do it, I feel more confident approaching the computer and working on a solution.
One of them graduated from IISC, Top rank holder in all-India entrance test for it, is at top position in a leading SW company abroad and another runs a SW company in our city with about ~ 100 employees for 25 years (he's content with the scale); Many of his ex. employees are at top positions in FAANG.
I guess the story would be same for many from GenX who have made themselves a great career in IT but couldn't afford a computer when they were studying.
I did not have a computer at the time. So I wrote actual program on paper, ran it, debugged it mentally. When I was satisfied, next day I went to my father's office which had a computer luckily with C compiler. I typed the whole program from the paper and ran it. There was no compiler errors or anything, but it didn't print anything on screen, absolutely nothing. I was surprised because I knew it can't fail. After spending hours of checking program and reading books (internet was still a long away), I realized I had put semicolons after every single statement including `if`s and `for`s conditions, essentially short circuiting everything. Once I got rid of those extra semicolons, it ran perfectly. What a nostalgia!
There's a collection of edw519's best comments here: http://static.v25media.com/edw519_mod.html - CTRL+F "paper" will show many answers in which he talks about how he works with it.
It's true that I don't comment much anymore, but remember, when someone who used to comment with so much energy before slows down, it's probably because they're so busy with the stuff that made them comment in the first place.
I'll be back. Promise.
Thank you! :-)
When I said that 'you sadly aren't commenting much anymore' I meant that in a selfish sense - it's sad to me, because I enjoyed your comments over the years. I've guessed you must be spending your time on more interesting and rewarding things.
Take care, and see you around!
Similarly I sometimes code review by printing out diffs and writing on them.
I like the tactile side of writing, and the spatial freedom. Also I just find it easier to think away from a screen somehow -- coding on a computer is still my majority case, and it's essential where it's the type of work that involves stitching things together. But for algorithm or code-design style work, if I get stuck I write it down.
One theory I have is that because I have a very spatial/location-sensitive kind of memory, scrolling on a screen messes with my internal mental map of where things are.
I mean that if I'm designing something or trying to understand someone's code, my working memory built up of the things that I'm reading or writing down is linked to where I read or wrote it, and I think a single screen space in which anything and everything can appear messes with that and makes my brain have to work harder to remap things.
I can forget almost anything no matter how obvious, but if it's linked to a location or is spacial then my recall is spot on. I can't tell you anything about 90% of my education but could give you exact waypoints for a 3 day walk I did over 15 years ago.
I've tried harnessing this ability with the 'mind-palace" techniques where information is associated with a visualised place. I worked at a large outdoor store for a few years with a huge stockroom and used that as my base. As I was learning programming I assigned topics to sections of the stock room and related concepts with specific products. Sounds nutty but it did seem to work (I can still recall all this information).
Remembering things this way fell by the wayside though as it requires very intentional "remembering" in the first instance. It's exactly like filing — you have to do it upfront. I never used it enough that this became second nature.
I do write code on paper though, but I quickly realised that writing in a journal is suboptimal for me. When I studied design we were encouraged to take notes on loose-leaf paper both to reduce the "preciousness" that comes with bound notebooks and so that we could reorder pages but also spread it out for a high-level view. For this reason my preference is writing code on index cards where each card is a data structure or function which then get grouped into modules (thinking Elixir here).
Despite this preference I tend to just use a notebook for scribbles and "working memory" notes because I'm prone to losing cards. I've toyed with the idea of a huge blackboard and post-it notes in my office before which I may look into again soon.
Anyway, the firm I was working at only had 2 proper DOS machines, and one of those was reserved for the boss, but there were up to 3 programmers working on the software.
If the DOS machine was in-use (which was most of the time) I had to spend the day 'writing' my code on another machine (an ACT Apricot PC). This machine, although it booted into DOS, was NOT IBM compatible, so the IDE software wouldn't run. All I had was the provided Word Processor app, so I wrote in that, sometimes for days, hoping that what I was typing was working code.
I'd only know if I'd written working code once I'd transferred it via floppy disk and compiled it on the real DOS machine every few days.
Not quite the same as coding on paper, but this thread reminded me of this part of my career.
You may be doing some abstractions/pseudo code on paper but you're not coding. You're planning.
There's nothing wrong with this! I think it's a great way to operate. But it's less sexy to say "How I Plan: Pen and Paper" then to conflate it with coding.
Everyone does planning. Some people do it on-the-fly while coding. Some people do it in their head. Some people write it down.
> I opened my laptop, created a new Github repository, typed in the code, added some tests and wrote the README. It was probably all done in 4 or 5 hours of concentrated work.
Means handwritten code verbatim went into the repo. The focus on iteration is great - it would be unusual to stop at this point.
But if we say the written word is canon, my response is that's inefficient. It is indeed the planning that is most valuable when putting pen to paper.
It actually helped make things stick better, after initially adjusting to it.
Afterwards, I would end up typing code more deliberately, and found myself tapping delete far fewer times.
Very similar experience to learning drafting-by-hand before CAD.
feel bad for the T/As that had to grade all those exams.
The author is conflating coding with solution planning in a pretty minor way - you're more seriously conflating coding with solution building.
Architects do a similar thing, they visualize in their heads and on paper, but then they also actually build 3D small-scale prototypes to get feedback on their design.
So I would say that coding can also be an important part of the design process. It is not just transliterating what's in your head to code-files on the computer, it can help improve the design which is in your brain.
I think it’s always true that there is some time spent figuring out what problem is being solved, what needs to be built to solve the problem, building something, and making sure that it solves the original problem.
In mechanical or electronics it tends to be called manufacturing instead of development. In civil engineering or architecture it tends to be called construction instead of development. I think the difference in creating software is that one person can do all phases. They can even do the phases without formally documenting anything. The phases can be much shorter and iterated on much quicker in some software projects. I think when the software projects become larger and require more developers that they tend to have a more clear demarcation between phases and use more formality in documentation.
I think it would be more beneficial to the software industry if everyone was working with similar enough terminology that discussions don’t end up revolving around who is operating under what definition and which definition is best. But at the end of the day that’s just my opinion.
I don't see how some solutions not requiring code means that coding is not valuable, as some solutions evidently do require code.
When the solution requires code, the code is the solution, whether it's written in pseudo code or a language. I don't think there is a line separating the two. Just like language is thought.
Your "deploying solutions" could be replaced with "deploying code" (whether created in house or third party).
If your solution depends on code, then the quality of that code will also be important, which will include aesthetics, design, readability, tests.
In the long run, this is valuable, as you can't regularly and reliably ship the solution, unless you're confident it still works.
So if you're a programmer then you're in the business of building software solutions which are generally built via writing code or script of some sort.
If the problem is best solved via a method other than writing software, then that's great. Not every problem needs software. Not every problem even needs solving either.
If however the problem does need a software solution then it's obvious that you should make sure you actually understand the problem so that you actually solve it.
I guess I just don't see how coding isn't equivalent to solution building unless what you call coding I call typing. For me thinking, researching, investigating, designing, engineering, planning, and even just "sleeping on it" are all part of the coding process.
I suppose that if the purpose of your coding is to learn or play then you might not be building a solution.
Is this just semantics or am I missing something?
I don't think so, or perhaps expressed myself poorly. Planning is a critical part of solution building. Coding is putting the pieces together.
Unless you're absolutely winging it, you're mostly doing planning and then execution. My argument is the planning - the most important part of solution building - is what's being done on paper.
I am not a developer, but occassionally need to write code. I always go to the paper first now.
I personally really enjoy pen because it makes you own your mistakes.
I think a lot of people here are not getting the gist behind the use of pen and paper; so let me try to summarize it;
* They do not limit the concrete expression of any concept/thought that you might have. You can use text, symbols, invent new symbols, connect them in any fashion you choose etc. etc. They are free form and become an extension of your mind. See also the book; The Body Has a Mind of Its Own: How Body Maps in Your Brain Help You Do (Almost) Everything Better.
* They force you to slow down your thoughts i.e. still your chaotic mind and help focus on the problem and its various aspects. This is invaluable in today's world filled with distractions. The books by Cal Newport are applicable here.
* If you choose to make your notes public, it adds another layer of discipline to really understand the subject matter since you have to anticipate possible objections and have the answers ready.
* Finally, they help clear your mind of the inessentials allowing you to ruminate and manipulate the essentials more effectively. Yet ancillary data is always available as needed.
If you look at History, all the greats wrote prodigiously. I firmly believe that it was one of the defining factors which directly led to their eminence. I was first inspired by the Notebooks of Leonardo Da Vinci (get the 2-vol large prints by Dover) before i started noticing the pattern.
PS: I read somewhere that Dijkstra wrote one of the first Operating Systems; The "THE" Operating System by hand on paper!
Paper/whiteboarding is more for communication to others, in my experience
Also, I'm old enough to not have always had electronic devices, so sketching was all we had. In college, I didn't live on campus while living with my parental units an hour away. With the limited access to the computer lab, I would hand write code on paper and then transcribe. Then, right at the end of lab time, hit print so I could continue debugging by making notes on the greenbar print outs.
The problem I run into when I'm brainstorming or thinking about high-level architectural/modeling questions, is that if I start drawing something I get focused on how to represent my current idea and I stop actually developing the idea itself. And then if I change my mind, I have to go back and erase or strike things out instead of just redirecting my thought. Etc.
Usually if something is new for me or ill-defined, I take a walk or a shower and work through a rough idea of the big picture (usually realizing and iterating on some of the high-level problems) without any medium.
And then when I sit down to start seeing what that established will look like more tangibly, I usually go straight to the computer. Though I will say, I sometimes turn off type-checking when I'm just writing the idea out the first time. It can get really distracting when the code is going to be "broken" for the first 90% of the process. Once I've given it a look over and feel good about it, then I turn editor hints back on to nail it down and get it running.
Sort of like a swap file, where if the number of items gets bigger than my working memory, I dump some of them onto a sheet of paper rather than thinking about all of them at once.
I'm interested in hearing how other people approach diagrams, because I bet there are a lot of different approaches, and no one size fits all.
It works better at the phase after ideation, where I'm pretty sure I have the major ideas in place and I want to see them to make sure they make sense. But even then I prefer a digital medium because of how easy it is to delete or modify (even an eraser leaves behind a smudge, adding something to a list on paper means moving each item by hand, etc).
Use a pencil, and not a pen ;-) Much less permanent. Just knowing you can erase should make it feel less decisionish. For me it's the opposite. If it's a sketch on paper, it is so much more transitional. Once it's in code and executable, it makes me want to keep forcing things until it works. But that's what makes it fun. Each dev sees the same problem totally differently and approaches it in their own way.
The test is the problem statement, or maybe a theorem.
You then need to figure out how to solve/prove it. You can do this on paper then type it in or directly. It doesn't really matter.
When the test goes green you know you've solved it.
Edit:
This line resonated with me:
> Maybe someday I’ll be able to handwrite code on an e-Ink device and then run it.
Are there successful projects for pen-based programming? I've read about Grail as a historical footnote, using hand-drawn flow charts: https://wiki.c2.com/?GrailSystem
I'd also be remiss to not mention Ken Perlin's Chalktalk project, though that's mostly a presentation system as it stands: https://github.com/kenperlin/chalktalk
These are both largely graphical and gestural, with a good number of low-stroke symbols instead of handwritten strings for the most part.
For example, using Swift Playgrounds with pen instead of going through all the digital keyboard transitions, or the external keyboard.
As for the article, that is also my approach most of the time, and how I sometimes do coffee shop programming, with a paper notebook and pen in some pseudocode.
Then back at the home/office I actually try out the ideas.
There's something there, I think, but it would have been much better without the bit about bikeshedding, or reordered.
I also have an ipad/pencil with the excellent notability app (excellent because it gives me an infinite grid page) for jotting notes/things I need to follow up on.
I tried keeping that stuff in a text file but there is something about writing it down on the ipad that means I rarely have to actually look it up, it sticks in my memory better and if I do forget what I had to do I rarely forget that I had something to do and can just look it up when we need to.
It's pretty cool how the comments are divided between "I write code on paper/I used to write code on paper" and "Nobody could ever write code on paper, she must be speaking metaphorically." It's kind of like China Mieville's "The City and the City": somehow these two populations in the same place don't see each other at all, or they pretend not to, in order to avoid conflict.
I have an easier time writing code on paper than on a computer when it's "algorithmic" and its problems are internally generated, or when it's in a domain I already understand really well. I wrote a Soma cube in OpenSCAD once in a text editor on an internetless iPhone, which is more or less the same thing; Naomi Wu mentions that this is one of the benefits of OpenSCAD for people in poor countries, where they maybe don't have access to sit in front of FreeCAD or Blender all day, but they can totally type text on their cellphone while they're on the bus. Or write it on paper, maybe, but that takes two hands.
On the other hand, I also write a fair bit of code where the relevant unknowns are things like "What kind of user interaction will feel responsive?" and "What will this API do if I invoke it with these arguments?" and "How many public recursive DNS resolvers are there on the internet?", which are not things I can find out by thinking and writing things on paper.
I may be living in the future then. :D
It helped me to think about the conceptual side, but other than that I'd never do it again. I like to seperate planning and coding nowadays. Writing code on paper doesn't solve any problem for me, but I respect it if it does for OP or other people!
Also, a lot of the work of a programmer consists in understanding existing code. You need the computer for that.
This was not the kind of toilet paper you would see nowadays, though. It was not in a roll, but a deck of precut pieces, and they were not soft at all. One side was glossy, and the other - rough. The glossy side was perfect for writing. It was almost like a notebook, only cheaper.
Here's a link to a somewhat similar kind - https://www.ebay.com/itm/VERY-RARE-OLD-ORIGINAL-RUSSIAN-TOIL...
(I'm not the seller, I swear.)
I do miss these times. I could actually write a whole program without compiling it, and it would run fine on a computer later. Most of the times.
On a similar note as the author, I enjoy stepping away from the screen to code, though it's mostly for problems I'm stuck on. There's been many times where I've been lying in bed thinking about a problem and I suddenly think up a possible solution in my head and then run to my computer to type it out to see if it resolves the issue.
Is time we bring back Static web page. We have Modern MultiCore CPU and SSD. Surely 99% of personal webpage shouldn't require a call to DB.
Edit: Oh interesting this is from the oringal author of Sequel.
While I often prefer the interactive feedback of a proof assistant or model checker I find spending time away from the screen and thinking on paper to be very relaxing and helps me with, "connecting the dots," so to speak. I tend to get a very narrow focus on the problem at hand when I'm at the computer.
I too hope to one day be able to write code by hand on my RM2. I have hacked a basic editor into an RM1 but it's slow going.
I had several mostly pen and paper courses because the professors preferred that to lab assignments. This was 2009.
They have a point. If you don't have an instantaneuos REPL, you'll probably think harder about what you are writing.
I like doing this in notion -- here you can write code with the syntax highlighting and attach all sorts of stuff to the document -- once you've crystalized exactly what you want to build, you can fireup your IDE and get to work.
I think it ties with the theme -- A programmers work is not to type things -- the main input is thoughts and ideas that can be interpreted by a computer to do correct things. A notebook helps with the thoughts and ideas part.
I use my iPad + Pencil to create sketches or I do it on paper and take a snapshot with my phone.
[1] https://github.com/fonsp/Pluto.jl [2] http://weavejl.mpastell.com/stable/
But it was a simple algorithm and it didn't specify a language so I wrote it in 386 assembler. I think that to this day is the only program I wrote by hand, and I know it compiled and ran correctly as they made me type it and execute it (only for fun they knew I knew what I was doing)
One of the advantages— perhaps the main advantage — is that the notepad doesn’t have an internet connection.
Use Mechanical Pencils. No leaking/drying/wastage and you always get to marvel at the ingenuity that goes into making some of these gadgets.
Plus it gives you an excuse to indulge in another collection mania :-)
See https://www.jetpens.com/blog/The-Best-Lead-Grade-For-Every-A... https://www.jetpens.com/blog/Mechanical-Pencil-Lead-Size-Com... and https://www.youtube.com/watch?v=73gZFjIAHtw
My current favourite is the classic Tombow Zoom 505 series - https://www.tombow.com/en/products/zoom_505/ Not too costly, well made, elegant and professional looking. I have the Rollerball (i.e. water-based ballpoint), Mechanical pencil and Multi-function pen all in Black.
Next up are the "Parker Jotter Originals" for EDC (https://blog.penvibe.com/parker-ballpoint-pens-ultimate-guid...). They are very affordable and hence i keep them everywhere.
Multi-function pens (which have 2 or more ballpoints and a mechanical pencil) are another must have (I limit myself to 2+1). Buy a good professional looking one (eg. Cross/Zebra/Pentel/Rotring etc.) rather than the cheap plastic ones (they look ugly).
Staedtler has a series called "Triplus" which have a triangular body (supposedly more ergonomic) - https://www.staedtler.com/intl/en/products/writing-pens/
Many of the OEMs who actually manufacture the pens but which are sold under other well-known brand names are now releasing them under their own name. Two of them are TWSBI(Taiwan) and Penac(Japan). You should check out their offerings.
If you are a Fountain Pen connoisseur, you should know that India has a large number of Artisanal Specialist Fountain Pen makers - https://www.bbc.com/news/world-asia-india-55314701 and https://www.fountainpenindia.com/
Finally, always check the offerings from Japan (Amazon.co.jp and Jetpens are your goto sites); they make some of the best and most innovative stationery.
I for some reason don't like the Parker Jotters as they are too thin for my fat fingers. Also the blue color of the ballpoint is too much on the purple side and gives me a headache. I too have one but I don't use it much but I still love it ;-). I am aware of their Gel lines but not sure whether they work for the Jotter.
>Finally, always check the offerings from Japan
I love the Japanese offerings but I don't get much in India. For eg Pentel has its factory in India but manufacturers limited set of models. I love Pentel pens btw but I am not satisfied with its offerings in India.
I am currently using Uniball Signo retractable UMN 207. Although the build and the ink is very nice it skips a lot and I am not sure whether it is because the ink is not designed for Indian weather or paper quality. I do see people having complaints with skipping but not much. I have ordered some UMN 307s and have to see how it fares.
>Many of the OEMs who actually manufacture the pens but which are sold under other well-known brand names are now releasing them under their own name. Two of them are TWSBI(Taiwan) and Penac(Japan).
I am thinking of buying the TWSBI as I really love its unique see through styling. I was thinking of purchasing a Lamy though. I am afraid to use Fountain pens as I work in harsh environments and I am not sure how it will fare but then again our ancestors were using these pens with ease. :-)
>If you are a Fountain Pen connoisseur, you should know that India has a large number of Artisanal Specialist Fountain Pen makers
Yes I am aware but the problem is I think they they import their nibs and just make the body of the pens. Somehow I don't feel like buying this Frankenstein and would love to buy the complete product if they make it.
You can find Japanese offerings on Amazon India and if needed, get it directly from Amazon Japan (i do both). You can also contact the resellers (who import from Japan and sell on Amazon India) directly for a better deal. For example, you can get the Tombow pens from https://www.foremostindia.com/
You should also check Aliexpress. I came across a rollerball pen which can be refilled like a Fountain pen which is neat.
Finally, your quote
>Yes I am aware but the problem is I think they they import their nibs and just make the body of the pens. Somehow I don't feel like buying this Frankenstein and would love to buy the complete product if they make it.
This is quite the wrong way of looking at it. These guys are very good and are optimizing their product based on their available skills. Making a nib requires metallurgy, high-precision CNC etc. which as small specialized Artisans they cannot afford to setup. So they focus on what they are good at (this is exactly similar to specialized Artisans in Germany and Japan; you find entire video series on Youtube; eg. https://www.youtube.com/watch?v=f5dekz26Kdw). For example, i have a Tombow pencil sharpener where the plastic body is made in Vietnam but the blade itself is made in Germany!. If you are a Fountain Pen guy you should definitely get one or more of this.
Finally, i should note that a lot of branded Pens are manufactured in India; eg. Parker Pens are manufactured by Luxor India and exported.
I don't think so. It is a "Parker Jotter Standard CT Ball Pen".
>You can find Japanese offerings on Amazon India and if needed, get it directly from Amazon Japan (i do both). You can also contact the resellers (who import from Japan and sell on Amazon India) directly for a better deal
Won't this be too costly due to import taxes?
>These guys are very good and are optimizing their product based on their available skills. Making a nib requires metallurgy, high-precision CNC etc. which as small specialized Artisans they cannot afford to setup.
I think Ratnam makes the complete product. I must say that I am not much into Artisanal pens though. Similarly I am not much into funky anime type colored pens from Japan. :-)
>Finally, i should note that a lot of branded Pens are manufactured in India; eg. Parker Pens are manufactured by Luxor India and exported.
I don't like Luxor very much. I think there are quality control issues with the Parker pens as there is a lot of rattling in their jotter pens. I researched and found that it is not universal and was pretty pissed off as the Jotters are not cheap. Another reseller is Linc who are resellers for Uniball and they don't care about what they are selling. Similarly Pentel has a measly collection even though they have a manufacturing plant in Gujarat.
In my school days I used to use a Hero Fountain pen (Currently Shanghai Hero group) which was pretty good and my daily driver. My mother still had her beautiful Pilot pen from the 70s which I started to use later. I also sometimes used to use my classmates Butterfly pens too. I bought a Hero fountain pen in 2008 and it was horrible. Not sure what happened to it.