According to computer scientist Donald Knuth, someone who has written numerous books, writing software is more difficult than writing books.
The most important lesson I learned during the past nine years [1977 – 1986, when Knuth developed TeX] is that software is hard; and it takes a long time. From now on I shall have significantly greater respect for every successful software tool that I encounter. …
The amount of technical detail in a large system is one thing that makes programming more demanding than book-writing. Another is that programming demands a significantly higher standard of accuracy. Programs don’t simply have to make sense to another human being, they must make sense to a computer.
Emphasis in the original. Taken from Selected Papers on Computer Science. In another paper in the same collection Knuth says
I was surprised to learn that the writing of programs for TeX and for METAFONT proved to be much more difficult than all the other things I had done (like proving theorems and writing books).