The economics change completely if you self-publish or publish with a smaller firm that has marketing abilities (and better royalty rates).
Self publishing is awesome because you keep all the money, but it takes years to build an audience.
Honestly, writing the manuscript is the easy part. Building an audience, marketing it, keeping the book up-to-date is just as hard as the original manuscript. But it can really pay off.
I'm ready to share this now: our book on Angular 2 did $400k a revenue, per year, the first two years. BUT the reason this was possible was we had a huge audience that trusted us.
Email marketing is more powerful in this space than you might believe. Even today.
If I could give you one piece of advice, it would be to sign up for Ramit Sethi's emails and watch how he markets. After that, get every book on copywriting you can and learn how to write copy.
(Also, if you're interested in writing books with me for 50% royalties, my email is in my profile. I want to do books on Python and Node this year.)