54
Which is the best language to do this?
Whichever you are most comfortable with. There are lots of examples of successful window managers in many different languages out there. Qtile and xmonad are good examples, written in Python and Haskell respectively.
Where to get some resources to learn?
I would go look at some of the existing window managers. There are lots of them, so at least some of them has to have readable code. Here is the Comprehensive List of Window Managers for Unix.