You're out in the desert, in your local botanic garden, or sitting in your eccentric neighbor's oddly landscaped yard. You take a step backward and feel a sharp pain in your calf. You turn: a plant with swollen stems and sharp spines has invaded your personal space, puncturing your skin. You suppress a curse, opting for something milder. "Stupid cactus!"
But is it a cactus? Maybe not.
The name "cactus" is commonly applied to just about any plant that has succulent, swollen parts, especially if those parts carry painfully sharp bits. Often enough, though, those armored succulent plants aren't any more closely related to cacti than they are to, say, onions or apple trees. A cactus is a member of a specific family of plants, and there are plenty of spiny, thorny succculents that don't qualify.
Take a quick look through Flickr's archives and you'll see plenty of examples. In my first search this morning on the word "cactus," for instance, this clumping aloe ground cover was the very first result, labeled "cactus green."
Aloes share the succulent form many cacti have, and some species of aloes have formidable spines. But they are only distantly related to cacti. The most recent common ancestor of aloes and cacti lived back in the Jurassic, somewhere between 130 and 170 million years ago, it's thought. Speaking strictly in terms of the most recent common ancestors, you and I are much more closely related to aardvarks than aloes are to cacti.
Agaves are another plant often mislabeled as cacti, as for example in this lovely photo, labeled "cactus in black and white":
Succulent, spines, and yet not a cactus. Agaves and aloes are pretty closely related themselves, compared to cacti: they're both assigned to the order Asparagales. An order is the taxonomic unit one step above "family." And yet agaves and aloes are still fairly remotely related. Agaves evolved in the Americas, while aloes are generally found in Africa, Arabia, and some neighboring islands.
What else gets called a "cactus" that isn't? Well, Joshua trees and other yuccas, for one thing. Spineless succulents such as Lithops, Echeverria, Haworthia, and Stapelia get so misnamed. Ocotillos are often called cacti, even though they're not particularly succulent.
The biggest group of plants wrongly called "cacti" would have to be the succulent Euphorbias, some of which can take in people that would never mistake a yucca for a cactus:
In this case, the photographer labeled the plant correctly, though personally I'd have had to look twice.
So we have all of these plants that are varying degrees of unrelated, and yet they tend to share two attributes: most of them are succulent, and most of them have defensive spines, thorns, or other poky parts. What gives?
Evolution is what gives. More specifically, a type of evolution called "convergent evolution," in which basically unrelated species contending with similar conditions over time evolve similar strategies for dealing with them.
What these plants all have in common besides their fat juicy parts and their armaments is that most of them evolved in places where water is scarce. Plants that could store as much water as possible in their stems, leaves, and roots are more likely to survive long dry spells than those that can't.
And once you have a lot of water stored in your tissues, you need to keep it there. One of your biggest problems will be that there are animals wandering around who'd love to take your water away from you by eating those succulent plant parts. Anything you can do to deter those hungry and thirsty animals will help you survive to reproduce.
In other words, becoming an armored succulent is a proven strategy for enduring arid climates. It's not surprising that a wide number of unrelated plants have hit on that strategy.
So how do you tell if a plant's really a cactus?
One way is to think about which plant part is which. The succulent parts of aloes, agaves, yuccas, and many other garden succulents are modified leaves. Cactus succulent parts are modified stems, for the most part. Most cacti don't have leaves, and if they do they're easily identified as such, little ephemeral green things growing laterally from succulent stems.
Prickly pear pads are often called "leaves," but leaves rarely grow other leaves on them. Those flat pads are modified stems. Leaf succulents tend either to have anatomies just like other trees and shrubs, only fatter, like jade plants, or their leaves grow in spirally rosettes, as with yuccas and aloes and agaves. If you find a plant that has a rosette of what look like they might have evolved from leaves, it's almost certainly not a cactus.
Almost certainly, but not a slam dunk: there''s a cute cactus species called Leuchtenbergia principis that has elongated non-leaf stem bumps called "tubercles," and it can look like a rosette leaf succulent. Just to keep things nuanced.
The easiest, most fool-proof way to tell if something's a cactus is to see where the spines are growing. Cactus spines are modified leaves, and they almost uniformly grow out of a special "organ" unique to cacti called an areole. An areole is a little patch, generally raised and of a woolly or hairy appearance (but don't touch it to make sure), and every spine you see on a cactus will be growing out of one. Sometimes the areole will be hard to see, worn away by the elements, but it'll be there if you know what you're looking for, and only cacti have them.
Once you know what an areole looks like, even the cactus-mimic euphorbias won't fool you. Which is a good thing. There are a lot of spiny plants out here in the desert, and you don't want to inadvertently swear at the wrong one.