1) There are plenty of software engineers over 40
2) The field requires a fairly robust ability to learn new things. Entirely new things, learning new things from scratch, becoming productive in something you didn't even know existed 6 months ago. That gets harder as you age.