What I've always found odd is when a company advertises something like "we have 50% women on the programming team" when only 20% of the programming workforce is female.
That's not really fair is it? The company is overly diverse if anything. In a way they're stealing women from the workforce of other companies.
Diversity needs to happen from the ground up. Affirmative action is more effective and more appropriate the earlier in life that it is. Special coding classes and programs for underserved groups (e.g. Rails Girls) are the best, because a lot of girls don't get the same opportunities. In New Zealand, a lot of single-sex girls' schools don't teach programming at all. It's the same with schools in lower income areas, they often have very underdeveloped STEM programs.
Having lower entry requirements to university for less privileged populations also makes sense, although using ethnicity is a very blunt stick, as there are often external factors that mean that equally talented students have worse educational outcomes in school, such as poor nutrition, working a job after school to help pay the bills, and low quality teachers (most good teachers want to teach at good schools). There external factors tend to be ironed out at university.
Obviously not every type of affirmative action is appropriate for every situation. Requiring lower grades for women to get into engineering programs at university probably isn't appropriate, since it's not like women grow up in less privileged households than men.
Affirmative action in hiring makes a lot less sense than at earlier stages. There's only a certain percentage of women in the workforce, hiring over that percentage isn't going to help with diversity or inclusion. If only 20% of programmers are women, then your company's programming team should be somewhere around that number. If it's a lot higher or a lot lower than this, there's something wrong.