What can Foursquare can tell us about urban design, complexity, and the future of smart cities? Anthony Townsend of the Institute for the Future looks at the digital lattices of our concrete canyons in this excerpt from his new book just out today, Smart Cities: Big Data, Civil Hackers, and the Quest for a New Utopia.

"There is some essential ingredient missing from artificial cities," wrote Christopher Alexander in Architectural Forum in the spring of 1965. "When compared with ancient cities that have acquired the patina of life, our modern attempts to create cities artificially are, from a human point of view, entirely unsuccessful." But as much as Alexander revered what he called "natural cities," the appealing ones that had evolved "more or less spontaneously over many, many years," he had little patience for critics like Jane Jacobs who, he argued, "wants the great modern city to be a sort of mixture between Greenwich Village and some Italian hill town." Alexander didn't want to replicate only the appearance of those ancient cities, but rather their DNA. "too many designers today seem to be yearning for the physical and plastic characteristics of the past. . . . they merely imitate the appearance of the old, its concrete substance: they fail to unearth its inner nature."

Alexander was well equipped to see order in the vast complexity of great cities. Though a professor in the College of Environmental Design at the University of California, Berkeley, he was trained as a mathematician and saw the structure and dynamics of the city through mathematical analogies. To Alexander, the sprawl of postwar suburbia, with its single-use zones and cul de sacs, looked structurally like "trees." In a tree, individual pieces link together up and down in a rigid branching hierarchy, but there are no connections between branches. For Alexander, the architecture and layout of these artificial cities imposed too much top-down order, their individual elements nested like russian dolls, with each subcomponent enclosed and isolated from those around it.

But "a city is not a tree," Alexander argued in the title of the essay. Cities that develop organically over time possess a rich web of overlapping connections, which to his mathematical brain looked like a semi-lattice. (For simplicity's sake we'll just use the lay term lattice here.) In a lattice, individual elements can be a part of many different sets. They can link up into a hierarchy, or cross-connect in flatter networks.

To explain how lattices worked to create the richness of interactions that he found lacking in modern communities, Alexander described a newspaper rack outside a drugstore near his office in Berkeley. Nominally part of the shop, it became a vital part of the street corner whenever pedestrians waited for the light to change and lingered to peek at the headlines. "this effect makes the newsrack and the traffic light interdependent," he argued. the newsrack, the people, the sidewalk, even the electrical impulses that controlled the traffic signal were woven together in networks of surprising complexity that formed a distinct urban place. Lattices are why the fine- grained hubbub of Greenwich Village or Florence feels so rich and full of wonder, and the single-use suburbs of Los angeles so empty and banal.

What plagued artificial designs, Alexander argued, was that their hierarchical structure fought against complexity. In theory, because elements in a semi-lattice can be combined with any others, "a tree based on 20 elements can contain at most 19 further subsets of the 20, while a semi-lattice based on the same 20 elements can contain more than one million different subsets." Compare a map of an old, great city with the layout of a modern auto-centric suburb and you will see this clearly. the city is a crisscross of streets and public spaces; there are many ways one could travel across it between any set of two points, interacting with different people, places, and things along the way. But in the suburb, the branching hierarchy of arterials and feeder roads constrains you to a single path. the city is an open grid of possibilities, the suburb a universe of dead ends. "it is this lack of structural complexity, characteristic of trees, which is crippling our conceptions of the city," he wrote. As a remedy, over the next decade alexander and his colleagues studied traditional cities around the world, distilling their timeless design elements—"the unchanging receptacle in which the changing parts of the system . . . can work together," as he had described the corner in Berkeley. The results, published in 1977 as A Pattern Language, were a crib sheet for lattice-friendly city building.

Standing outside the St. Mark's Ale House in 2011, almost ten years to the day after I first encountered the pioneering location-based social networking app Dodgeball, I browsed the East Village's lattice with my iPhone using Dodgeball inventor Dennis Crowley's newest app, Foursquare. Alexander's ideas about trees, lattices, and patterns have lingered on the margins of architecture and urban design since the 1970s. But they had an enormous impact on computer science, where his writings inspired the development of object-oriented programming. Its philosophy of modular, reusable pieces of code that can be brought together in useful semi-lattices—much like the objects on Alexander's street corner—dominates software design to this day, including the computer language used by iPhone app developers (Objective-C). A fifty-year feedback loop closed as I realized that Alexander's vision of the city as a lattice underpinned the design of the software that now filtered my own view of it.

Foursquare had turned my phone into a handheld scanner that senses the meaningful bits of urban life around me. The home screen opened with a list of nearby attractions: restaurants and bars, shops, even food trucks. a large button at the top urged me to check in, as over one billion others around the world had in the last two years. With Dodgeball, you had to spell out the place you wanted to check in to, and cross your fingers that the system didn't read "Times Square" and mistakenly check you into "Times Square XXX Theater." With Foursquare, putting your pin on the map involves one simple click to select the venue from an automatically populated list of nearby places, and one more to plant your flag.

Digging deeper into the lattice, clicking on people who are checked in at nearby places, I found friends who had recently visited, photos they'd taken, and twitter-sized tips about things I should do or eat. The app's Radar feature scanned constantly in the background, and chirped an alert about a nearby coffee shop i wanted to check out. It's on a "list" I was following, a scripted guide created by a friend. Lists let you curate collections of places for others to explore— "Best Burgers in NYC" or "Chelsea Art Galleries," for instance. By design, Foursquare was here to do penance for the spontaneity- sapping and serendipity-killing devices of the digital revolution that immerse us in messages from elsewhere as we shamble down the street, oblivious to the world around us. Even more effectively than Dodgeball, Foursquare draped a new digital lattice atop the city's physical one, and connected the two with code. It was perhaps the one piece of software that could turn a skeptical Christopher Alexander into a believer.

Excerpted from SMART CITIES: Big Data, Civil Hackers, and the Quest for a New Utopia by Anthony M. Townsend. Copyright (C) 2013 by Anthony M. Townsend. With the permission of the publisher, W.W. Norton & Company, Inc.

9780393082876 300

photo: Doc Searls, "Top to bottom: New Jersey, Hudson River (with the George Washington Bridge crossing it), Manhattan, Bronx, Queens. The bright light is Yankee Stadium." (via Flickr)