I think I'd use "develop" for more formal contexts, and "build" for quite a lot of the others. My instinct is that "write" goes more closely with "a program" but "build" goes better with any more functional definition like "a tool", "a toy", "a browser", or whatever.
Hm, really? I don't think I agree. I think I would still instinctively speak of writing a browser or writing a tool. "Build" in particular is something I'd reserve for the process of compilation rather than coding ("the build system" etc).