AF NIKKOR 50mm f/1.8D & Nikon AF-S NIKKOR 50mm f/1.8G Difference???
Aside from the D not autofocusing on the D5100, I've also heard that the G is sharper than the D.
I have the D and it is a great lens, especially for the price. However, if you plan to stick with the D5100 for a while (or ever change to another body that does not have an in-body focus motor) then pay the extra for the G. It will focus on your current camera and may be sharper at the larger apertures.