I'm going to guess that most of the "not nice" programmers are male, and most of those are single.
My experience - for which there's biological justification - is that men who've been bachelors a long time tend to be selfish and inconsiderate.
So here's a little background. Take our closest primate relatives, chimps and bonobos. The males of both species are violent, competitive and selfish by nature. Chimp females are solitary, and chimp males force sex on the females and commit infanticide to bring them into heat.
However, bonobos operate differently. Younger males try those kinds of aggressive tactics - but bonobo females are social and protect each other. After a male has had the sh-t beaten out of him by gangs of females a few times, he usually figures out that a better approach is the bonobo equivalent of candy and flowers. But of course, each new generation of male bonobos has to learn that the hard way.
When you get to humans, things are pretty much the same. I love kids and was a popular and successful babysitter when I was younger. But as cute as little kids are, they're also amoral little savages who have to be taught to be civilized. And when we hit puberty, all vestiges of civilization go out the window when hormones come in. There's also been a lot of recent scientific evidence about brain development and the fact that teenagers are often crazy and reckless because the parts of their brains that contribute to good judgment don't complete developing until about 25 or so.
And let's face it: most young guys are jerks. Really and truly. When I think of all the guys I know who turned out to be reasonable people, and where I know the details of their lives, every one of them started out as an inconsiderate jerk. Most of them fell in love with someone, acted like a jerk, got the "shape up or ship out" ultimatum, and decided they loved that person so much they would change their evil ways. I certainly did. Another guy I know came home from an evening of drinking to find his bags packed in the front hall - he never did that again, and he's been a great dad and husband for many years now. And every guy who turned out well who didn't get the ultimatum had some other life-changing event that made them reconsider their priorities, like having someone close to them die unexpectedly, or having to take care of a loved one who became seriously ill.
I knew a guy who was part of a hippie commune in the 70s called The Farm. They recognized this, and had a cure. It was a special dormitory for single guys called "The Tumbler" - as in rock tumbler. A single guy who acted like a jerk had to go live there with the other jerk guys, and he had to keep living there until the commune leaders judged his rough edges had been knocked off and was smooth enough to live around the reasonable people.
Anyway, our profession attracts a lot of single guys who've been socially awkward since puberty (aka "geeks"), and spent their time with computers or online rather than interacting with real people in person. So they have all those biological "I wanna be an aggressive inconsiderate chimp male" urges, and they haven't gotten a lot of the human social equivalent of gangs of bonobo females beating the bejesus out of them for being inconsiderate. After long enough, being inconsiderate becomes a habit, and then there you are.
This sometimes continues after getting in a relationship, too. I know quite a few jerk programmers who married passive women, and they're still jerks.
It's not just programmers, either. I've got a relative who's a confirmed bachelor and has lived alone for nearly sixty years. He's a really interesting guy in many ways, but he's so used to having his own way about everything, and so difficult when he doesn't get it, that some of my relatives contemplate family gatherings that include him with a measure of dread.
And I'm sorry if some guys are offended by this, but I'm a guy, I was an inconsiderate jerk until I saw it was to my advantage to stop, and I just haven't seen this happen the same way with women.