Hacker News new | past | comments | ask | show | jobs | submit login
How to write a programming book (aquicarattino.com)
166 points by aqui_c on May 23, 2020 | hide | past | favorite | 68 comments



What pains me about programming books is that due to the market pressure the balance is skewed extremely in the direction of beginner material and there is precious little material for advanced users.

If you look at other branches of knowledge, say electronics, there is couple of books for beginners and then massive selection of highly specialized books for experts.

I get that part of this is due to multitude of languages, paradigms, frameworks, etc. but I suspect that a huge part is due to the fact that programming book writers have huge incentive to make the book palatable to absolute beginners and anything else seems to be a sure way for the project to tank.


Another thing that bothers me is that most intermediary books on a topic tend to start with a good chunk of beginner stuff. For example, many game programming books will cover a ton of beginner material at the start, same with graphics books or books on a particular programming language. I shudder to think of how much duplicated content that I will never read because I'm no longer a beginner is sitting in my bookshelf. If I buy an intermediary or advanced book, I don't need a recap giving me the absolute basics! Eg if its an intermediate-level programming language book, don't tell me how to do simple conditionals or loops or something that I definitely already know to consider an intermediate-level book...


This is why I look for gems like Professional Javascript for Web Developers[0][1]. (I can't speak to the latest version, I think I read the 3rd edition from 2012.)

It's a book about Javascript that assumes you've written software in other languages before. I believe the book uses Java/C#, Python, and maybe a couple other languages as reference points.

It describes language behavior and constructs that may be new to you, and details where the familiar may differ from what you'd expect. For instance, the section on `var` and how function scoping (and hoisting) differ from block scoping was quite detailed, but I don't remember it spending a lot of time on what it meant to declare a variable or why scoping rules matter.

If the book had a beginner focus I might have seen the section on declaring variables, skimmed to see the `var` keyword, and skipped the rest. Then I'd have written a bunch of code that would bite me later, because why would you ever assume function scoping when coming from another language?

It's unfortunate that it's so difficult to find books with either an intermediate to advanced focus, or a focus on switching languages, as I think both are sorely needed in the current programming ecosystem.

[0]: https://www.wiley.com/en-us/Professional+JavaScript+for+Web+...

[1]: https://www.amazon.com/Professional-JavaScript-Developers-Ma...


Author of the 4th edition here!

Much credit goes to the author of previous editions, Nicholas Zakas, for dictating the style. He offered this advice when I began the new edition:

I tried to make it a book that had a distinctive approach, which is that it didn't treat the reader with kid gloves and went deep into technical details to people could really understand the language. This, more than anything else, is what people have told me they enjoyed about the book. It was unapologetically not for beginners.

More than anything else, this advice is what guided me in preserving the original style in the new edition.


Fluent Python sounds like the same thing. It assumes experience in another language and having done the official Python tutorial.


Thanks, I'll have to check it out. I've definitely dabbled in Python but I would like to learn it properly.


There was a commenter here on HN (if my Google-fu serves me, I'll come back and edit with a link) talking about this problem wrt contracted educational services. Folks request intermediate to advanced training. The trainer shows up, finds out that everyone is actually a beginner with this particular technology, and has to adapt the course appropriately.

That's pretty good customer service, but it's not something you can get with a book. I suspect "intermediate" books with a "beginner" start are attempting to address this problem and head off the terrible reviews. Perhaps it's an ego thing with software engineers. "I'm no idiot, so I'm intermediate," "I've been doing software for decades so I'm advanced," and not realizing that it's about your experience with this technology, not your brain.


Okay, so you propose all books should be written for noobs just in case noob picks up something for already advanced user?

That just doesn't make any sense.

Obviously, the author of the book can explain the book is really meant for a user with some prior knowledge and experience of the matter. If the reader ignores it it's not really a problem of the author to deal with.

My background is mathematics and, as an example, just recently wanted to pick up some control theory. It is absolutely normal I pick up a book I have not enough knowledge to even start reading. It is normal. You get something else, study it, then go back to the one you tried to understand.


Agreed. The one thing the Internet surely did was enable self-starters to have their fill of the entirety of human knowledge. But you have to have determination and patience. Some things might not make sense the first time you read them. I come back to things that I’ve already read time and time again, and get new insights out of them each time.

“Oh!!! That’s what they meant here!!!”

I say this once a month with something I’ve read 50 times. We need to reward people for having determination, not make every single book beginner friendly at the expense of deep material. We’re doing the world a huge disservice by limiting the potential of what people could be sharing.


This is the exact problem that I am working on with my project https://fromtoschool.com. Where we write books and create courses that teach new programming languages and frameworks to experienced developers, using the languages and frameworks that you already know.

The style we use to teach is optimized for speed of learning and teaches this way using the 'constructivist' method. I expand on this learning style, and why it is so effective more in this post: https://fromtoschool.com/why-most-programming-tutorials-are-....


Your post in https://fromtoschool.com/why-most-programming-tutorials-are-... has links at the bottom to books and courses -- both point to https://fromtoschool.com/courses which gives me: page not found.


Yep, the first book "From jQuery To VueJS" is still in the works. I'll be updating the pages to reflect the coming soon status of the book tomorrow!

But if interested you can leave your email address on the form at the bottom of the post.


As someone who writes programming stuff, yes this! I avoid complete beginners and aim for junior to mid.

The problem is that this is still a crazy fast growing field. Say we double in number every 5 to 10 years. That means at 5 years experience you are more experienced than half the industry.

That’s mindboggling.

Newbies also need more help and are more willing to pay for help.

Oldbies only pay for help when entering a new area. Like a fortran engineer picking up React or a JS person getting into C++

One problem is that software engineering doesn’t quite value experience yet. Easier to throw 3 newbies at a problem than 1 senior who’s never seen this new tech anyway.

The other issue is that engineers are smart and motivated by problem solving. They’d rather figure it out themselves than take all the fun out by just learning it like a normal person and reaping the rewards.

Also advanced stuff often gets so in the weeds that only you and 50 of your friends in the whole world even care. Or it’s so specific to your company tht only other people at your company care.


That is why there is a small time window for smallish niches, like Elixir, Clojure or Rust. One has to have their eye one fashion, the crowds, the knowledge gap and the perceived utility.

I personally wouldn't wanting to be competing with all the other beginner material and sufficiently advanced material would take forever to produce.

But if there was a 100 page book on writing an Elixir/Phoenix app and deploying it on K8s across 4 cloud providers, using a CDN and Aerospike, I'd pay 50$ for that.


> I'd pay 50$ for that.

That’s the other problem. The thing you just described is worth 6-figures when sold as a consulting deal. Why do you expect to pay just $50 for the book version?


Exactly, which is why the expert information is teased out in a couple in depth blog posts.

https://www.michael-noll.com/projects/

Does a very good job in this regard. I think if you have a consulting agency where you can train or lead on multiple projects, then a book could be a very good sales vehicle.


I remember reading a comment on why there's a shortage of very advanced books in databases,where the author argued that anyone who know his stuff at that level is more likely to keep it to himself, because there's tons of money to be made+ lots if proprietary stuff nobody wants to be open about.


What advanced material are you looking for?

A lot of research papers can be found online for free. What problem are you trying to solve that you feel would be helped by advanced material not found in research papers and/or computer science textbooks?

For me, the problems I've encountered that I thought were problems of lack of advanced learning material, have turned out to be problems of absence of tooling, libraries, frameworks and the will to create them.

In my particular case - I became an iOS developer and found out we're still paying people 100k+ to manually create trivial phone apps that fetch trivial database queries via json and display them in rather trivial ways on screens.

You wouldn't believe the number of people working on any given banking app that lets you display your past transactions and transfer money in-between accounts - it's basically a folder/file viewer with pre-defined file types and a couple of pre-defined actions for each. We've had folders, files and transactions to ensure correctness for decades! People are still re-creating these features!

Why do we have separate banking apps that do the exact same thing and why does displaying text fetched from a database and letting you modify it in the most trivial way, a job that pays 100k+ while producing bug ridden code?

There is no book to solve this problem and I believe most of the people employed in software development are churning out or maintaining this type of code. As a result, the market for advanced techniques in computer science is incredibly tiny - if you removed the idiotic whiteboard waterboarding techniques, academia and R&D at big corporations, you'd find out that there is maybe a few thousand people world-wide who are genuinely interested in putting advanced computer science to use.

I'd say this hypothesis explains why we don't have any actual progress in the field, just more javascript frameworks (simplifying, of course ) :) It doesn't explain very well what those billions of dollars in R&D at big corps are accomplishing besides removing ports from laptops and coming up with new keyboard mechanisms that fail when dust falls on them (lol) - maybe we're one day away from a quantum computer that changes everything? I have my doubts :)


