I used to joke with my wife that when I turned 40 I'd have to grow a ponytail to still be considered relevant as a programmer. My 40th birthday was a decade ago and I haven't had to grow the ponytail yet.
The book "Decline and Fall of the American Programmer" was written in 1992. The author got it wrong because he didn't understand how the Internet, smart phones, and now "smart everything" were going to push software into so much of our lives. He was wrong in 1992 and you can find slashdot articles saying pretty much the same thing in the early 2000s. They were wrong too.
How long will software people be in demand? Who can say? Based on the last 50 years or so the demand has been pretty good (with some downturns here and there). Yes, ageism is a danger and yes you may find yourself with skills no longer needed, but looking forward there aren't many vocation choices that don't involve some sort of risk.
If you're good at it, keep your skills fresh, and pick good companies to work for, you can make a career out of it. Having other skills doesn't hurt either.
While I don't think that a huge emphasis on coding for kids (who aren't otherwise interested) is a good idea, they should definitely get some exposure to it. Just like they should get exposure to art, music, literature, or even robotics. I also believe that there are huge opportunities for those who can combine programming with expertise in another field.
I have a son who is in his early teens. He really has no idea what wants to do for a living yet and that's fine. He has a vague notion that he might want to do something with computers. He's a reasonably smart kid but I don't think that's his calling. He's kinda sorta interested in electronics and will mess around with Lego Mindstorms with some prompting. He's had a little experience with programming but doesn't have nearly the excitement over it that I did at his age. Still, I've encouraged him to take a one semester course at his high school. I think that will tell him if coding is something he wants to pursue further or not, even as a hobby.