Live data from Hacker News

Programming book authors: put all the code in the book

logicgrimoire.wordpress.com

41–50 of 83 posts

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

#41
post #6

Was it just me, or did anyone else read the "TL;DR" explaining how to AVOID the antipattern to BE the antipattern?

No? It's in the imperative voice, it wouldn't make sense to read "do this" as a description of an antipattern.

Why not? A TL;DR is a summation of the article. The title tells what the article's about.

So just reading the title and the tl;dr would leave one with no actual idea of the antipattern. What if the article was about something for which the imperative voice was an accurate description?

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

#42
post #22

Two things come to (my) mind. First, if the problem is broken URLs, does it make sense to try to fix that instead of not using them? Some odd blog is likely to (eventually) become ephemeral. What about Github links? How long will they last? That seems particularly appropriate for posting code examples. Are there other repositories on the Internet that can reasonably be expected to last? Second, extremes in either dir…

> 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 ...

Good point.

> Python code has an average shelf life of four years.

Wouldn't that also be a problem for examples in print?

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

#43
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.

If programming books still came with CDs (or USB drives), we’d be reading blog posts complaining about that. I can see the comments now: “Just put it on GitHub! Why do they put it on something physical that I’m just going to lose!?” Retailers loathe books with extras (CDs, USB, or otherwise) because the rate of issues and problems with returns goes way up. Customers dislike it because they’ll lose the thing. Just put…

Linux Format quit shipping CDs with the magazine, oh, about a year ago, maybe. I think some of it is also "shrinkage" (the term in retail in the U.S. for shoplifting + breakage, etc). I liked the CDs for many reasons, one of which was once you open a browser...off you go. However, there are still people in the world who may want to learn but have rate-limited, firewalled, or dodgy Internet. It's like cashless systems that cut out millions of people. [1]

I don't see why it would be a problem with items mailed, except it would add another step for the publisher or distributor. But along those lines it irks me when I subscribe to a print publication that includes digital and after I login the only benefit I get it to read more stuff on the same tracker-loaded, privacy-invading enshitified site.

[1] During COVID I protested vigorously at my church about going virtual for many reasons. One of which was elderly or impoverished members who could not (because of either access or ability) easily access whichever platform was being used. There are so many variations of "works on my system" in the world.

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

#44
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.

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

#45
post #29

Bring back the 90's antipattern of making the book so thick you use it as a monitor stand.

I don't think I'd call that an antipattern, tbh. Lots of things did this - I remember our CIO bought us all fancy IDE thingies back in the early J2EE days; I forget what it was, JBuilder, maybe?

Everyone was using Eclipse (or us greybeards sticking to our emacs and ((neo)v)im, by then so we ALL used them as monitor stands.

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

#47
post #15

Earlier quoted context omitted.

Is it feasible to attach a usb drive to a book these days?

A cheap USB drive sells for under $10 and you can seal a book in plastic so I'd imagine it'd be feasible to just add the $5-$10 to the price of the book. People who buy books, especially programming books, generally aren't very price sensitive anyway.

Can we attach an attack vector to the book cover? Sure. I wouldn't let that USB anywhere near my computer if I'd bought it let alone a library copy of it.

I'm with the author on this one. Any code needed to for it be useful should be printed in the book (perhaps complete code in an appendix rather than right there in the chapter). That said I haven't bought a programming book in years.

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

#48
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.

Is it feasible to attach a usb drive to a book these days?

yes but it would add two or three dollars to the retail price https://www.usbcompany.co.uk/usb-credit-cards/

https://www.vistaprint.com/promotional-products/technology/u...

https://www.instructables.com/USB-PCB-Business-Card/

https://hackaday.com/2010/05/25/mass-storage-business-card/

cds are a lot cheaper

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

#49
post #37

Maybe QR codes, containing the code in plain text, in an appendix? That would ensure easy access to the code on devices outside of the printed book.

you will probably want to use https://github.com/za3k/qr-backup

with safe settings it gets about 3 kilobytes per page; at 130 kilobytes per page read success rates are nonzero

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

#50
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…

this is a fully general criticism of printing anything in a book; it's not an argument against printing code in books, but against books themselves
Post reply on HN