> you'd find out that there is maybe a few thousand people world-wide who are genuinely interested in putting advanced computer science to use.

Nah, there are lots of people writing big complex programs with big complex architecture. Architecting programs isn't an "advanced compsci topic", but there are lots and lots of books that don't really talk much about it. Instead they show you how to use your programming language's (or framerwork's, database's, etc.) primitives in a basic way. That's pretty much the things you could just look up in a reference manual. Then you figure out the hard stuff yourself.

They tell me how to hold this bundle of hammer and nails, but I need to figure out how to design a skyscraper with them..


If you haven't read them yet, Design Patterns, The Pragmatic Programmer, and Code Complete, will all help you.


I've glanced at design patterns, but like most programming books, it bored me to death.

To me it reads like "now that you know how to hold this clumsy 90s OOP hammer, here's how to swing it". That's a far cry from architecting systems, and not a particularly motivating read for someone who's really not into that flavor of OOP (or much OOP at all).


I'm trying to think of a tactful way to phrase this, but let me just say it: If you're only willing to learn things that are in convenient, fun-to-consume packages, you'll miss out on a lot of the world's wisdom.

There are a lot of experts who have profoundly deep skills, but don't happen to write in your personally preferred writing style. Do you want that to get in the way of you learning from them? If not, you gotta meet them halfway.

