Peter - loved the writeup. After being in the technical education industry for so long, I know that no one writes "just one book" and makes money but it's good to show people in such an easy to understand way (like you did).

There were a few things that I had questions on - since you are answering here at HN, I'll try you here!

You mentioned, "I’d argue that unless you’re writing a very niche book (that’s unlikely to earn back its advance) ..., you should avoid the major publishers and instead find a mid-sized publisher that can offer more attractive royalties..." It has been my experience that, "the bigger the publisher, the bigger the advance" and/or "the smaller the royalty, the bigger the advance". When I think of this conundrum, I always think back to, "Why is this author writing this 'very niche book' - what is their motivation?" If it is money, then I would suggest they perhaps follow your advice and go with whoever gives them the biggest advance (and just forget about negotiating royalties since they are 'unlikely to earn back' in your words). However money is often not the major motivator as you mentioned.

For example, if the motivator was, "I want to increase my profile so that I can speak at big events and raise my consulting rates", they are probably better off going with a bigger company who can flood the market with marketing instead of a small/mid-sized company. Sure they'll give up royalties but they will receive what they want. Small and medium-sized publishers will generally not have the resources and expertise to perform those same functions at the scale a big publishing house can do them.

Also, I would ask the author, "What is success to you for this book?" Some will say, "I want it to sell a bunch of copies because of x, y, and z" then they won't be as likely to do that with most small/mid publishers. Your case of selling 8500 copies through Apress vs. 2000 through Pragmatic Programmer is important since some might perceive that the book was a failure because it "only" sold 2,000 copies. And those "some people" might include potential employers, industry colleagues or the author. It also does not take into account the perceived prestige someone might feel with being accepted to be an Apress author vs. a PP author (again "some people" might have never heard of PP books and so it might not have the same weight).

The final bit I'd say is that negotiating the best possible advance + royalty rate for yourself may not always be the wisest thing to do long term. Example: Let's say that you went with PP and had written "Beginning Ruby" and it was a moderate success selling 2,000 copies over at PP. Apress starts to take notice and they hire someone to write the Beginning Ruby book for them and they market the shit out of it. What do you do now? You l-o-s-e, that's what. PP can't afford to market your book - they don't have any budget left after your 50% royalty and paying their staff - so you are SOL. Your "greed" (and I don't mean "you" as in Peter Cooper; I mean the collective "you") let you miss out on an opportunity: the opportunity to write a beginner-level non-time-specific book (which generally outsell more advanced titles or, as you say, time-specific titles) for a major publisher that will sell for 10-20 years (or as long as (a) the language is popular, and (b) you create new editions). You opted for a small, short-term payday with instead of the potential longer-term success which, yes will have certain confines that aren't ideal, but would be more predictable and more stable. Trust me: although major publishers may not be cutting edge with their titles/technologies, they are paying attention to the small/mid-sized markets. Once something becomes popular, the big guys will emulate it.

Full disclosure: I am the founder of a small publisher (http://www.learnitfirst.com/) albeit in the ebook and video markets exclusively. I know that it sounds like I'm arguing for Apress but I'm not - just a different point of view, I suppose.