I don't know how people do it -- I mean, I can cook and sometimes it is delicious, but it's nothing worst than waisting 2 hours on something and then at the end to find out that I blew the dish for some reason.
Don't you ever spend a couple of hours trying out an idea in code only to find out later that it's a complete wash? Making mistakes in cooking is no different from any other activity - it can be a valuable learning experience if you recognize it. Plus, in cooking, you can usually still eat your mistakes.