This contains a lot of Latin names of plants and scientific terms for groups of plants. You can use a search engine to look these up.
Let’s start by getting a few things straight. Not all cacti grow in deserts. Many grow in semi-deserts, mountains, beaches or even rain forests. Not all cacti, even desert ones, have fleshy stems, lack leaves or have spines. Not all desert plants that are fleshy and/or spiny and/or leafless are cacti. Agaves (century plants), Aloes (including Aloe vera), Euphorbias (includes the pencil cactus and the baseball cactus), stapeliads (carrion flowers), Lithops (living stone plants), Pachypodiums, Crassulas (Jade plants), Araucaria (monkey puzzle trees), cycads, Welwitchias, palms etc. are not cacti! Perhaps you should note that Schlumbergera (Christmas cactus), which isn’t very fleshy, grows in rain forests and doesn’t have spines or leaves (but the stems look like leaves), is a real cactus. Euphorbia obesa (baseball cactus), which does grow in a desert, has a very fleshy stem, has nothing that looks like leaves but doesn’t have spines, is not a cactus.
Perhaps I should also mention that all cacti are native to the Americas although one of the forest ones seems to have got to Africa and Asia without human assistance.
The desert, semi-desert, mountain and beach cacti have similar adaptations and can be cultivated in more-or-less the same way (also some of them grow in more than one of these habitats). The rain forest cacti are rather different. I will talk mostly about the former group.
One way to reduce water loss is to have a thick, waxy skin. All cacti have this one pretty much covered.
Another way is to reduce or get rid of leaves. The four sub-families of cacti have somewhat different leaves. The Pereskoideae (which doesn’t include any common cacti) have large, non-fleshy leaves but they don’t grow in deserts (so I’m not going to talk about them here). The Maihuenioideae (which only has two rare species) have cylindrical, fleshy leaves. The Opuntioideae (includes prickly pears and chollas) are rather varied: Pereskiopsis and Quiabentia have flat, slightly fleshy leaves, Austrocylindropuntia and Cylindropuntia have fleshy, cylindrical leaves, the others have small, short-lived, scale-like leaves. The Cactoideae (which includes most cacti except prickly pears and chollas) don’t have leaves.
If you’re going to get rid of your leaves, how do you photosynthesize? Almost all cacti have stems that photosynthesize (and are therefore green or sometimes brown due to a mixture of chlorophyll and red pigments), which gets round that problem.
Another way is to reduce your surface area to volume ratio. This can be achieved by making your shape closer to a sphere or by being larger.
If you make your above ground parts spherical, you reduce your area for photosynthesis. Some desert plants, like Lithops and some Haworthias resolve this dilemma by having windows that let light into the leaves, where there’s a large area for photosynthesis, while maintaining a small area for evaporation. Cacti however don’t do this (even if you substitute leaf for stem). Another way to resolve this would be to have a round stem that grows leaves in the wet period. Euphorbia bupleurifolia uses this strategy but no cacti do. Many cacti do have ball shaped or thick cylinder shaped stems. These almost always have ridges (ribs) and/or bumps (tubercles), which increases the surface area again. It’s often claimed that these help the plants to shade themselves from the sun and expand and contract as they absorb and loose water. This may be true but why the huge variety? How do you explain something like the narrow, wavy ribs of Echinofossulocactus? Why does the number of ribs tend to follow the Fibernachi sequence? How do you explain the flattened stems of prickly pears (roughly equivalent to the genus Opuntia) or why some hard-core desert cacti; like Ariocarpus, Leuchtenbergia and Astrophytum caput-meducae; have large, leaf-like tubercles?
If you make your bellow ground parts ball shaped, you make it harder for the roots to absorb water. Many succulents, including some cacti, have a combination of long thin roots for absorbing water and thick, fleshy roots to store it. Some cacti, like the tiny Blossfeldias, have more below the ground than above and some like Echinocereus sub-genus Wilcoxia have fleshy roots and thin stems. A few, like the genus Pterocactus, which grow in the shifting sands of Patagonia, even loose their stems in the winter.
Size can also be a double-edged sword. A small plant can hide in the shade of rocks or other plants, both as protection from the sun and to make it harder for herbivores to find them (but would it be safer for a herbivore to munch on a hidden plant, than one that’s out in the open where carnivores can spot it?). Also a small plant can grow to flowering size and reproduce faster. A big plant has nothing to shade it and can be seen from a great distance, it also takes longer to grow to flowering size (although there are large, fast growing cacti and small, slow growing ones). One way round this is to get large but stay low, a large clump (many cacti including a lot of Echinocereus and Mammillaria species) a disc shaped stem (many cacti but particularly Gymnocalyciums) or crawl like a snake (e.g. Stenocereus eruca). A large round stem seems to be impractical, perhaps because you don’t have enough surface area for photosynthesis and there are few cacti that do it (Echinocactus, Ferocactus and Denmoza). No globular cacti seem about to attain a diameter of much more than 1m. There are some huge cacti, like Carnegia gigantea; there are also many small ones and a number of in between ones.
Then there’s spines. It isn’t a simple case of turning leaves into spines. All cacti have hairy patches called areoles. These are reduced branches and the spines are the leaves of these. Pereskias (thought to be the most primitive cacti) have normal leaves and areoles with spines. In some species the areoles on old stems grow normal leaves (in addition to spines). I suppose this is a way for a deciduous plant to grow leaves quickly without growing a lot of new stems. However Pereskias aren’t desert cacti so I wasn’t going to talk about them. If the cactus has leaves, the areoles are located just above (except for leaves which grow from the areole but we’re not talking about Pereskias). Normally the spines are in a specific arrangement, which varies with species but may even be variable within a species and may vary with the part or age of the plant. In Cactoideae there are normally one or few spines in the middle, which stick out from the plant. These are called central spines. Then there are typically more spines around the edge of the areole, which point in different directions. These are called radial spines. (Not all species have both radial and central spines.) Areoles have two parts. An upper part (nearer the growing tip of the plant), which produces a branch or a flower (a few, like some Neoporteria and Weingartia species, can produce more than one flower from an areole) and a lower part that produces the spines. This isn’t normally obvious from looking at the cactus but if you look closely, you may see branches or flower buds coming from the upper parts of the areoles. However some cacti, most notably Mammillaria, have the two parts separated. If you look at a Mammillaria with flowers, you will see that the flowers come from between the tubercles, not from the tips of the tubercles where the spines are. I don’t think anybody can explain why most Astrophytums have normal type areoles (although not always with spines) while A. caput-meducae has the spine baring parts at the tips of its ridiculously long tubercles and the flower baring parts (sometimes more than one!) about half way along the tubercles.
There’s a fair amount of debate about the function(s) or the spines. Not all cacti have spines and there’s a huge variety. Some of the forest cacti have spines. It would seem logical for a cactus seedling to put its resources into growing stem (or leaves it has them) that can photosynthesize and allow it to grow faster. Then, when it starts getting to the size when spines are useful it will start growing some. However this isn’t what happens! Usually about the first thing a cactus seedling does is to start growing spines. It also grows leaves if it has them. (There are no cacti that are leafy as adults and not as seedlings or vice versa.) Nearly all cactus seedlings have spines, even if they’re spineless as adults (e.g. Ariocarpus and Lophophora). This suggests that the primary reason for spines may be helping seedlings to survive somehow (fending off very small herbivores?) and their functions (if any) in adult plants are secondary. Obvious functions are protection from herbivores (because they don’t like getting pricked), camouflage (this only seems to apply to a few cacti, like Toymeya) and shade from the sun. Less obvious are to hook onto animals to move the plant (or bits or it) around. This certainly seems to be the case with species like Opuntia fragilis and Mammillaria yaquensis (which have barbed or hooked spines and tend to break apart and grow form cuttings easily). However when small seedlings get pulled out the ground by their hooked spines (I’ve known this to happen) it seems less helpful. Another theory is that the spines somehow cause water to condense on them. Certainly a dehydrated (but still alive) cactus cutting, if put in water, will absorb water without roots. This is a good way to revive cuttings that been forgotten about! This doesn’t seem to work with succulent Euphorbias or stapeliads. In many cases the spines are downright baffling. Why does Matucana madisonorum have 3 spines on some areoles and none on others? Why does Astrophytum capricorne have curly spines while the similar A. asterias and A. myriostigma have none? You’d have thought the really ferocious spines of Hamatocactus uncinatus (one of few cacti with hooked radial spines) would be more trouble than they’re worth. What use are the weak spines of Aztekium ritteri or Echinocereus subinermis? What about the bristly spines of Notocactus ottonis? A number of cacti produce their flowers from very spiny and hairy regions called cephalia. In some others the flowering region is spineless. There are even one or two species that can flower from cephalia and normal parts of the stem. Why? Cacti have varying degrees of hair in addition to spines. Some just have hair.
The Opuntoideae have barbed hairs called glochids in addition to the spines. Some just have glochids. If you handle an Opuntia microdaysis or something similar you will quickly learn what glochids are! In most cacti, the areoles stop growing spines when they’re fairly young but Opuntias can grow more glochids on old stems.
Some desert plants grow quickly, flower and survive the dry period as seeds. However all cacti are perennials and grow relatively slowly, although some of the small ones can reach flowering size in just a year or two (at least in cultivation). However it’s thought that some cacti (e.g. Pediocactus), in habitat may have large reserves of seeds in the soil, perhaps more than the number of plants, waiting, possibly for many years to germinate. Some desert plants (e.g. Agaves) build up food for a number of years, produce a huge display of flowers and then die (or at least the flowering rosette(s) dies and it tends to take it several years for another rosette to reach flowering size). Cacti don’t do this either and flower every year, sometimes multiple times a year or over a long period, in good conditions.
Cactus flowers are produced singly (not in clusters each flower being attached to the stem separately although a plant may produce many flowers at once) and lack peduncles (stalks) (except for Pereskia but we’re not talking about them). OK a few of the Cylindropuntias bear flowers on their fruit producing chains of fruits. They tend to be big and showy with lots of petals and stamens and don’t have much in the way of obvious water saving adaptations. They are normally produced from the areoles (i.e. they are axillery and don’t stop the stem from growing more). Very few cacti have terminal flowers (Pterocactus are famous for it) and some can have axillary or terminal flowers (e.g. Echinocereus subgenus Wilcoxia). As there’s no peduncle, cactus flowers often have tubes made of tepals to hold the open end away from the plant (and perhaps to get clear of the spines). In some cacti the spines are so long that they stop the flowers from opening properly. Some like Cleistocactus have long, tube shaped flowers, perhaps an adaptation to conserve water (it’s also an adaptation for pollination by humming birds). Many cactus flowers have areoles with spines and/or hair on the outside (often completely covering the bud before it opens and presumably protecting the developing fruit). If this was a big advantage, you’d expect all cacti to do it, but this isn’t the case. Mediolobivias (a group sometimes given their own genus but often included in Rebutia, Lobivia or Echinopsis) have hairy flower buds but the similar Rebutias (obviously not including Mediolobivia or Aylostera the classification of this group of cacti is a confusing mess) don’t. Similarly if Echioncereus need spiny flowers, why don’t most other globular, North American cacti?
We’ve already mentioned cephalia. There are only found in the sub family cactoideae and then only on certain members. They’re mostly produced on cacti that grow large and/or are from more tropical climates (which tends to make them harder to cultivate but ironically it could make them better house plants as they don’t need a cool resting period). Therefore it’s fairly rare to see a cactus with a cephalium in a colder climate (although nowdays you are getting Discocacti and Melocacti with cephalia in garden centers). There are two main types: terminal where the cepalium is at the top (e.g. Melocactus, Discocactus, Arrojadoa), and lateral. Latereral cephalia are also at the top but only on one side (e.g. Buiningia, Espostoa).
Flowering at night is sometimes pointed to as a water saving adaptation. Indeed some cacti (and other succulents) do flower at night. If this was a good way to save water, you’d expect night flowering to be commoner in small cacti, which have a higher surface area to volume ratio. In reality it’s more common in larger cacti and there are only a handful of small night-flowering cacti (most Echinopsis, if you exclude things like Lobivia and Trichocereus this is that group with confusing classification again – confuse things but having their flowers open day and night). Also there are quiet a few night flowering rain forest cacti.
Another water saving flower feature is to short circuit sexual reproduction and go straight from bud to fruit without the open flower stage. This obviously has drawbacks related to inbreeding and limiting genetic diversity. This is a feature of some of the smallest cacti, Blossfeldia and Frailea. Even these open their flowers sometimes.
Cactus fruits are quiet varied. Many are fleshy, brightly coloured and obviously meant to be eaten. Some split open to release the seeds. Some are just dried capsules (e.g. Rebutia, Frailea, Opuntia polyacantha), presumably economical on water but how to do they distribute seeds? Pterocactus have winged seeds, designed to be blown by the wind but this is unique to this genus. Most Mammillarias have small, brightly coloured berries but a few (e.g. M. saboae) retain their seeds in the stem and they trickle out slowly. Most cactus seeds are small, roundish and brown or black rather uninteresting, at least without a high powered microscope.
The adaptations of seeds to a desert environment are poorly understood. Most cactus seeds germinate fairly easily (in cultivation) and will remain viable for several years. Some seems to have to age a bit before it will germinate. Some (e.g. Frailea) goes off very quickly. Opuntoideae seed is notoriously difficult to germinate, perhaps because they need to be frozen or passed through an animal’s digestive tract. Why? How does this help these plants survive? There are some cacti (e.g. Cylindropuntia davisii) that don’t seem able to reproduce by seeds and rely on vegitative reproduction. There are a number of others where they probably reproduce asexually a lot of the time (e.g. Opuntia fragilis).
Cactus seedlings aren’t very tolerant of drying out. Those of larger cactiodeae have obvious cotyledons (seed leaves). Those of smaller cactoideae usually have the stem and cotyledons fused into a round blob. Other sub-families have fairly normal looking dicot seedlings, just normally with fleshier cotyledons. It’s likely that in habitat a cactus seedling will only successfully grow to adulthood if it has a prolonged period of wet to get it going. It may be that cacti rely on producing large number of seeds rather than having seedlings that are well adapted to survival. Maybe the spines help in some way that isn’t obvious in cultivation.
There are some less obvious adaptations in some or most cacti. Nearly all cacti have CAM (Crassulacean Acid Metabolism). This means that they can open their stromata (breathing holes) at night, to reduce evaporation, store carbon dioxide as organic acids and then use photosynthesis to convert it to carbohydrates and oxygen during the day. Many have red or purple betacyanin pigments to protect them from bright sunlight. Normally the plant becomes more red when it’s in bright light or is short of water. However a few are purplish brown normally. Some (particularly Coryphantha and Ferocactus) have nectar-secreting glands on the stems, apparently to attract ants to carry away the seeds. No cactus is terribly poisonous (some of the other succulents are) but some have foul tasting alkaloids that can be hallucinogenic (Lophophora willamsii is the most notorious for this). Then some cacti seem to adapt extraordinarily well to different environments. Opuntia fraglis is found over much of North America including parts of Canada. Many cacti seem able to survive or even thrive in conditions in cultivation that are very different from its habitat.
Obviously those cacti that grow in deserts are adapted to do so. Some of these adaptations are obvious but some are less clear and many things aren’t understood.