– On a busy weekday in July, Chinatown’s main drag pulsed. Families queued up at the Legend Tasty House, waiting impatiently for rolled ice cream, the line stretching out onto the street. Tourists crammed into stores selling trinkets and Chinese herbal remedies. Old people in straw hats camped out on the sidewalk, peddling produce.

Just a few blocks away, the two-year-old Chinatown Public Library, a $19.1 million, 16,000-square-foot glass behemoth, was a gleaming illustration of Chicago’s determination to preserve this ethnic enclave. The library offers English classes, but also classes in Chinese, tai chi and Cantonese opera.

Chicago’s Chinatown is growing — and becoming more Chinese — even as many other cities’ Chinatowns, along with their Little Tokyos and Koreatowns, are starting to shrink in the face of encroaching development.

People who want to preserve ethnic enclaves such as Chicago’s Chinatown say they provide essential social networks to newcomers and established residents alike. They also provide vital tourism dollars to their cities, and their businesses serve as “the No. 1 job creators,” said Seema Agnani, executive director of the National Coalition for Asian Pacific American Community Development.

“What distinguishes a really exciting city from the same old, same old? It’s the character of its people,” said Teresa Cordova, director of the Great Cities Institute at the University of Illinois, Chicago. “Ethnic enclaves are a part of that.”

But scholars have long debated the role of traditional ethnic enclaves. Some see the neighborhoods as evidence that immigrants have failed to integrate into the larger society. Some research has shown that immigrants who cluster in the neighborhoods are less likely to learn English, adapt to the customs of a new country, or climb the economic ladder.

Some people flourish in these enclaves, while others struggle, said Kay Hymowitz, a senior fellow at the Manhattan Institute, a conservative think tank, and the author of “The New Brooklyn: What It Takes to Bring a City Back.”

Recent immigrants are among those who tend to benefit from settling in these neighborhoods, particularly in the U.S., which does not have policies in place that ease immigrants’ assimilation, said Brigitte Waldorf, a Purdue University professor who studies immigration.

“Living among other immigrants from the same origin country can provide much needed assimilation assistance,” Waldorf said, such as encouraging newcomers to become citizens — and helping them to achieve that goal.

But as the upper-middle class returns to U.S. cities, gentrification is putting new pressure on these communities. Many highly paid workers are being drawn to urban neighborhoods that traditionally housed lower-income, working-class immigrants. Demand exceeds supply, which may make some displacement inevitable, she said.

“If I were a policymaker, I would try to find a middle ground that allowed for development and newcomer talent to come in” while preserving diversity, Hymowitz said. “That’s what you need to keep a city growing and thriving.”

It’s a familiar American story: New immigrants settle in densely packed, inner-city neighborhoods with other people from back home. And as they prosper, they move on.

Chinatowns from San Francisco to Boston sprang up in response to segregation, redlining and other forms of housing discrimination, said Gen Fujioka, policy director for the Chinatown Community Development Center in San Francisco. “People have to start somewhere,” Fujioka said. “And these neighborhoods have been important gateways to America.”

These days, most Greektowns in urban centers are Greek in name only, save for a restaurant or two. Los Angeles’ Koreatown is mostly Latino.

Over the years, many cities’ Chinatowns deteriorated as residents left for suburban pastures. Many Chinese-American residents fled the Washington, D.C., Chinatown in the wake of the 1968 riots, settling in nearby suburbs.

Today, city dwellers are giving those neighborhoods a second look. Ethnic enclaves are often located close to downtown, which makes them attractive for developers.

Median rents in Chinatowns across the country increased by nearly three-quarters between 2010 and 2014, compared to the national median of about half, according to a 2016 report.

White populations in Chinatowns in Boston and Philadelphia doubled in the last decade as the overall white populations in those cities decreased, according to a 2013 report by the Asian American Legal Defense and Education Fund. In New York’s Chinatown in Manhattan, where luxury high-rises are sprouting, whites were the only group whose population increased.

In Washington’s Chinatown, fewer than 300 Chinese residents remain, a decrease of more than a third since 2000. The median price for condos is $510,000, making it one of the most expensive neighborhoods in the city.

In San Francisco, which has the most expensive real estate in the country, the Chinese population in Chinatown declined 12 percent between 2010 and 2015, while the white, non-Latino population increased 21 percent, according to a Stateline analysis of census data. In New York’s Chinatown, the Chinese population decreased 11 percent between 2009 and 2015.

Ultimately what may keep Chicago’s Chinatown intact is that community members were able to buy land decades ago, said Janet Smith, co-director of the Voorhees Center for Neighborhood and Community Improvement at the University of Illinois at Chicago. Chicago’s real estate remains relatively affordable, compared to other cities.