One weekend, two festivals. What’s a critic to do?


There was Electric Zoo on Randalls Island, with nearly 12 hours of electronic dance music on four stages for three days. And there was Rock the Bells at the PNC Bank Arts Center in Holmdel, N.J., a determined effort to mix hip-hop’s past and present, scheduling 12 hours of performances on two stages. Both are on their way to becoming summertime institutions.


As Bob Dylan once sang, “Like a fool I mixed them.” I visited Electric Zoo on Friday and Saturday, with headliners including Above & Beyond, Steve Aoki, Pretty Lights, David Guetta and Axwell. Then came Rock the Bells on Sunday, featuring Nas, J. Cole, Common and an unannounced guest appearance by Lauryn Hill.


Both festivals represent the distant spawn of a shared ancestor: 1970s disco, which placed the disc jockey at the center of the music, using two turntables to mix, mesh and extend whatever would keep people dancing.


The D.J.’s who would eventually claim the term “electronic dance music” became scientists of looping, layering and beat-matching, and syncing up with ever more elaborate lighting systems, and they gradually shifted their position from the seclusion of the D.J. booth to the center of arena stages, pumping their hands in the air. They run their sophisticated gizmos to generate fantasies of perpetual motion and endless pleasure.


Hip-hop D.J.’s, meanwhile, became experts on the physical possibilities of needles hitting vinyl and mixer knobs being manipulated, scratching their way into the music’s foreground as percussion soloists. They also became picky archivists looking for beats and vamps, discovering the atomized beauty of tiny musical fragments and recycling them to make instantly memorable tracks. At the core, despite wizardly transformations, is a nugget of something tangible, something gritty.


Now turntables have made way for digital playback, and hip-hop D.J.’s are often flanked by both live musicians and laptops. Yet at the festivals the ancestral instincts still came through.


Electric Zoo reveled in the high-tech and the synthetic. The D.J.’s were small, peppy figures surrounded by dizzying, strobing video displays, the humans piloting the cybernetic colossus. What once was a club experience has proved to be, in geek terms, perfectly scalable to festival size; seeing the performer onstage is the least of anyone’s concerns when the music, the lights and everybody dancing are the real show. It’s a fully participatory man-made world, not just in staging but in the party gear worn by most people in the audience: fluorescent tutus and legwarmers, L.E.D.-equipped shirts and shoes, technicolor wigs and glitter adhering everywhere. Dancing skin becomes its own artificial display.


Electric Zoo’s lineup delved into various schools of dance music. Topping the commercial ranks are varieties of house music, with its four-on-the-floor beat — traceable to disco — now pumped up to seismic impact.


That giant, unsubtle stomp, at around 135 beats a minute, has made its way into Top 10 pop in recent years, and it could be heard constantly somewhere at Electric Zoo, usually on the two largest stages. Above & Beyond, a trio of producers and songwriters from England, has made the most of a pop formula with yearning, balladlike verses propelled into booming dance-floor choruses, a mechanized optimism that trio reinforces onstage by typing out uplifting text messages to appear on screen — among them, on Friday night, a tribute to Neil Armstrong.


Pop success is changing D.J. sets; instead of exploring the components of a song with on-the-spot remixes or drawing musical through lines with segues, they play jukebox sets of their own releases. In David Guetta’s dull, steady-thumping set, his idea of a remix was simply to turn down the overall volume so people in the crowd could sing lyrics — which they did, happily. Mr. Aoki didn’t have much to do as his tracks, with triumphal synthesizer lines, marched toward their programmed peaks; he spent a lot of time standing on his console tossing things into the audience, including, eventually, pieces of his stage set.


Meanwhile, there’s a growing challenge to the 135-beats-a-minute regime. It comes from dubstep, once an arty English underground movement and now — in the hands of D.J.-producers like Skrillex, one of Sunday’s headliners — a full-scale assault on the steady, shiny, orderly world of trance and house. Dubstep favors skidding, distorted basslines and sudden changes of tempo, like salvos of double-time percussion or slowdowns that sound like the music has been heaved into a tarpit. It’s a reminder of the freedom of the D.J. — who, after all, has an infinitude of sounds available. On Saturday acts like 12th Planet, a lone D.J., and the four-man Dirtyphonics used whipsaw tempo and texture changes to keep pushing dancers further, while Datsik plunged into murky, defiantly slow tracks with dub reggae foundations.