Question: I have a few interests, and among them belong fiction, math and computer science, and so naturally I like to imagine/think about the possibility of a piece of fiction living in the intersection of these fields. I wonder, what does it mean to "code a novel"? Is there already such a thing as algorithmic fiction?

Answer: 
I used to be a coder, too (PHP, Ruby, Javascript, etc). But my main thing was design. And I used to have the same wish as you: I wanted to think of fiction writing as "designing" a story. But later on, I understood that, even though they share some similarities, they are different kind of thought processes. It was only when I accepted that that I figured out how to be a better writer.

So I don't think you can code or design a novel. You can only *write* a novel.
I find this an annoying question. You appear to have no idea, what you yourself mean by the words you use. You paste words together and then try to come up with a second-hand meaning for that undefined term. Code my nutrition. Sounds interesting. What could that mean?

Good thinking means you have an idea and you try to realize it, not you have a name and try to fill it with meaning.

Since "code" in relation to computation means "To put into the form required by a code" ([OED](http://www.oed.com/view/Entry/35581)), we can come up with the following answers to what your phrase might mean:

1. **Creation:** Software to create literary texts has been around for decades. The linguistic structures of text are well known, and programmers have developed algorithms that create artificial text (both prose and poetry) at least as early as the sixties. Google something like "computer generated writing", which will come up with interesting results such as this one: <http://singularityhub.com/2012/12/13/patented-book-writing-system-lets-one-professor-create-hundreds-of-thousands-of-amazon-books-and-counting/>.
2. **Analysis:** Computational analysis of literary text is equally old. The purpose is to discover text-linguistic structure and elements. See <http://en.wikipedia.org/wiki/Corpus_linguistics>