I've learned a lot from well-written books. I've also learned a lot from frankly poorly-written books. Mastery takes work.


On the other hand, life is short, time is finite, and there's more to read and do and learn than any one person can do in a lifetime.

Time and time again I read things only to regret it later because I didn't get my time's worth out of it and probably could've spent that time on something more useful.

It's less a question of style and more a question of content. Do I feel like I'm learning something insightful or important? If not, I start to get bored. If it's a book people recommend a lot, I force myself to keep reading, and tend to get more and more bored. I might or might finish, but in the end I usually regret it. It's very rare for a book that doesn't start out well to do a U-turn and get good towards the end.


You make a valid point, and if you're reading fiction for pleasure then your own judgement of the experience is really the only thing that matters. However, if you're reading technical material with the aim of improving your skills, how can you tell whether you are learning something insightful or important?

A classic problem, and the reason that some questionable authors with unreliable content are nevertheless among the most popular in their field, is that the student of a technical subject is by definition never going to be qualified to evaluate tutorial material aimed at their current level. We all rely on the opinions of those more skilled or experienced than ourselves to guide us, at least until we reach a level where there are no more tutorials and instead we're learning from our own experiences including original research and discussions with peers.

In the case of Design Patterns specifically, if you're not into the kind of OOP where those patterns apply then it will have much less value to you. However, I'd say anyone who is working in a language like Java, C++ or C# should have at least passing familiarity with the patterns within and their names, if only to recognise the concepts and key details when they come up in discussion with fellow developers or get mentioned in code or documentation. Some of the ideas behind those patterns are relevant in non-OOP contexts as well, but in other programming styles they are often expressed very differently, which is why I say the book would have much less (but not necessarily zero) value to someone whose interests lie away from class-based OOP.


Those are all intermediate/improver kind of books, though. They contain a lot of useful material, and many programmers who haven't studied those subjects would benefit from doing so. However, the ideas would (should) be familiar to any professional programmer with more than a few years of experience. The challenge is where you go after that to continue developing your skills and broadening your experience for the next 5 or 10 or 20 years, rather than becoming the "eternal novice" who is proficient with the basic tools but unaware of more advanced idioms or more strategic issues that would help them to produce much better work.


I suspect that, in many cases, books are most useful for people starting out because they don't know what they don't know and don't know what they really should know. Once you're more experienced, you probably care about deep dives in specific areas that may not even be of much general interest and may be very recent. And those are probably less amenable to books.


