Intelligence is vastly overrated and widely misunderstood.
By which I mean, it's not a fixed quantity that an individual has no control over; it is not the same thing as natural aptitude. And responses like "Great job, even though you did poorly on that math test you studied really hard!" are not helpful if you actually want someone to get better. [Note: I'm not saying that "Bad Timmy, you clearly suck at math and I'm giving you an F!" is any better, though unfortunately belief in that false dichotomy is pretty common in the world of education]
When someone "intelligent" gets a bad grade on a math test despite having studied hard, they realize that something is wrong with the way they studied. Or that they have a deficiency in earlier material that they need to correct. Or that they need to sleep more before the test. Etc. They never accept that they didn't work hard enough (they did!), and they never accept that they're not smart enough (they are!) - they assume that they somehow worked wrong, and they set about fixing that problem.
When someone "unintelligent" gets a bad grade on a test, they chalk it up to the fact that they're not very good at math, but hey, they tried hard, and that's what's important, right?
That's not what's important. Learning to work hard is not a worthy goal on its own if you don't learn to work better at the same time (or at least it's not the most worthy goal). This is as true in programming as it is anywhere.
Now, when it comes to child psychology and keeping a child engaged, maybe you're right and it's better to praise effort. But that should not come at the expense of praising intelligence; "intelligence" is the end product of many years of effort directed at the process of learning and thinking, not something that's doled out of a box at birth. Unfortunately it's something that we've never really learned to effectively teach, which is a shame.
[Edit: I'm also not claiming that there's no natural difference in smarts that does come "for free" at birth, there is absolutely some sort of Bell curve happening there, and some people are destined to be at the high and low ends of it, for sure. But my point is that the way the people at the top handle failure is vastly different from the way people at the bottom handle it, in that they're never satisfied with mere effort.]