Andy Weir is the author of the bestselling novels The Martian and Artemis. The Martian, which he wrote while working as a software engineer, was originally released as a free serial and later made into a film starring Matt Damon. Here’s how he paid the bills.

This interview has been edited and condensed for clarity.

Medium: Growing up, what did going to work look like to you?

Andy Weir: My dad was a linear accelerator physicist. He got electrons going really, really fast, then hit things with them to see what they’d do. My mother was an electrical engineer. For Dad, it was a passion, but for Mom, it was a paycheck. She didn’t really like it, but it paid well. My parents got divorced, and Mom wanted to do whatever would make her the most money so she could properly be a single mom. But once I left, she went off to other careers.

You studied computer science in college, but you also completed your first novel there. Were you taking writing classes?

I always wanted to be a writer, but I also like regular meals. When I got to college, I had already been programming computers for three years. I had been hired by Sandia National Labs as an assistant—basically a test tube cleaner—but they found out I was pretty good at computers, so they let me do a bunch of programming for them. I really enjoyed it. So, when deciding on a major, I said, “Well, I like computer programming, and I think it’s a much better career to go into in terms of financial security.” But I always wanted to be a writer, so while I was doing that, I was also writing a book. I wasn’t taking any creative writing classes. I wasn’t part of any writing group. And the book sucked, by the way. It was not The Martian. It lacked pretty much everything. It was the first pancake.

Did you graduate from college with a computer science degree?

I did not graduate. I ran out of money, and at the time — 1994 — the tech industry was blooming. Companies were desperate for engineers. They didn’t care if you had a college degree, if you were entry level, whatever. You could make decent money. I was like, “Well, I could either go deeply into debt to finish this degree, or I could start getting paid to do this job right now.”

What was your writing practice like at that time?

Around 1999, I’m living in Southern California and working for America Online. I wanted to get back into writing, so I started my second book, which is also not The Martian. Then I got laid off, because AOL merged with Netscape. These are such dated references now: AOL merged with Netscape, the Macarena was popular. Anyway, when they merged, I had these stock options that were worth a shitload of money. They said, “You have 60 days to exercise your options or they’ll disappear.” So I was forced to sell at what ended up being their all-time high. I assure you, left to my own devices, I would have held onto them, and they would have tanked a few months later when AOL merged with Time Warner. But circumstances conspired, and I ended up with a bunch of money. And I was like, “I can live for years on this without having to work. I’m gonna take a shot at being a full-time writer.”

I had friends that I hung out with during the day. Once they went home, I’d be up writing until 5:00 in the morning and then sleep in until 1:00 or 2:00 p.m.

When you said, “I can live for years,” did you mean “if I live on ramen noodles and tap water?”

I’m real cautious. I didn’t have any expensive tastes. I lived well within my means in a one-bedroom apartment and decided not to sacrifice quality of life.

How much of your second book had you already written?

I had a running start, but I did the bulk of it when I was unemployed.

What was your writing day like then?

I used to stay up crazy late, because I didn’t have to work. I had friends that I hung out with during the day. Once they went home, I’d be up writing until 5:00 in the morning and then sleep in until 1:00 or 2:00 p.m.

How did the book turn out?

The second book also sucked, but it didn’t suck as bad. It was a much better story. It was cohesive and coherent, had a good plot arc with exciting twists and turns. The characters actually had depth and complexity. What I didn’t have yet were mechanical prose skills. The narrative voice was clunky. There were long bouts of exposition and tangents that were exciting as hell to me but boring to any reader.

I finished that book and tried to get agents. This was really before the internet, so you’d go through the agents in the Writer’s Guide and highlight the ones that did science fiction.

But after three years of writing the book and trying to get anyone interested, I had to give up. I wasn’t out of money, but I was like, “Okay, I’m not getting any traction with this, and I’m kind of sick of being at home all day. I want a job. I want to feel productive again.” And I didn’t want to be looking for a job when I was desperate for money.

Were you looking for a job that would give you time to write?

At that point, I said, “I gave [writing] a try. I don’t have to wonder what might have been, but it’s time to face reality: I am a computer programmer.” And this was not like a sad Charlie Brown music, hang-your-head situation. I really enjoyed programming computers.

It took a year to land a job. After the first tech bubble burst and with everyone in the industry unemployed, I was now in competition with everyone who had the “programmer” title at their previous company. It took a while for the industry to reset itself, and having to deal with a scenario where supply actually meets demand was an unpleasant lesson.

Did you consider changing industries and writing professionally?

