Programming a piece of software is very similar to writing a book. You're just telling a computer what to do in a somewhat unusual language. So software development, in my opinion, is neither science nor engineering, it's art.
What kind of book? A math book? biography? romance fiction? In that respect, programming is also like cooking. For cooking, you can go from one extreme of food science, like NASA practices for food going up in space, to popping a frozen pizza into the oven, to many points in between. Programming allows a wide range of discipline to be executed in the process.
Software is a logical construction. It is a structure of parts that have determinate behaviours, put together to serve a particular purpose. It realises intent by assembling objective materials. When you build software you are building a machine. This is pretty much nothing like writing a book.
The only rationale you give is to imply both activities are telling something what to do. But does this stand up? When you write a book, are you 'telling' the book 'what to do'? No. Or maybe telling the person reading it what to do? In which case, are you expecting them to behave exactly according to your 'instructions'? No, not really.
Literature and software are two very different things.
That entirely depends on the purpose of the software that's being written.
If you're writing, say, the Amiga Boing Ball demo, or Dali Clock, you might be leaning more towards art.
But if you're writing software that controls transactions for a bank, you're definitely more an engineer.
What does it matter anyway? In my rather short career so far, I've been an artist and an engineer, a scientist and a craftsman. Sometimes all in the same day.
The process of science and engineering is art too. They both are "writing books" in their own way. Engineers write bridges, electrical circuits, environmentally friendly housing, etc. Scientists write new paradigms to understand the world with.