The terms 'hard reboot' and 'soft reboot' have many different (and often ambiguous) meanings:
- from the perspective of the processor, a soft reboot is caused by the reset interrupt, which causes the processor to jump to the reset vector and perform another bootup. A hard reboot is performed by powering down and up the processor (main memory blanks itself while the processor is powered down, as it needs to be refreshed by the processor every few miliseconds).
- from the perspective of the hardware, a hard reboot is a reboot performed by removing and then restoring power to the computer without warning, a 'soft reboot' is anything else.
- from the perspective of the operating system, a soft reboot is any reboot that allows it to shut down properly, and a hard reboot is anything else.
All but the first meaning of hard reboot are Very Bad Ideas, and should only be done in an emergency (such as the computer catching fire), or as a last resort (if all attempts to switch off properly fail).
If you're running an ancient operating system (DOS, for example), switching the computer off and on instead of pressing the reset button may give some protection from viruses. It is possible to write a program that can survive a soft reboot, by hijacking the reset vector. In the old days, many viruses were 'reset proof', but modern operating systems don't allow programs to write to the reset vector.
A hard reboot by disconnecting the power is especially damaging. Any computer produced after 1980 or so will have at least one hard disk. Hard disks must perform a controlled shutdown to avoid losing data - they have a cache (an amount of memory built into the drive to buffer writes from the fast computer to the slow drive), which may contain data that has not yet been written to the drive. In a controlled shutdown, the microprocessor controlling the drive will finish any writes that are buffered in the cache, before shutting the mechanism down safely (for example, parking or unloading the heads, to minimise the risk of damage should the drive be transported).
If a computer has power removed unexpectedly, its storage devices will have no opportunity to empty their caches, causing data loss (and possible filesystem corruption). Even worse, if the power supply does not detect the power failure and cut off power, unexpected behaviour can occur (remember that computers operate so fast that the capacitors in a power supply can provide power for millions of clock cycles after it is unplugged). Electronics that has some power, but not enough will behave unexpectedly - an improperly powered hard disk may write rubbish over existing data, or even damage itself.
Most computers have more than one processor. As well as the microcomputer controlling each hard drive, a modern desktop computer ('ATX' PCs, and just about every mac ever produced) has a system management controller, a tiny, low powered computer that is always on, and manages the power supply, front-panel, fans etc. The system management controller is responsible for bringing up and shutting down the computer, and can do so even when the main processor has locked up.
On an ATX PC, a controlled shutdown can be requested by pressing the reset button, or by holding the power button. On a mac, a controlled shutdown is requested by holding the power button on the keyboard. Both ATX PCs and macscan be hard rebooted by unplugging the computer from the wall, switching off the wall socket, or by switching off the power switch on the power supply (typically at the back of the machine). Depending on your computer/country, power switches may be missing from your power supply or wall socket.
Not allowing an Operating System to shut down properly can lead to filesystem corruption and data loss - modern operating systems have caches in main memory, typically many times the size of the cache on a hard drive. If the operating system is not shut down correctly, data in the the cache not yet written to the drive will be lost. In addition, if the computer is restarted while it is in the middle of writing to a disk, the incomplete write may damage the filesystem. Most modern operating systems will check for filesystem damage before using a disk that has not been shut down cleanly, but if the damage is to the disk carrying the operating system, the computer may no longer boot. Finally, any documents you have made changes to but not saved will be lost if the operating system is not shut down properly.
Thanks to Brontosaurus and isogolem for feedback and corrections!