Which is better for programming?

Depends on the program you're coding in, and whether it makes use of hyperthreading or not.

If it can use hyperthreading and 8 logical cores, get the i7.

If it can't use hyperthreading, but can use 8 logical cores, get the AMD.

If it can't use hyperthreading and can only use 4 or fewer cores, get the i5.