Computer programming once had much better gender balance than it does today. What went wrong?

That trend is even true at the high school level.
http://www.nsf.gov/statistics/seind14/content/chapter-1/at01-10.pdf

Girls as a percent of all AP test takers in the HS graduating class of 2012:
Biology: 59
Environmental: 55
Statistics: 52
AB Calc: 49
Chemistry: 47
BC Calc: 41
Physics B: 35
Physics C Mechanics: 26
Physics C E&M: 23
Comp Sci A: 19