I agree with the above. When recording with a microphone it is important to understand how the distance from the microphone will affect you. As you get to higher volumes, you want to adjust the distance you are from that microphone to reduce the volume the microphone sees but still get the natural performance of your voice. Conversely, when singing lower volumes, you can get closer so that the microphone picks up your performance at a nice volume. It is good to spend time learning how these affect you, and monitor performance as you sing (often best through headphones, since using speakers with a microphone can create a feedback loop - the speakers are being picked up by the microphone).
That said, when recording, you want to have your "loudest" performance not to exceed -6 db levels when you sing, and can adjust these with input gains on your equipment. Practice high volume parts of a piece before recording to see that you are not driving the signal above -6db (into the red). If you are, learn the distance of the microphone or adjust the input gains to keep the level below the red. Typically, the input gain will be set to one value, and the rest you do with your distance from the microphone, which is where monitoring and understanding how to use distance from it is important.
Back to your original question. Typically in a digital environment you would not use these to record since you want the original recording to be the "real performance." If you record an adjusted signal, they cannot be undone if what you recorded was that adjustment. As for what they do:
A gate is a threshold which removes all signals below a certain level. They are useful for removing low level background noise, but setting the threshold too high will cut off the beginning of each note you want to hear and can sound unnatural.
A compressor "squashes" a signal to make the volume output be more consistent even when the recorded values are not. Digitally, this is more used for the "mixing" stage, where you adjust the recorded levels to fit the piece you are doing. This link has a simple overview of the typical use (
http://www.soundonsound.com/sos/oct09/articles/qa1009_2.htm). But again, your
best control of this when recording is to understand how your distance/angle to the microphone affect you, setting input gains properly, and monitoring your performance as you sing. As you understand these better, you can use these techniques to improve your performance.