Hacker News
points by saidnooneever 4 days ago | 0 comments
if you write your program first with pencil and paper u'll be amazed at what you can do yourself.

most people open an ide and start coding, or write some basic diagrams to get an overview/mental model. Back in the day any bitnlarge program would take hours to compile so really u did not want to have any bug or typo just to sit for hours until a compile error or logic mistake. Take it even further back to days before C and that is even more needed.

a lot of high level modern languages seem to alleviate that need, likely so that enterprise software can be written a bit faster because the features need to arrive faster.

still in more modern languages i'd recommend starting with pencil and paper, write most of it if not the whole thing out. u'll find much nicer patterns and will save yourself a bunch of refactoring. even for small programs.

[–] lieks 4 days ago
When I was at school, I used to program on paper like this (due to not having a computer during class). It was accidentally a great exercise, that I think everyone should try. Because of it, I find myself writing mostly bug-free code on my first try these days (my bugs tend to happen on interactions between parts of a system I designed separately).
[–] 1718627440 4 days ago
I had the same experience of writing almost no bugs when writing on paper. (Only conceptual bugs, e.g. in architecture or that I solve the wrong problem in the first place.) But when I now write code on a computer, I do introduce bugs. However I regularly find tricky and rare to occur race conditions or heisenbugs just by printing and reading the code from top to bottom, without a goal, just for entertainment. I did not know of the existence of the bug, before I find them. They stick out when you read it, because it's not what you have in your head that should be written there.

It helps me to print it in a different font/color and without syntax highlighting to force my brain to read it as new code, instead of simply assuming it's the same as I already know.

[–] saidnooneever 3 days ago
i recognise this. i do pen and paper still but i do also write bugs. when i do i try to make test programs to learn why, and ideally recognise where my pen and paper whent wrong, because those are gaps in my real understanding of how my language, the program or interactions with its environment and platform really work. Needless to say i always find myself having lots to learn still :). i think in reality only once or twice i wrote a program truly free of bugs. relatively trivial programs ofc (simple socket client/server with basic binary protocol or so. easy to reason about, no complex sync or threading requirements).

i never use syntax highlighting. one day someone told me it was very distracting, i turned it off and suddenly things were calm. Maybe its just taste but i do find it helpful. you really read stuff rather than assuming some color happening means its correct or incorrect subconsciously