I have had priviledge of coding with best in the world, talking near perfect IQ tests, been to MIT etc. What they all had in common was their brain thinks faster than normal people, when they smoke pot they can actually focus and concentrate on code like a normal person. I remember one time one of these guys flunked a math test because he ran out, he rewrote it next day stoned and got a perfect 100%. For fun he'd sit up late at night stoned all the time hacking at the linux kernel trying to make it better.
For normal people, there are 2 types, ones that shouldn't be programmers and ones that really do want to be there. The type that do want to be there come up with more creative ideas stoned, then implement them the next day, a coding block on an algorithm easily solved with having a joint, then tackling it the next day. Then there are the types that aren't creative that shouldn't be programmers to begin with that it doesn't help them at all.
In overall society legalizing is probably a better thing, criminal minds that would go off committing crimes, instead smoke a joint, and say , screw it, lets just play xbox for rest of night, or just hang and chill, creating less work load on society. In general my opinion is do it in balance, don't smoke pot for 6 months straight or it will take you a full month to gain your longterm memory back, just do it here and there for a breather from life, as a sleeping pill or to overcome a coding block. Having a joint means you become effectively 2 people analyzing same problem, 2 minds are better than 1, and generally reason it is easier to solve problems thinking outside the box at times. I am definately not advocating smoking a joint everyday, unless you have no job or income(then go for it), but just in balance, it never hurts to approach things from a different philosophical perspective.