And this study indicates that a major factor is confidence, because boys will self-assess their performance much higher than girls when there is no observable difference in actual results:
https://phys.org/news/2017-04-girls-confidence-math-ability-hinders.html

So basically, boys bad at math will continue on to become bad programmers, and girls good at math will drop the interest and do something else, instead of becoming good programmers.