Scott Alexander posits a theory which addresses why programming has a high gender disparity but law, medicine, biology and (undergrad) mathematics don't: http://slatestarcodex.com/2017/08/07/contra-grant-on-exagger....
Doesn't address why the number of women in programming has fallen since the 80's though...