What do you get when you grind up sulfur, potassium nitrate and charcoal and mix vigorously? Gunpowder.

The key ingredient in fireworks was invented in the ninth century by the Chinese to ward off evil spirits. Ever since then fireworks have been real crowd pleasers. They do however carry an element of risk. Rockets crash and fireworks are sometimes dangerous. Even the most benign variety, the deceptive sparkler, spits out a shower of 1,800-degree sparks. Ouch.

That doesn’t deter us. Studies show that when dangerous behavior feels rewarding, it releases dopamine, the brain’s pleasure chemical.

Fireworks have also been used to express patriotism. John Adams believed our national birthday “ought to be solemnized with pomp and parade, with shows, games, sports, guns, bells, bonfires and illuminations from one end of this continent to the other.”

You wonder what John would have made of July 4th, 2018. Would he be worrying about the fate of his beloved country?

Some adults are made uncomfortable by the unpredictable gap between the flash of fireworks and their explosion, the suspense-filled moment between expectation and reality. Dogs and young children are often overwhelmed by the noise.

Others might agree with Oak Bluffs fire chief John Rose, who grows nostalgic when he recalls fireworks from when he was a boy. He remembers the excitement and still enjoys the big cannons. “You can feel the percussion as it ricochets across the buildings,” he says.

Fire chief Simon Bollin of Aquinnah is more matter of fact. “To me, they’re no big deal,” he says. “I enjoy fireworks as much as anybody, but I’ve been around them my whole life.”

Then there’s the aesthetics of the whole shebang. Usually, the colors we see are created by light bouncing off reflective surfaces. As we grow older, we become more proficient at unscrambling these colors in our brains. Not so with fireworks, which seem otherworldly, especially when their canvas is a black sky.

There are 22 varieties of fireworks to choose from: Roman candles, peonies (the most popular), parachutes, rockers and spinners, to name a few, and the very latest: the gender reveal. It’s true, and a riff on the trendy party put on by expectant couples nowadays in which the sex of the baby is announced. Why not ignite a firework that will explode into the sky in a burst of pink or blue and shower you with the appropriate color confetti? Just $35 plus tax.

There are hundreds of other nontraditional names of fireworks: Scarface, nuclear sunrise, anxiety attack, neighbor hater and grounds for divorce. Who comes up with them? The manufacturers of fireworks for one, and then there are those who have chosen to devote their lives to them: students studying fireworks in the 10 U.S. college programs offering pyrotechnical programs, some of whom even grant PhDs in explosives engineering.

Once fireworks explode, there’s no turning back. They cast a mysterious spell. Consider the sounds: the puff of smoke and fading hiss, the sputter and the flutter, the whistle and the hum, the booming echo, the mere whisper, and what George Plimpton (who was a demolitions technician in World War II and a lover of fireworks) refers to as a “kind of harrumphing.” (True story: Plimpton’s gift to Caroline Kennedy and Ed Schlossberg on the night of their wedding in Aquinnah was a fireworks display.)

How fitting that fireworks attract a large audience and at the end, a grand finale.

It seems a worthwhile occupation to turn our eyes to the sky and wait for night to fall, to allow ourselves to be moved by these dazzling lights, to raucously whoop and cheer as we salute them and still choose to celebrate our country.

Ted Sutton lives in Newton and Aquinnah.