It's estimated that up to half of all Russian (and I'm sure many other countries) embassy personnel are actually Intelligence Operatives. Throwing out 40 "diplomats" is just a show of force and not a move to actually curtail spying. Those 40 "diplomats" will be replaced by 40 new "diplomats".
And you think the Russians are a problem? We've been spied on by allies also (Britain, Israel, South Korea, France). And let's not forget what we do (project echelon).