I favor an approach where we separate kids who've shown some aptitude for the sciences and concentrate them in schools full of their peers. We can't do anything for the anti-intellectual types, but we can at least stop their ruining perfectly good raw talent.
They tried that on us ("gifted schools"). The two things it got us were hours less sleep each day because of the longer commute, and worse college admissions because of GPA deflation. I would've rather stayed in the normal pipeline and gotten scholarships instead.
Unlike "hanging out with friends", a universal activity, extracurricular sports actually do conflict with early computer science exploration (they're a huge time sink, as any parent of a kid in a sport will attest).
Meanwhile, sports draws in more boys than girls.
Why are we so quick to accept the notion that after-school activities that girls participate in isolate them from STEM, but after-school activities dominated by boys don't?
As a nerdy teenager, I never had a problem with any girl in any clique or social group at my school. But I sure as shit had problems with the boys in sports.
There are kids (and parents) who get totally invested in a sport with often unrealistic expectations of college scholarships or professional careers, but there are a lot who are also remain very academically focused and balanced. I know that many of the kids on my oldest son's high school teams went on to college in STEM fields so it's not an either/or.
(Though it is true I did very little partying.)
I think that the big difference in STEM is that nerdy boys exist in such a number that they can still get acceptance and support. It's not as normal as, say, being a football player, but male nerds aren't exactly rare.
In contrast, because there are much fewer female nerds, their awkwardness is even more exaggerated, and this feeds back on itself to heighten the pressure to conform. Boys find some support in numbers, and their interest in the subjects smooths over any discomfort. Girls don't have any of that support, so if they aren't absolute fanatics about the subjects, they're going to conform.