Actually, I've done all that. It's really not that hard to estimate, unless you don't pay attention to how long it takes to do stuff. It's not like you're trying to figure out how to fuse atoms, and have to build the manhattan project from scratch.
Writing something new is more difficult, but when you break it down into chunks it becomes easier. You do have to have a good understanding of how you work.
Just like anything, it takes practice. If you have enough people estimating you can bayes the answers, sort of.