In my four decades as a programmer, I've worked with hundreds of programmers, and I can say that no single type of person is good at programming.
I've seen young people who could do amazing work and those without a clue. I've seen programmers older than me who could accomplish anything, and those with as much experience as I had had be unable to do even minimally acceptable work. I've seen someone with a Ph.D. in Computer Science who built the single worst piece of code I've ever seen, and people with no degree at all build complex applications. No race, ethnic group, background, experience, or other category ever made the work quality predictable, good or bad.
Programming ability appears to be related to nothing obvious except something in people's brains that connects with programming. It's not intelligence (a poorly defined concept with almost as many definitions as people making them) but some combination of qualities that make writing good code easier. Of course, even defining "good code" has almost as many definers as intelligence.
Writing computer code that works correctly in all circumstances, succeeds in implementing whatever is required, interacts reliably with all other code and systems it touches, and can be supported and modified over time can be one of the world's most difficult tasks. Combining these basics with understanding the necessary security and interacting with team members, other teams, executives, product and UI designers, architects, and even the outside world can make the required effort almost impossible. Yet some people do, and others do not.
Of course, many programming tasks are rote and require little skill, assuming adequate supervision and testing are available. Not everyone needs to be able to work on complex systems and walk a narrow tightrope between success and disaster. A single programmer working on a team of hundreds will not likely affect the project. Still, a single programmer working on a project alone may determine success or failure.
When I started as a programmer in 1981, the world had few programmers compared to today; I expect that many whole countries did not have a single one. Today, I have seen estimates of around 25-28 million worldwide. Are all of them good? Given the wide range of quality I have seen over my life, I am sure most of them are not.
Yet, given my experience working with or interacting with programmers over this long period, no one mold produced excellent or bad programmers. I remember when Mark Zuckerberg once claimed that only people under thirty were any good, saying, "Young people are just smarter." That's pretty ignorant; I have seen people of every age write amazing code and yet also seen people of every age write absolute garbage.
Someone with a Ph.D. in Computer Science wrote the worst single piece of code I ever saw. They wrote a Mac application as a single .c source file, 29,000 lines long (the IDE at the time could not handle typing at the end) with a main event loop (original MacOS, in 1995), 14,000 lines long, indented two-and-a-half monitor widths deep. It took three of us several months to untangle it.
I once worked with someone who passed every Java certification and had a degree in Computer Science, yet they could not build anything that worked when put on a simple application. Having a degree or not even going to college did not seem to matter; I've seen both succeed and fail. Age (and experience) also led to no predictable outcome. One person hired at the same time as I was, with the same number of years of experience I had, everything they wrote had to be checked as they did not seem to understand what they were doing (such as excessive copy-paste with extra lines).
I started my career as a programmer in 1981 with no work experience, and the only computer education I had was in 1973 in high school. Noodling around on my Apple II+ that I bought in 1979 was all I could offer, yet I passed a single interview with the hiring manager, who offered me a job. Everyone else hired at the same time had a B.S. in Computer Science. Today, someone like this would not even get a phone screen, much less a job. No one (including me) could have predicted that not only would I continue to be a programmer for the next four decades but that I would remain relevant during that entire time. Why? I have no clue. I have the qualities that make a good programmer, but I don't know what they are or where they come from. Others may be smarter, more capable, and accomplish more than I can, but from my experience, many more cannot do anything beyond simple tasks or wind up with broken code.
Programming well requires discipline, imagination, creativity, the ability to comprehend what is being asked for, focus on details, comprehension of existing code and side-effects, the ability to plan for the future without compromising the present, being willing to learn things that may or may not be relevant, and the ability to spend the time necessary to understand everything even if it's tedious. It's a long list of abilities, but you can't predict who will be able to do well and who will not.
When I started my first job in 1981, I did not know if I could do anything as a professional programmer. I did not even know what a programming job entailed besides the apparent writing of code (the joys of no internet back then to learn what the job was like). Somehow, I found I could learn on the fly and improve my ability as fast as necessary. I was handed complex tasks where I was the only programmer and could get them done. I still find it hard to believe I spent four decades writing code (and still write code today for my generative art), given I had no real education in it. I didn't even expect to work more than a couple of years as a programmer before continuing to get a Ph.D. in Chemistry.
I firmly believe latent programming ability exists everywhere, but opportunities to discover it do not exist equally. To me, the most significant opportunity is to expose students at a high school level to programming so that people who do have the ability to discover for themselves a desire to program. I expect most people will find it tedious, boring, complex, or otherwise unappealing, and that's fine. My exposure to programming 50 years ago in a public high school, which had to be one of the very few offering this in the country, eventually led me to lifelong enjoyment and success as a programmer. Without that class, it is doubtful that I would have ever started.
Good programmers can come from anywhere, even countries that seem unlikely to produce them, because the features in the human brain that are necessary for success can be anywhere. It would be best to allow these people to be discovered and nurtured. Missing people who could be good programmers is a loss for everyone.
Mediocre programmers can also come from anywhere. I do not believe, from my lifelong experience, that everyone will do well if you just train them enough and invent some environment or process that will keep them from failure. It may be OK to have only minimally capable programmers who work with lots of supervision, but expecting all programmers to exceed that is unreasonable. I always preferred having a small team with people I could expect to succeed without excessive oversight rather than a large team who could not be that. You don't always have that choice, however.
"Anyone Can Cook" is a nice slogan for a Pixar movie (Ratatouille), but it isn't reality any more than "Anyone Can Program." Still, believing that a rat can be a cook is a decent metaphor for thinking that good programmers can come from anywhere if you allow them to discover it for themselves and don't have a preconceived notion of what they look like. My core team (both I hired) at my last job was a former Army tank driver who taught themselves to program and someone whose LinkedIn photo featured a pink mohawk. I'd build anything with them.