I used to live and work in Madrid (for a non-tech job), although I have been a programmer for some years now.
While in Madrid I met a number of software engineers/IT professionals. I think Madrid is a decent spot for finding tech work.
Mind you, my family is from Asturias, and the tech scene, I believe, isn't great there. I also don't know how Barcelona is.
If you're looking at Madrid, I think you'll be OK.