The encouragement needs to start from an early age. Little boys of my generation got Amigas and Commodore 64s and learned coding from typing in the code from magazines, fixing bugs. In some cases from the age of five.
Whereas many women had obstacles put in their way, or had never had that grounding as their parents had no idea.
Girls need that encouragement and support. But STEM education is still highly gendered.