The aim is to present an analytical framework for the analysis of trade imbalances, in which developing countries specifically benefit from trade surpluses. The production process is described as a continuum of tasks and international specialization is determined by comparative advantage. Dynamic external economies of scale affect productivity: the greater the amount of tasks performed over time in a country and the higher will be labor productivity. The difference between advanced and developing countries is in how deep the comparative advantage is rooted in each country: an advanced country has already a huge past experience, hence its productivity can increment only marginally, contrary to the gains in productivity that a developing country can obtain. Given sticky prices and a tendency for cost-minimization over the global production process rather than on keeping balanced trade balances, a misalignment in the nominal exchange rate can affect international specialization also in the long term — in developing countries. Indeed, once new tasks are in-shored in the developing country, productivity significantly increases over time, eventually reversing the comparative advantage in those new tasks. Moreover, the more productivity increases and the greater becomes the price variation required to restore the trade balance equilibrium. Hence, persistent trade imbalances might be a sign of a long-term shift in international specialization. Therefore, developing countries can acquire permanently new production tasks by keeping their currencies undervalued. Indeed, getting locked in the initial observed comparative advantage might not be the best choice: producing textile equipment forever, in line with initial observed comparative advantage, might not be beneficial in the long term — better to acquire other complex tasks that can grant productivity growth also in the long term.