A decent number of folks have used programatic methods for managing groups and devices. There quite a few different solutions including, but not limited to zenbatchload, zendmd scripts, and the JSON API.
Each has its own merits, and one isn't necessary better than another, but you do have options.