Hammerspoon is amazing, and even more impressively, it's amazingly well maintained and its API is incredibly well thought out by its really talented development team. It really is a must-have for anyone who wants ultimate programmatic control over OS X.
Check out the really gentle follow-along tutorial:
I think we made some terrible API decisions, but we'll fix them up eventually!
(Also for those following along at home, sdegutis is the author of a long line of OS X automation tooling, up to and including Mjolnir, which we forked to make Hammerspoon. He is awesome)
That's right. Sdegutis built Zephyros (Ruby OSX automation, also other Lang support), then Phoenix (JavaScript OSX Automation), then Hydra (Lua based) which became Mjolnir, which is forked to Hammerspoon.
Check out the really gentle follow-along tutorial:
http://www.hammerspoon.org/go/