Ask HN: How do you print code?
I would really like to print out stjepang’s library smol. It’s just a few thousand lines of code and I have a feeling that it would be easier for me to understand on paper.
How does anyone do this? I’ve heard that companies sometimes do code reviews on paper, so I figured this would be a solved problem.
Still, I couldn’t find a decent solution anywhere. So there’s the question for Ask HN. How in the world does anyone print code in a reasonable way?
By “reasonable”, I mean:
1. with line numbers,
2. with syntax highlighting,
3. and preferably some sane separation of source files.
Smol:
https://github.com/stjepang/smol
16 comments
[ 0.21 ms ] story [ 50.3 ms ] threadTo change the highlighting theme, e.g. to "pastie":
I was already using Pygments to highlight my source code and was thinking if I could print them highlighted with it.
Pygments has many formatters to format output. I used .rtf but you can also output images as well.
(I didn't have to print line numbers back then)
You can generate LaTeX documents, images etc. with line numbers. And then print them. hmm.
https://pygments.org/docs/formatters/
https://pygments.org/docs/cmdline/
You lose facilities like: goto source, search/replace, modifications (I might modify/format a piece of code temporarily, to help me understand it better, might rename functions, variables, add lines to visually separate parts of code, etc) and many more.
You re-enforce your discomfort with reading/writing code on the screen. I'm trying to assume different reasons that you might have to learn a code and for all of them that I can imagine, you'll be better off as someone who feels at home with the screen. So I suggest you to resist this temptation and do what you ultimately will do.
Out of curiosity, Is your job/situation/skills in a way that being good with screen will not seriously benefit you? How?
You’re right that you lose a lot of tooling on paper. But you can always have your laptop alongside the packet. No need for either/or. Plus, I have found that I retain things better when they’re printed out. I also like to mark up documents in pen. At the end of the day, it’s just a preference thing. And paper might actually work for the use case of just trying to understand a library; the code is static in that situation.
https://marketplace.visualstudio.com/items?itemName=nobuhito...
I think it is a good idea to print it out to help you understand. I consider it on occasion but don't want to pay for the ink and paper. Plus printers have some unspoken vendetta against me...they hate me and I hate them.