What's the difference between these two Nikon lenses?

Nikon Nikkor AF 50mm f-1.4D
Nikon NIKKOR AF-S 50mm f/1.8
and which is better?

First of all, the f/1.4 lens is slightly "faster" because of the aperture and will work better in low-light situations, and give you nicer bokeh (out of focus backgrounds) for portraits. It's an older design, but excellent and highly regarded by Nikon professionals.
But, the 50mm AF-S f/1.8 has an internal autofocus motor, required if you are using a novice-level Nikon DSLR, such as a D3100 or D5100.
If you have a D7000 or higher, you can use either lens.

The f/1.4 version is far much better even if it's less than a stop difference. If you can't afford it, the f/1.8 will do just fine.