At the time I thought, “Maybe I need another career,” but it never occurred to me to make that career writing. I was going to go into locksmithing. I like gadgets and the way things work, and locks have always fascinated me. So I was looking into trade schools, because I figured whatever happens to the world, people are still going to need locks.

But I landed a job up in the Bay Area and went back to being a happy little software engineer for quite a while.

Once you said, “It’s done, I tried, it’s over,” how did you end up with ‘The Martian’?

I still liked telling stories. I decided, “I don’t get to be a professional writer, but I still like coming up with stories, I still like knowing that people are reading them, and the internet’s a thing.” So it became my hobby. In 2000 or so, I made a website and started posting my short stories [and webcomics] to it. By 2009, I had a mailing list of about 3,000 regular readers. I would send out a mass email every time I posted a new story or something.

I started The Martian when I lived in Boston, working for a company there. I was always willing to move where the jobs were. I didn’t have any friends in Boston at all. So, with no social life, I had plenty of time to write.

Every two months or so, I would post a chapter for The Martian, and I would get so much positive feedback: “Oh, I really like this one. This one’s really good.” It really fed me. All I’ve got to do is finish this chapter and post it online, and I’m gonna get like 300 emails telling me I’m awesome. That was enough motivation to continue writing.

By the time I moved back [to California] and started working at MobileIron, it was getting really popular.

You were posting chapters of ‘The Martian’ as you wrote them and inviting people to give feedback?

Yes and no. I was challenging anybody to find scientific inaccuracies. All the little nerds cracked their knuckles. That was like having 3,000 fact-checkers, which is awesome. They’re not gonna let you slide on shit. They found a lot, and that’s exactly what I wanted. However, I didn’t take any advice on the story. I wasn’t interested in that.

How did you manage changes if you were posting as you wrote?

I had this open statement: “This is a serial, but you’re watching me write a book. I reserve the right to go back and change stuff that’s already been posted.” And whenever I did that, I would just send out an email. “Hey everybody, I went back and changed chapter two. I got my reasons. You can either go back and reread it, or here’s the summary of the changes.” So basically, like a computer programmer, I would make release notes.

Were you coming into work bleary-eyed because you stayed up writing until 4:00 in the morning?

Even when I was working on The Martian, my priority was my job at MobileIron. I would never stay up super late writing and then come in late to work the next day or anything like that.

I was writing code with a team. We all respected each other, and we all had our pieces of the pie. It was like being in a band. I liked the camaraderie. And I miss that. Now I’m [writing] by myself. Well, I’m married now and have a social life, but professionally I’m by myself. I sit writing by myself and then email my agent and my editor, then make their changes. I miss being in a room where you’re all bouncing ideas off each other, coming up with stuff.

That software engineering attitude came across when working with an editor. It’s like, “Hey, this paragraph here is not very good, and here’s why.” And I’d be like, “Okay. Yeah, I’ll fix it.”

I read that your readers complained that your website was crap, so you ended up posting the book on Kindle.

Yes. The Martian became the number one sci-fi seller and in the top sellers of all Kindle. That’s what got the attention of the traditional [book publishing] industry — they came to me.

You’d been working collaboratively in programming for years by the time your book was bought. Was working with an editor similar to working in programming?

Absolutely. A lot of that software engineering attitude came across when working with an editor. I didn’t do a real editing pass with a real editor until I was working with Random House. That was like, “This is a great book. Here’s a thousand things wrong with it.” I found it very easy and natural. Same as dealing with bug reports from QA. It’s not like, “Oh, woe is me. I failed. There is an error in my code.” No. It’s like, “Hey, this paragraph here is not very good, and here’s why.” And I’d be like, “Okay. Yeah, I’ll fix it.”

I was going to be published. This was a dream I’d had since I was a kid, and I wanted to do it well. I also just have a very simple work ethic: Do your job and work hard. I told myself: “These are the people I’m working for. They gave me money, so I give them a thing.”

‘The Martian’ became a bestseller and then a blockbuster movie. At what point did you realize you would no longer need a day job to support your writing?

I kept that last engineering job way past when I should have stopped. The Martian had already been on the bestseller list, and I think they were shooting the film. It was absolutely clear that I’d be financially secure. But I enjoyed the job, and I liked my co-workers. We had a release coming up, and I didn’t want to leave them behind to deal with that without me.

Looking back, is there anything you would have done differently?

At no point did I ever risk my financial security to become a writer. That meant I always got to write exactly what I wanted. But it also meant I was much less motivated to write. If I was working to make ends meet and somebody said, “Hey, we want you to write columns for this newspaper,” then I would have gotten more experience in prose and flow, and I would be a better writer right now. But I would have spent a lot more time doing writing that I didn’t want to do. So, I’m not sure.