Generally speaking, books as a format make no sense. I have seen the financial records for number of popular tech book authors — and numbers related to them having published, for example: products, services, consulting & speaker fees, etc. If the author is trying, they make way more money from the numbers related to them publishing than the book sales.

If you like writing long form tech guides, do yourself and your audience a favor, figure out how to publish your materials for free digitally and grow an audience you have direct one-on-one access to, then allow people to order paper versions if that’s what they prefer.

Then, writing a book becomes easy: grow audience, provide an outline, get feedback, write more, write testable code, get more feedback, etc.

Anything you write (as in subsection) should have a timestamp of when it was: written, rewritten, last reviewed, test, environment tested, etc.


> Generally speaking, books as a format make no sense.

This is such a silly assertion. Books have been one of the most effective ways for an informed author to get large, complex topics and rich experiences into a another persons head literally since the Roman Empire.

Even in today's world where we have an infinite number of other formats and media to choose from, millions of people still prefer and learn from books. The ability to encode spoken language into a series of written words that can be consumed at a pace the reader controls is one of the most powerful technologies humans have ever invented. And an author taking the time to organize an entire body of work into a single coherent linear narrative is one of the most effective tools to move information across brains.

> I have seen the financial records for number of popular tech book authors

I think what you're trying to say is that conventional tech publishers make no sense economically, and I am inclined to agree with that. The idea that an author can do 90% of the work and get 10% of the royalties is just bananas to me. That kind of royalty sharing only made sense in a time when publishers formed a hermetically sealed cartel preventing independent authors from easily accessing bookshelves. Those days are thankfully over.

It is possible to make decent money from writing technical books if you self publish and build an audience yourself.


>> “conventional tech publishers make no sense economically” [...] “It is possible to make decent money from writing technical books if you self publish and build an audience yourself.“

Do you have an example of an author doing this? (Meaning all they do is self-publish books and have disclosed financials.)


Yes, me.

My self-published book "Game Programming Patterns" has made me a lot more money every year for the past six years than I ever expected. It's not enough to live off of, at least not in an expensive city while raising a family, but it's nothing to scoff at either. I could probably make quite a bit more if I put time into marketing, supplementary materials, etc. As it is now, I just let the checks from Amazon etc. roll in and treat it as a nice bonus to my day job income.

If I lived somewhere cheaper, wrote full time, and made some adjustments in my lifestyle, I could probably get by on just my writing.


First, congratulations, thanks for publishing, thanks for sharing your experience!

Second, yes, maybe I was not clear, my advice relates to the average author on a simple straightforward method of write a book that reduces the odds of it not being of use of the audience it seeks.

Lastly, might be wrong, but it appears:

(A) at least on Amazon, your book appears to be rank in the top 20,000 of all books;

(B) you appear to have published a singular book;

(C) as you say, yourself, it does not make enough for someone to live in a major city;

(D) writing books is not your primary means of income;

—- to me, what I hearing does not conflict at all with my analysis and your example, to me is survivor bias: https://en.m.wikipedia.org/wiki/Survivorship_bias

——

Writing multiple best selling books year after year is VERY hard to do as a means of income. There are much easier ways to earn an income and share what you know. If someone wants to do that, awesome, though I do not have advice for doing that, nor do I know of anyone else that does; that would result in publishing 1+ successful books a year. My advice is just no nonsense take on being reducing odds of book being useful, which for the average author is much more of a challenge.


All of that is true, but it's also worth balancing that with the fact that when I was writing that book, I was only spending about an hour a day on it, and now I spend zero hours a day. The long tail of passive income seems to be pretty long so far.

You're right that it will be hard for many people to make a living solely off writing technical books. But I also think it's true that you can make more money that most people realize just by not giving a traditional publisher a huge cut of it. Maybe not enough to live on, but likely enough to make it worth your while.


If you go for free and online anyways, then you can pursue more interesting formats like Quantum Country [0]. It seems to include a spaced repetition mechanism. I have yet to try it though.

[0] https://quantum.country/


Love the idea of a book based on spaces repetition, but wish they had a better way to get a sense of what you’re getting yourself into, since as far as I am able to tell there’s no:

- estimate of reading time - level of knowledge - way to link deeper content


