Boys have an inherent fascination with the concept of using symbol manipulation to change the functionality of physical machinery. By changing how machines work by typing words and code. Boys are absolutely obsessed with the concept that you can create machines that do what you tell them to do by changing mere symbols (which is what source code is). It is a way of creating life from dead objects by using 'magic' symbols. Religions are based on this. Programming is a type of religion. Boys are very much into this.
Girls, on the other hand, are absolutely fascinated by their ability to create actual living, thinking, unique human beings with their own bodies. They don't need magic symbol manipulation to create artificial life from physical objects. Their bodies create life from their interactions with other life. The lives that girls create can't be controlled like the robots or machinery that boys create, but their human-life creations are infinitely more complicated than what the boys can do.
This is the basic primal fundamental reason why boys are much more attracted to computers and science. Boys spend their lives and careers trying to gain and master the life-creating abilities that girls are endowed with at birth.