That depends very strongly on the publisher, and if you go with one of the industry leaders than it can be a very useful decision to go the traditional publishing route.
No Starch and Manning are both excellent publishers with fantastic teams. You'll get lots of attention from experienced editors, teams of talented people assisting you throughout that process, and very nice distribution channels. I've known many authors that have worked with these publishers and none of them have regretted it.
If you purely care about the money, then I think self publishing for a niche audience is probably the best route, though you have to put some extra energy into marketing. The math just works out that much higher royalties on a smaller audience means more direct income.
But if you want to make a really excellent book, and would like to be able to walk in to a Barnes and Noble and see it on the shelf, then going with an experienced, quality publisher can make a notable difference.
They also changed the terms of payment at some point. I used to get quarterly royalties via Paypal, but they wanted to switch to European bank transfer or something. That is impossible for people based in the US, and they just didn't seem to understand that. It sounds like something I could have sued them over, but the book was definitely past its prime at that point, so I just said "remove my name from the book and don't contact me" and that has worked out pretty well so far. (I think someone else did a second edition. Good for them!)
It was nice to be forced to write an entire book. I signed a contract, got an advance, and delivered it. Today's me would just tell users "read the source code if you have questions", but a book length tutorial was probably good for the project in general.
If you have the mental energy to write an entire book without anyone pushing you to complete it, I think you'll enjoy the enhanced control that you get by self-publishing. Collecting money for PDFs is a solved problem, and honestly, PDFs are a lot more useful than printed books anyway. It is always "neat" to show people a printed book that you wrote, but I'm not really sure that's worth the downsides. I buy programming books, but I haven't gotten a printed copy in years. They just live on my computer, where I'm actually doing the programming.
I think my conclusion is -- don't write a book unless you really want to write a book. Nobody but your parents are going to care that your book is in a bookstore. No software engineering interviewer is going to let you skip the interview because you wrote a book. The only reason you should do it is because you want to share your knowledge with the world. That is a valuable pursuit, but you will be undercompensated for it.
(Fun story... many years ago, a Google recruiter reached out to me with a little survey; rate yourself from 1-10 in these categories. They said 10 was "literally wrote a book on this subject". I answered 10 for web frameworks, which I had in fact written a book on! They ghosted me. But I did end talking with another recruiter, and ended up working at Google for 6 years, so... I guess it worked out.)
I don’t agree that going with a publisher is a fool’s game. Yes, they take the majority of the income of the book, but most technical books don’t do all that well anyway. In return, they provide credibility and marketing support, as well as a certain amount of editing (depends on the publisher) and infrastructure support (ISBN, getting the book into stores, etc.)
For me, the credibility and marketing is more valuable than the money to be made. I spent a full year writing the new edition, close to full time, and I’ll likely never be paid what I’m worth for that time. But going with O’Reilly as my publisher means that a lot more people will hear about and read the book, and that’s a win to me.
Hmm... it seems to me that it would be better to have it in every marketplace. If someone's looking for a book on Amazon, you'll lose the sale entirely. 30% is better than 0%, yes?
While I may follow a link to gumroad or whatever from a blog post or something, I never go there if I'm just looking for a book on my own initiative. It's always Amazon. If your book isn't on Amazon, I likely won't even see it. Yes, that probably means I'm lazy. But I suspect I'm not the only one.
And he's right about publishers trying sleazy things. Another thing they may ask for is "All future rights in any medium". So people who signed this clause in 90's/early 2000s lost right of their ebook/audiobooks, which are the most profitable.
I would not go with a traditional publisher unless you can afford to hire a lawyer who specialises in copyright law (and not an English lit graduate, which is what most agents are).
Self publishing-- from my experience:
* Typesetting has never been a problem, but then I write general programming books, and Leanpub handles the conversion really well.
* I never found copyediting/proofreading very useful for programming books (though I do use them for my fiction). Readers care more about technical accuracy-- ie, does the code work, does the text and code match. are instructions clear etc. A good set of 1st readers is very useful here.
The best way to make money is to sell digital copies via leanpub/gumroad, as these sellers pay 80-90% royalty. Amazon will only pay you 30% if you price your book over $9.99, which let's be honest, most technical books will be.
Nathan Barry popularised the formula of selling the book for $39+, and extras for higher pricing, and that works the best.