That's why, precious gem formation is often associated with volcanic activity. As the molten rock cools, pockets of minerals are formed and the crystals begin to develop. The type of minerals, cooling temperature, and hundreds of other variables all play a role in determing the type of crystal that will form. It just so happens that diamonds are a very simple crystal. They are almost pure carbon, just like coal.
Quartz crystals are more complex and are formed of silicon dioxide molecules.
Garnets, and emeralds are much more complicated, containing compounds of iron, calcium, and aluminum. A gem that has just been mined out of the earth looks nothing like the jewel you'll find in the store. In order for a diamond to achieve its breath-taking beauty, it must first be cut and polished. The art and science of gemcutting is called lapidary. The first step a gemcutter takes is to lightly hammer off fractures and protrusions from the rough stone.