The four phases of <insert random library here> integration

I’m currently working on integrating a 3rd party library in my own code and today I realized that there are 4 typical phases in such a process (at least for me):

  1. Try to understand library
  2. Fail at step 1, try to write my own. How hard can it be right?
  3. Realise that step 2 is actually quite a lot of work and that my solution is even worse than the original library.
  4. Gain more appreciation for the original library and start to use it (mixed with the good parts of the stuff I wrote myself) :)