In modern terminology they refer to the same thing. However, sunroofs used to refer to a metal sliding partition, while moonroofs were made entirely of glass.
Function-wise, these days you get sunroofs/moonroofs that tilt to open a little bit, and/or slide back for a larger opening.