When I started out in programming, in 1984 at the age of 19, it was considered to be "the" most secure job to go into.
Even coming up to Y2K many were saying that there would be plenty of work for the next 20 or 30 years for COBOL programmers like myself. There was a perception that, with universities not even teaching the language any more and with so many legacy systems using it, there would be a growing shortage.
Meh, then all the jobs got outsourced due to a perception that it would save money. And in the business world, of course, perceptions count for a lot more than reality. It can happen now to any programming language, anything you do in IT that can be done more cheaply in the 3rd world will likely get outsourced eventually.
In Australia now, at least, IT degrees were once highly sought after and it was quite difficult to get a place at university. Nowadays universities are downsizing their IT faculties, and it is very difficult to get students. I certainly wouldn't recommend programming to anyone. After 20+ years as a programmer I was making a serious effort to get more into the systems analysis/business analysis side of things. That was before the worldwide recession went and f***ed everything up. I was perfecty happy to be a programmer for the next 20 years and then retire, but I really didn't see any secure future in it.
It is a hard job, a stressful job, and the pay used to be good. At 25 I was making about double the average adult wage. These days, if I had a job, it would be more like 30% above the average adult wage. In some Western countries business lobbies have driven a false perception that there is a shortage of IT workers across the board (for obvious self-serving reasons) and governments have adjusted their immigration quotas accordingly.