Live data from Hacker News

Programming book authors: put all the code in the book

logicgrimoire.wordpress.com

51–60 of 83 posts

Re: Programming book authors: put all the code in the book

#51

Earlier quoted context omitted.

> That seems particularly appropriate for posting code examples. Github is a proprietary, closed-source service that makes no promises about keeping things for a long time. And even if they do, at the time convenient for them, they'll send out an email titled "We are changing our ToS", and users will just accept it. Doing infra work for researches I encounter so much dead and dysfunctional content on Github, it's a m…

> Github is a proprietary, closed-source service that makes no promises about keeping things for a long time. GitHub doesn’t arbitrarily remove public repos for no reason. GitHub is extremely unlikely to just disappear overnight. If people aren’t willing to accept GitHub as a place to host public code in this thread, I think people are just looking for reasons to complain about things rather than looking for a practi…

geocities didn't arbitrarly remove public web pages for no reason, yahoo groups didn't arbitrarily remove public files for no reason, and friendster didn't arbitrarily remove public profiles for no reason

until, one day, they removed all of them

hosting information on a centralized website is a viable way to host it for a year or two, or maybe ten. but books have a lifespan measured in decades or centuries. so centralized websites are not suitable

Re: Programming book authors: put all the code in the book

#52
post #8

Just glue an envelope with a CD to the backcover, this is what people were doing before your fancy internets became a thing. But really, if you a writing a book on a modern language, and your code has external dependencies, chances are it will not build 5 years forward, even if there are no URLs directly in the book.

I still have some books on my shelf that include a floppy disk securely nestled in a pouch in the backcover.

Re: Programming book authors: put all the code in the book

#53
post #25

Bugs emerge. Tools change. How do you update code printed in a book? If a book can be written in such that it does not need to change, then by all means, carefully proof and test all the code and hard code it into the book. But that's simply feasible in many cases. Better a book with some external resources than no book at all? (Oh, and let's set aside the cases where the links to external resources are done in a hor…

Print code in the book, and have a URL you can check for errata. That's how it always used to be done, anyway.

Fine with me. (op would still object, though, because their issue is "The URLs always break. The libraries never load properly. A book should never depend on a URL")

Re: Programming book authors: put all the code in the book

#55
post #8

Just glue an envelope with a CD to the backcover, this is what people were doing before your fancy internets became a thing. But really, if you a writing a book on a modern language, and your code has external dependencies, chances are it will not build 5 years forward, even if there are no URLs directly in the book.

Those CDs never worked.

Re: Programming book authors: put all the code in the book

#56
post #17

The antipattern here is the physical book, surely?

Why? Literally everything in this article would apply to online books as well, except "type it in" would be "copy and paste"

How about distributing the "full" book as a docker image where you have both the source and compiled binaries (if relevant) of all the code samples in the book?

Re: Programming book authors: put all the code in the book

#57
post #21
post #8

Just glue an envelope with a CD to the backcover, this is what people were doing before your fancy internets became a thing. But really, if you a writing a book on a modern language, and your code has external dependencies, chances are it will not build 5 years forward, even if there are no URLs directly in the book.

How long do CDs and DVDs last, anyway?

I have a guitar instructional book that I've had more than 20 years, just checked out the CD the other day and it's still good. Also I've only mastered half of the exercises in the book so I'm still getting use out of it after all this time.

Re: Programming book authors: put all the code in the book

#59
post #8

Just glue an envelope with a CD to the backcover, this is what people were doing before your fancy internets became a thing. But really, if you a writing a book on a modern language, and your code has external dependencies, chances are it will not build 5 years forward, even if there are no URLs directly in the book.

It's 2024, books must also come as digital-only.

I agree that the obsolescence rate has skyrocketed, as a side-effect of always-online development.

Re: Programming book authors: put all the code in the book

#60

1. Print the source code in a micro-barcode in a physical appendix. 2. Make the first exercise in all books be to code a simple barcode image interpreter. And just include the walkthrough and source as typed text. You should be able to get a few MB on a page easily. Future proof as long as there are cameras on phones.

> You should be able to get a few MB on a page easily

A few hundred Kb, maybe, but a few MB seem unlikely. If I take the best case scenario (no optical aberration, perfect sensor...), my phone has a 48MP camera. We cannot have 48M * 3 colors as those 48MP are after Bayer matrix handling. We also cannot have more than one bit of information per pixel, due to printing often not having "real" greyscale but some kind of dithering and you don't know for sure how it would interact with your sensor. So in the best case, 6MB. But then, you need to add error correction: books prints are not perfect, especially at a sub-0.1mm scale. They are also not perfectly planar as paper is grainy. And the camera is not exactly at a 0 angle... In the 3 axis. So you would need to have the printed pixels be way larger than the sensor ones to be able to offset this. And so on.

Post reply on HN