I take a more selfish approach on this debate. I nearly always write my own code to do something, even when a library already exists... just so I can understand the problem well. Then, when I finally decide to use a specific library, I understand why they're doing something in a specific way more clearly.
Maybe not the most advisable route for commercial work, but one that keeps me satisfied.