I love buying pre-releas books from Prag Prog (which isn't exactly the same but similar to what you described). Especially since things change so fast, if you have to wait for a finalized, published version of the book, it's usually outdated by the time it even hits the shelves (not entirely of course, but parts of it). If the author(s) publish pre-releases frequently, it can be a fantastic reference.


Preselling good, since sending cash is a lot better signal of interest than handing over email, SMS, etc.

That said, you would need to have a quantifiable definition of done and likely be a good idea to account for absolute failure in case something comes up an “done” is never accomplished. Until it is “done” likely be good idea to escrow the funds, but then you run into issue like paying taxes, transaction fees, etc.


Agreed, escrowing is a great idea. In the case of the books I bought they were by very prominent people so I had high confidence they would be completed. For less-known authors tho, you make a great point.


This is relevant to me because I'll likely be teaching Linear Algebra online in the Fall. I'm rethinking support materials from scratch. This article does not rethink its genre from scratch. And I nearly stopped reading, unwilling to take advice from a fixed pitch body font.

I've learned dozens of programming languages, and I find programming books increasingly unreadable. They all give me that feeling of ADHD that actual programming heals.

I've also made progress learning various human languages. No single approach works. Doing crosswords in old age doesn't fight off dementia but does make one better at doing crosswords. For language aquisition, read with the sole goal of getting better at reading. Listen with the sole goal of getting better at listening. Repeat phrases in the car as if that's a self-contained game one plays. Then trust that these separate skills will integrate as one travels; they do.

For anyone who has learned the board game of Go, it's interesting how books on Go are compartmentalized. There are books solely dedicated to short timescale tactics, for example.

After a few programming languages, one can easily absorb the "short timescale tactics" of a programming language, and still be at a loss on idiomatic ways to assemble complete programs. Just as the best mathematicans only read original literature, the best programmers simply read code. A programming book can ease the transition to reading code. We should be clear that this is our primary goal.

One experiences a more intense sensation of comprehension, reading and understanding how a short complete program works, than reading any neverending text that ambles on. Take a cue from human language aquisition: Programming books should deliver a sequence of "aha!" moments of comprehension, teaching language constructs through explanations of a sequence of cleanly separated short complete programs. Their success should be measured in terms of the enjoyability and intensity of the experience of reading code this way. Leave it to the reader to find other ways to put together the rest.


Good luck with the LA book. It is a beautiful subject with so many applications, so a great opportunity to do an original take on it.

In case this is might be helpful, here is a preview of the LA book I wrote[1] and the condensed four-page-in-small-font tutorial version[2]. You might also consider using a computer algebra system for teaching, see [3] for my take on LA using SymPy. Last but not least, I highly recommend the CMapTools software for creating concept maps, which can really summarize the field in a very compact form[4].

[1] https://minireference.com/static/excerpts/noBSguide2LA_previ...

[2] https://minireference.com/static/tutorials/linear_algebra_in...

[3] https://github.com/minireference/noBSLAnotebooks#no-bullshit...

[4] https://minireference.com/static/tutorials/conceptmap.pdf


I would be interested in what materials you come up with, and what resources you are looking at to make your course up. Syllabus.


I found this quite insightful. Thank you.


One thing that is constantly left out of books is challenging problems with solutions for the user to cement the new ideas they’ve learned in actual examples. It’s very easy to read along and nod your head but it’s very hard (at least for me) to incorporate my new skills without memorable hands on examples.


As a reader, what I do is make up my own challenges. Do I feel comfortable modifying the code and knowing it will still run error-free?


I do the same when learning a new concept, find a little way to apply it by slightly to heavy modifying the original code until it clicks. I save those to a folder I can reference sometime in the future. I’ve been doing this for a really long time and it works well for me.


Gee, write a program using what you just learnt and see if it works. You want someone to tell you what program to write?! I assume it's a book for kids, or a school textbook, when I see exercises like that. I don't understand the demand that books not only tell you things, but tell you how to learn everything in them too.

Apologies, I really tried to make this not sound condescending!


The expert you're learning from probably has a better idea than you do of what programs you should write given (a) your presumed knowledge level and (b) what programs would help you learn the fastest and/or the most relevant features. Including good exercises is an extension of the purpose of the book itself.


Maybe, but they know nothing about (a) why you're reading the book, (b) what you know/don't know already, (c) your learning style, (d) your speed of learning etc.


I think the article is really general advice about (tech) writing, not about writing a programming book. There is very little if anything specific to programming itself, e.g. e.g. the types of code fragments you should use as examples.

Also, apart from the line:

> You can always ask feedback from people you trust to gain confidence

there is no mention of getting someone to proofread or even copy edit the book. This would also seem really important for a programming book - e.g. to check that the examples work away from the author's dev environment.


>there is no mention of getting someone to proofread or even copy edit the book. This would also seem really important for a programming book - e.g. to check that the examples work away from the author's dev environment.

You're actually talking two different things.

Someone needs to proofread/copyedit the book. Full stop. And, unless you have a partner or particularly close friend who will/can do a careful edit for you for a case of beer and a pizza, you're going to have to pay someone.

For a programming book (or other types of technical books), you probably need a technical reviewer. If it's just a sanity check for technical accuracy, colleagues etc. can probably do that. But to work through all the code in a book, again, someone will probably have to get paid.


This is a much more useful comment than the OP.

Books need review - not just a few comments on the general concept, but line by line proofreading of the English, and fact checking of every single technical statement.

This is fundamental to the process. It's not an aspiration, it's part of the writing process - because often you'll be writing content while other content is being reviewed, and feedback from both can influence the rest.


Indeed, there's no remark about it because I wanted to split the act of writing from the publishing of the book. The sentence on asking feedback was geared towards checking the ideas, having an overview of what you've written by someone else (which is not the same than proofreading).

All what you mention as missing, is part of my current ongoing process, and I still haven't learned nor tested enough as to summarize it.


Fair points.

I hope the process goes well! Doing what you are doing is really difficult and I have lots of respect for those who try!


> "If you ever start the path of writing a book, you should ask yourself why you are doing it."

I've wanted to create a short video series for my workplace, but I'm stuck on what the approach and theme should be.

The series would be about automotive assembly, and I have a lot of things to talk about, but I keep getting stuck on what people would be interested in and what would be helpful.


Start with a round table, provide a space so that people open up about what they find confusing, try to map out the knowledge gaps.

Is this about design for manufacturing from an assembly standpoint? Would it also cover repair? The spark plugs on a VR6 are inaccessible, can you fix that?


It's about IT for Mfg, so kind of broad. Sorry about the spark plugs. Packaging is a bitch.


"...in 24 hours"


This would be interesting if I could read it. Would it be possible to display text without enabling JS?

I have read several IT books recently and they aren't good. Basic stuff like visibility of diagrams, presenting advanced subject matter but also supposedly in a way that will teach you programming, or having pages of code to illustrate something trivial.


Someone needs to make a Hacker News bingo card. "Doesn't work with JS disabled" would definitely be on there.


Along with "you need JS for the modern web"


"it's just text and images"


I'm working on that. I just used a stock template for the website.


Cheers! Much appreciated. :-)


The low contrast text is also really hard to read.


> Would it be possible to display text without enabling JS?

No, because then how would it set up pullquotes like "If you don't set a baseline somewhere, you risk starting a book that grows backward" that you can tweet at the push of a button? (Is that really a thing? I guess it must be somewhere, but it's new to me on a (I guess) programmer's blog.)


You can't actually send a tweet at the push of a button (unless you're connected with twitter oauth with the right permissions), but what you can do (and that button does) is opens the tweet composer pre-filled with the quote, ready for you to then just hit "Tweet"


I used to do that on my blog. Example: http://beza1e1.tuxen.de/team_building.html

Stopped doing it as I got negative feedback about it being annoying. I never tracked how many tweets I get out of it though. So if you aim for popularity (unlike me) it might still be worth it.

It was one of the big reasons I used RestructuredText as markup language for my static website generator. It is extensible enough to make these tweet-blocks with just:

    .. tweetable :: Psychological Safety is THE core factor for Great Teams says Google


They are just links to Twitter, no JS involved on those fragments.


Yeah, I'm getting pretty sick of sites that want to run JS to show static content.




Applications are open for YC Summer 2023

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: