A devastating diagnosis led Eric Sun to find new meaning in an old pursuit. Photograph by Talia Herman for The New Yorker Audio: Listen to this story. To hear more feature stories, download the Audm app for your iPhone.

Johannes Brahms wrote his first violin sonata for his muse, the pianist Clara Schumann. He presented it to her in 1879, soon after the death of her youngest child, Felix, who was named for the composer Felix Mendelssohn and was the only violinist among Schumann’s eight children. Brahms was his godfather. The sonata, which Brahms completed at the relatively late age of forty-six, takes its theme from his own “Regenlied,” or “Rain Song,” and is a meditation on the loss of childhood innocence. The violinist Anne-Sophie Mutter, who was captivated by the work as a child, has said that it is best played by an adult. “I have a deeper understanding of music and, if you want it or not, life does leave its marks not only in your brain but in your heart and in your soul,” she said. “The understanding of things deepens.”

Eric Sun heard the Brahms piece at a violin summer camp, when he was in junior high. He’d started playing, on a child-size instrument, at the age of four, and although he didn’t really enjoy the lessons, he stuck with them, mostly to please his parents. Sun’s father, Ming-Ting Sun, and his mother, Julie, were immigrants from Taiwan who went to the University of Texas at Arlington in 1980 and later settled in New Jersey. Ming-Ting is a video-processing researcher. Julie is a certified public accountant. Eric was an only child until he was eleven, when his sister was born. By the age of three, he could recite lengthy Chinese poems from the calligraphy scrolls that hung in his home. In fourth grade, he asked to study the piano, and his teacher discovered that he had perfect pitch. When he was in seventh grade, his parents, at the suggestion of his teacher, took him to a violin dealer in Manhattan, who had a Stradivarius but wouldn’t let him touch it. Sun tried several instruments before choosing one that cost sixty-five hundred dollars. It was a financial stretch for his parents, but, as his father told me, “Education is always the top priority in our culture.”

In 1996, when Sun was thirteen, his father joined the faculty of the University of Washington, and the family moved to the Seattle area. Sun was placed in a program for students with I.Q.s over 140. Though slight of build, he was on the varsity tennis team. He also excelled at Ping-Pong. But he missed his friends in New Jersey and was slow to make new ones. Other students taunted him as a nerd.

Sun started taking lessons from Kyung Chee, a violinist with the Seattle Symphony and the Seattle Opera Orchestra. Chee told me that Sun displayed remarkable technical facility, but she often found herself urging him—sometimes even shouting at him—to play with more emotion. In 2001, as Sun’s high-school graduation approached, he asked Chee if he could play the Brahms sonata for a senior recital. She thought there were few works more ill-suited to Sun, and her response was swift and direct: “Absolutely not.”

This fall, I visited Sun and his wife, Karen Law, at their apartment, in Mountain View, California, and Sun recalled Chee’s response. He told me that he’d thought he would give up playing after graduating from high school. He pursued computer science instead, and joined Facebook in 2008, four years after it was founded. At thirty-three, he had the kind of remarkable career that makes Silicon Valley a subject of persistent fascination and envy. I had first seen Sun a few months earlier, at a chamber-music program at Stanford University, which I attended as an amateur pianist. He was still slight of build, with a shock of dark hair, and looked younger than his age. I didn’t know then that, about a year before, he had been given a diagnosis of glioblastoma, an aggressive brain cancer, and might have only months left to live. He was already making plans to give away the rare violin I’d heard him play.

In addition to his gifts for music and math, I later learned, he had an entrepreneurial streak. As a teen-ager, he’d taught himself computer programming and started a Web-hosting business, Alphapython Technologies, which he incorporated in 2000 and sold after enrolling at Stanford. There, he embarked on a double major in computer science and economics, and joined the orchestra. He met Sean Tyan, a fellow-student who took many of the same classes and, like Sun, was the child of Asian-immigrant parents and played the violin. The two became best friends and, during the spring break of their junior year, Sun, Tyan, and another friend visited Berlin, where they went to a concert featuring the young American violin prodigy Hilary Hahn. Tyan described Sun as having been “enthralled” by Hahn’s performance of Erich Korngold’s Violin Concerto in D Major, which none of them had heard before. The flashy, crowd-pleasing work foreshadows the popular film scores of John Williams, who wrote the soundtrack to “E.T.” and “Star Wars.” Watching Hahn, Sun told me, he realized for the first time “how much fun playing the violin could be.” After the concert, he bought a Hahn CD in the lobby and waited in line for her to autograph it. He became an avid follower of her blog, and read up on the instrument she used, a violin made in 1864 by a noted French craftsman and violin dealer, Jean-Baptiste Vuillaume.

Back at Stanford, Sun started studying with Dawn Harms, a member of the music faculty who was a co-concertmaster of the Oakland Symphony and a member of the San Francisco Opera Orchestra. Harms recalled, “Eric could sight-read anything, and he has natural technique. But how do you emotionally move people through your playing? That’s what we had to work on. Some people can do it, and some can’t.”

During Sun’s senior year, a friend persuaded him to enroll in Social Dances of North America I. Sun had never danced, but his musical background helped with rhythm and with memorizing steps. After mastering the basics of the waltz, the polka, and swing, he joined the committee that organizes Stanford’s Viennese Ball, an annual white-tie event. Each year, members of the committee perform an elaborately choreographed waltz to open the dance. In this group, he found a warm sense of community that had long eluded him, and forged lasting friendships.

Sun graduated with honors, in 2005, but his grade-point average in computer science was below 3.0. He had got a B-minus in the course taught by Jerry Cain, the software engineer who created Facebook’s “like” feature. He looked for a job as a computer programmer but was repeatedly rejected, and ended up working at an economic-consulting firm. He stayed on in the Stanford orchestra, and helped audition new members of the ball committee. The following year, one candidate caught his eye. She moved like a ballerina, Sun remembered: “Her form was very different from everyone else, which isn’t usually regarded as a good thing.” It was Karen Law, who had just completed a master’s degree in thermosciences, a branch of mechanical engineering. She was one of the few women in the field. That year’s waltz choreographers paired her and Sun.

Law had begun studying the violin at the age of six, and she and Sun discussed what Law refers to as “the Asian arms race: your child plays either the violin or the piano, and preferably both. Then they have to be properly equipped with the best instrument.” The goals are to instill self-discipline and a work ethic, to get into a top college, and to confer bragging rights on the parents. Law was one of three girls, and, unlike Sun, had felt no pressure from her parents to play an instrument. She told Sun, “My parents always said things like ‘Don’t do this to impress us.’ ” Law’s career goal as a mechanical engineer was to advance the cause of clean energy. Sun’s attitude, she recalled, was “That’s a nice thing to work toward—but he didn’t see much evidence of it happening.”