Drugs, in many cases, outside of working hours can have effects during working hours.
Many software developers working for companies have agreements that they can't compete with their current employer on what they do while employed there. It's something employees give up while employed somewhere.
In the name of safety, many jobs with safety issues have to give up certain things (i.e. drugs) while employed there.