Children can program Sphero, a white plastic orb, to traverse land and water. Illustration by John Hersey

At Trail Ridge Middle School, which is forty minutes north of Denver, in Longmont, the old Colorado is giving way to the new. A stuffed grizzly that once stood at the entrance has been banished to a dusky back hallway, and many of the students are the children of tech workers. On a recent weekday morning, Anna Mills, a sixth-grade science teacher, shouted from the front of the classroom, “Grab your iPads and your Spheros!” When her command didn’t work, she clapped twice, and this code was successful: her two dozen students clapped back, roughly in unison, and began getting up from their desks. Mills had divided her class into groups of three, and the leaders of each trio hurried over to a counter where ten Spheros—milky white orbs about the size of navel oranges—sat in blue charging cradles. The leaders grabbed their Spheros and hurried with the other students to the school’s former library, now known as the Digital Commons.

You tap a Sphero twice to turn it on, and it flashes three colors in quick succession; once it has established a wireless link to your iPad or your smartphone, it strobes like a fortune-teller’s crystal ball and is ready to move. A Sphero, which costs a hundred and thirty dollars, is chiefly a toy. Its “out-of-the-box experience,” to use the industry parlance, is excellent. You download an app, and, by pressing and swiping and swirling your finger on your smartphone or tablet screen, you can command the ball to travel a zippy five or so miles an hour on land. It also moves in water, though much more slowly. A Sphero can make hairpin turns, and, thanks to its gyroscope, it is aware of your location; with one gesture, you can order it to roll back to you. It will vibrate softly, like a purring cat, and you can code it to do a lot of fanciful things: dance to the “Dance of the Sugar-Plum Fairy,” perform playful flips, find its way around the things it bumps into, and blink if it falls over an edge. (It has an accelerometer.) Because it looks like an ordinary ball, it outperforms your expectations. The makers of the device, a company that is also called Sphero, are in Boulder, and at their offices I was encouraged to toss one of the balls out a second-story window. It bounced off the concrete sidewalk, hit my rental car, and came to a stop. As soon as we linked it up with a smartphone, off it rolled.

Spheros aren’t just fun; they are also an excellent teaching tool. Students have begun using them to learn everything from geometry to genetics. They can code them, too, to take a first step into computer programming. The toy’s infiltration of the classroom came about mostly by accident. Ian Bernstein and Adam Wilson, the inventors who came up with the Sphero, six years ago, were immersed in hacker culture, and they planned to disseminate portions of their code to anyone who wanted to improve on it or add to it. Eventually, they realized that if the app came with a simplified form of that code, kids would fiddle with it.

It was a fortuitous moment to create such a crossover product. The stem movement—the effort to incorporate science, technology, engineering, and mathematics into the classroom—was gaining in popularity. Educators avidly debated how to help kids transition from the analog world of early childhood to the digital world of adults. Many teachers foresaw a crisis: only sixteen per cent of high-school seniors contemplate a career in stem fields, even though the number of stem jobs is increasing rapidly. Sphero and similar toys like Lego Mindstorms—simple robots that you build and then code—have come to be seen as stops on the road to the well-salaried position of programmer.

There are objections to this framework. Putting young children in front of screens will likely make them better coders, but what will go unlearned during those hours? Education is not merely job training. And some studies suggest that the more children interact with devices the harder time they have interacting with one another. Yet technical fixes are often seductive to educators, especially a technical fix like Sphero, whose surface has two cute blue dots and an upswept blue coif, suggesting a tiny face.

Mills’s goal that day was to harness the class’s ongoing study of the environment to promote some basic programming skills. The students, in their groups of three, gathered around low tables, and Mills, projecting PowerPoint slides, described a process of “design thinking” that would be familiar to any Silicon Valley entrepreneur: “Empathize, Define, Ideate, Prototype, Test.” She reminded the students that feedback sessions should begin with such phrases as “I like” and “You all have done a great job with” rather than with criticism. The students’ tables had whiteboard surfaces, and the children wrote down conservation goals—saving gorillas from poachers, keeping sea turtles out of fishermen’s nets—and tried to ideate how a Sphero could help. “Go for volume!” Mills advised. “And include ten lines of code.”

Some students seemed reluctant to leave their analog idylls. Earlier in the environmental unit, one of the groups had constructed a sea turtle out of cardboard, and a boy asked Mills for green polyester fabric to cover it. “I love that you guys want to make your turtle, but what should we be focussing on?” she replied. “What role would a Sphero play in helping a turtle avoid a trap?” Another group wanted to use Spheros to reduce smoking and, thus, air pollution. They proposed coding their Sphero to run over and crush all the cigarettes in a house. The group that hoped to save gorillas from poachers suggested strapping a banana to their Sphero; they imagined a gorilla following its favored fruit to safety. At feedback time, Mills praised the students’ idea but asked them if it would be unwieldy to attach a lure to the device.

Soon, most of the threesomes had left the Digital Commons and headed into the school’s large atrium, where the rasp of unspooling masking tape dominated. The children were marking out simple mazes on the carpet; the nut of the exercise was to code the Sphero to navigate a course accurately. When Mills was busy elsewhere, Spheros were often skidding and skipping and rolling underfoot—a toy is a toy—but she is a talented teacher, and when she got down on the floor to review their coding the students focussed. Afterward, Mills told me that “middle-schoolers find it surprisingly difficult to understand the correlation between a numerical value and a physical movement.”

One of Sphero’s design strengths is its flexibility. You can be anything from a novice coder to a high-school computer student and still get something out of programming it. The orb’s app has a dual interface. The students in Mills’s class used simple drag-and-drop balloon commands to make their Spheros move, but by swiping on a button they could also see some of the raw computer syntax that lay behind the commands—in Oval, a subset of the canonical programming language C. The balloon command “Set heading 178 degrees” reveals itself to be “controlSystemTargetYaw = 178” in Oval.