Ageism for me started in the late 20s. (I'm 32.) These companies want large teams of commodity programmers that they can cram into open-plan cattle pens. They don't want actual elite programmers. They want average people with huge egos who think that they're "rock stars" and will work 14 hours per day to prove it: the macho-subordinate type. They don't want people who are experienced enough to spot bad management, much less people who know what to do about it.
Also, both the abuse of the H1-B program and ageism are rooted in an unspoken but powerful fear: unions. H1-Bs are attractive because they can be threatened with deportation and come from countries where unionbusting is a lot more aggressive (as in: in the Third World, you get killed if you're a union organizer, rather than just illegally fired and blacklisted) than here. H1-B abuse is more about union prevention than it is about wage depression. "Culture fit" is code for "we don't want to hire people who know that we don't have our employees' interests at heart". These companies fear that if they hire someone in his 40s, he'll let the young'uns know too much about how the world actually works, and it won't be as easy for employers to take advantage of them. So they put out a bunch of propaganda indicating that 40-year-old programmers "are resistant to change" and "can only write in COBOL". Anyone halfway intelligent can see that this is ridiculous, but it sticks, because a lot of the people in the contemporary startup scene aren't halfway intelligent.
The problem is that technical excellence, in 95 percent of these supposedly technological companies, does not matter. (If it did, these companies would value technical ability and experience, rather than young bluster.) The era when startups were small teams whose technical excellence gave them a 10-100x force multiplier against competitors (and, to be truthful, it often helped that these startups were attacking niches than larger companies didn't care about, but that later proved to be important) is over. These days, startups are VC-fueled built-to-flip insta-behemoths. They're not teams of 15 doing the work of 200. They're sloppily-built 200-person companies that didn't exist two years ago that run on this misplaced middle-class belief that these horrible "tech startups" are the companies of the future. (I mean, they might be, but if that's the case, I want no part in that future.)
I doubt that this particular brand of perversion is sustainable. The reason for technical excellence to be severely undervalued is that the effects of technical sloppiness usually take a long time to have a macroscopic impact, and the managers who impose horrible practices and sloppy hiring expect to be promoted away from their messes before anything happens that could be attached to them. Founders don't expect to be running their companies 10 years from now; they want to be cashed out, diversified, and working 10-to-3 jobs as venture capitalists or executives at Googly mega-corps. The sad thing is that, for several years, sloppiness has at least seemed (survivor bias?) to work. The managers who have shoved the perma-junior Scrum culture down our throats have been able to get promoted away from their heaping piles of tech debt.
I'm betting that, some time in the next three years, the tech bubble will deflate (it may be a "crash" and it may be a slower deflation) and that a lot of the bad actors will have egg on their faces. Right now, there just isn't enough dirt flying around, because even though there's a ton of unethical behavior going on, no one wants to expose it and become unemployable. That'll change when the easy money is obviously gone and people get angry. Y Combinator (also known as, "where founders learn how to be unethical, and how to get away with it") managed to miraculously escape blame for the Zenefits disaster. Very few people have even made the connection. That's easy to do when it's a one-off. When a large number of people realize that they've been lied to, that they've bet their careers on a fraudulent shell game economy, and that they're not going to be rich VCs inside of 5 years, I predict that the knives will come out. What I want to do, when that happens, is get up on a platform and say, "Hey, technology itself is really important and our society still needs it; these bozos weren't even technologists." We need to differentiate ourselves as true technologists, apart from the VC-backed bozos who'll be blamed (circa 2018-20) for wrecking the economy. Then, perhaps, we can create a culture where technical excellence and experience are actually valued.