This year, Harvard’s time-honored tradition of Class Day, the informal gathering of students, friends, and families in Tercentenary Theatre the day before the Commencement ceremony, included an interesting twist.

In the past, comedians and politicians have often taken the stage to deliver the keynote address, but typically not together. For the first time in years, two speakers — actor, writer, and comedian Andy Samberg, and U.S. Rep. Barney Frank ’61, J.D. ’77 — took turns at the outdoor dais to offer the seniors parting words of wit and wisdom.

Samberg, the lovably nerdy cast member of “Saturday Night Live,” is perhaps most famous for his humorous digital video shorts, often created with his musical comedy group The Lonely Island, who parody pop culture on the show. The comical clips have garnered him an Emmy Award and a legion of YouTube fans.

His artistic credits include the films “Friends with Benefits,” opposite Justin Timberlake and Mila Kunis, and “I Love You, Man,” opposite Paul Rudd and Jason Segel. He will star in the upcoming comedy “That’s My Boy” with Adam Sandler and Leighton Meester.

Samberg joined the ranks of SNL alumni who have delivered Class Day addresses: Amy Poehler gave last year’s, and comedians Will Ferrell and Al Franken ’73 gave the addresses in 2003 and 2002, respectively.

Samberg demonstrated his comic sense and timing from the start, strutting on stage to a song by the sultry singer Adele, and embracing one of his student introducers, Matthew DaSilva. The hug quickly morphed into a dance, and ended when Samberg kissed the surprised senior.

“What happened there?” joked Samberg. “That song is so emotional. I just met that guy!”

“I am honored to be here today, as I am unqualified,” he said. But that didn’t stop him from declaring as useless a list of majors that included “history, literature, all things related to arts, social studies, East Asian studies, pretty much anything that ends with studies” — unless they could somehow be transformed into iPhone applications.

Samberg’s presentation included spot-on impersonations of celebrities such as Mark Zuckerberg, Nicolas Cage, and Mark Wahlberg. His “message” to the graduating class included: “So, you guys are graduating. I think that’s great. We should do a film together. What do you think? You guys are super smart, right?”

Saying he was disappointed that he wasn’t receiving an honorary Harvard College degree, Samberg playfully poked fun at Harvard College Dean Evelynn M. Hammonds, who sat behind him on the stage.

“Dean Hammonds,” he pleaded. “You lied to me.”

Near the end of his remarks, he pulled from his pocket a second speech titled “Heart Stuff,” which included some harsh comments about Yale University, including, “It’s like a second-tier safety school.”

A graduate of Harvard College and Harvard Law School, U.S. Rep. Barney Frank offered up his own words of wisdom during Class Day: “Be sure that you obey every law that you have voted for.” Photo by Jon Chase/Harvard Staff Photographer

Frank, who has represented the Fourth Congressional District of Massachusetts since 1981, addressed the crowd first. A graduate of Harvard College and Harvard Law School, Frank began his political career in Boston as a top assistant to Mayor Kevin White. He served in the Massachusetts House of Representatives for eight years before winning a seat in the U.S. House. The outspoken Frank was chairman of the House Committee on Financial Services from 2007 to 2011. He remains the committee’s ranking Democrat.

Known for his work ethic, his intelligence, and his quick wit, Frank, a strong supporter of civil rights and financial regulation, was a lead author of the Dodd–Frank Wall Street Reform and Consumer Protection Act, the financial reform effort that was signed into law in 2010. He will not seek re-election this fall.

Frank offered quips as well as political points.

He cautioned graduates who are planning careers in public office never to discard a gift or trinket “within a mile of where it was given to you.” Equally important, he said, “Be sure that you obey every law that you have voted for.”

He warned the graduates not to use metaphors in public policy debates. He acknowledged that some political partisanship is inevitable, but said that idealism and pragmatism are not competing mindsets. In the end, he asked, “What good are a set of ideals if they are unrealized?”

Turning to foreign policy, Frank urged his listeners to join him in calling for the United States to end its billion dollars in regular assistance to Europe. Frank referenced Secretary of State George Marshall’s Harvard Commencement speech of 1947, during which he announced the Marshall Plan, the allied roadmap on how to rebuild Europe after World War II.

At that time, he said, Europe was “poor and hungry and defenseless, and facing a brutal Soviet Union.” The current situation is vastly different, and “65 years later, too little has changed in our policy,” he added. “America continues to commit tens of billions of dollars that we could otherwise use for very important purposes,” including education, environmental solutions, and health research.

“I hope that is an issue with which you will engage, and I look forward to at least some of you being on our side as we right the balance.”

The earliest Class Day exercises, in the early 1800s, included speakers and chapel services. But the festivities took a raucous turn in the late 1830s when the practice of “dancing on the green” around an old elm called the “Liberty Tree” was initiated.

“And at the end the Seniors danced around the Tree, all the college danced around the Tree, and the Seniors, as of old and new — proceeded to cheer the buildings,” noted an 1870 New York Times article about the festivities in 1838.

While the attendees mostly stayed in their seats this year, they did applaud and hoot and holler in acknowledgement of several speakers and award winners. The event includes a male and a female orator who deliver heartfelt addresses, and a male and a female Ivy orator, who offer more lighthearted comments.

Harvard orator Pauline Mutumwinka drew parallels from her Harvard years to “Alice’s Adventures in Wonderland” by Lewis Carroll. Freshman year, she said, felt like “falling down a rabbit hole,” as she struggled to keep pace with her peers. Later in her Harvard career, she was reminded of the hookah-smoking caterpillar who is constantly asking, “Who are you?” as she plumbed her own identity.

Ultimately, she found that Harvard “was not the wonderland where things always work like magic. It is the wonderland where we tirelessly question the beliefs and assumptions that used to define us.”

In his oration, Steven Maheshwary encouraged the graduates not to run from rejection and failure, but to embrace them with the “same enthusiasm” with which they first stepped into the Yard as they move into the next phases of their lives.

“I entreat you to seek out motivation and enthusiasm in the wake of failure.”

The Ivy orators were irreverent. Jacqueline Rossi entreated the seniors to embrace their inner weirdness, and suggested that any mistakes they made at Harvard won’t deny them access to the world of the wise. “Rather,” she quipped, “they make your life a joke that everyone can laugh at, like Buddah’s belly, or Steven Pinker’s haircut.”

Matthew Whitaker delved into Harvard’s history and mused how benefactor John Harvard might react if he knew how his original gift of 780 pounds had turned out, eventually including the birth of Facebook, the social networking site started by one of the College’s most famous dropouts.

“How confused John Harvard would be to learn that his name is associated with the world’s most popular stalking platform. I can just hear him asking, ‘What exactly is Facebook? How do I untag all these photos?’”

The Class Day ceremony also honors recipients of the Ames Award, given annually to a man and a woman from the senior class who have demonstrated “selfless, heroic and inspiring leadership” at Harvard. The award is given in honor of Richard Glover and Henry Russell Ames, brothers and Harvard students who gave their lives trying to save their father, who had fallen overboard off Newfoundland during a sailboat race in 1935. This year’s winners were Jonas Wang and Rumbidzai Mushavi.

There was also a touching tribute by Kristen Arn to Wendy Chang, who died earlier this year. Arn said Chang drew people to her easily, and was “elegant, compassionate, loyal, and sincere.”

“But perhaps most of all,” said Arn, “we loved Wendy so much because she had an incredible power to make us feel truly cared for.”

O, hear the bells