It's a very interesting topic, one I don't have time to contribute to much at this moment. Most people here seem to have very limited ideas about what a sentient program or robot would be, however. The whole "we program it so it will only do as programmed" is patently false even for "simple" artificial intelligence programs we do today. For example, a neural network learns how to classify objects, but we don't exactly know how it classifies, and the network itself can't express how it does it. This is similar to our brains, actually; we can do lots of stuff (semi-)automatically (like read this text), but we can't articulate how our brains do it. Can you explain exactly what your brain is doing to decode these words and sentences?
Anyway, I recommend some reading for people really interested in the subject. There are tons of good books about conscience, the philosophy of "strong AI", sentience, free will, artificial intelligence techniques, machine learning, etc. One mind-blowing example for starters is "Gödel, Escher, Bach: An Eternal Golden Braid" by Douglas Hofstadter, which seems to be about a lot of things in the beginning but it's really about consciousness and the possibility of a "strong AI".