Writing a sample chapter for a possible programming book was quite eye-opening. I’ve never done any serious non-fiction writing other than a magazine article. Writing a programming book is considered non-fiction just as a humor book is.
I find the classification funny. “Fiction” is defined as everything not-made-up. It can be anything from a story about a crime in your town to space battles. Non-fiction is everything else.
In the sample chapter I realized there was as much fiction as truth. I was making up a story about the code I was writing. I could take the story in direction and provide the code to go along with it. I’m not trying to solve an “out in the world” problem. I’m just telling a story, illustrated with code. If someone learns from it, even better.