"History doesn't repeat itself, but it does rhyme." -- Mark Twain

In tech, there probably isn't an industry that looks more battered over the past 12 months than solar. Before last fall, it looked as if the good times would be here for a while: Sales were booming, prices were strong, and financing for installations was easy to come by.

Then, the recession, the credit crunch, and the slashing of Spanish subsidies all wreaked havoc on demand. At the same time, new plants and rising inventories created a capacity glut, which sent margins into a tailspin. And to top it all off, the bursting of the commodities bubble made solar's near-term value proposition less compelling.

Today, there's still optimism about solar's potential over the long run. But there's lingering pessimism about the speed of the industry's recovery, as well as concerns about its long-term profitability. Understandable fears, given what has happened. But if you fire up your time machines for a minute, you can find an example of a promising tech industry that went through an equally jarring downturn, only to wind up on sounder footing.

The DRAM disaster, and recovery
Going into 1985, the outlook for DRAM chips was a lot like that for solar going into the fall of 2007. Demand was soaring, thanks to growing computer sales by Apple (NASDAQ:AAPL) and IBM, among others. Convinced that nothing could go wrong, management in the fragmented DRAM industry aggressively invested in adding new capacity.

Unfortunately, demand in 1985 didn't pan out as expected. Computers were still pretty expensive those days -- Apple's Macintosh went for more than $5,000, inflation-adjusted -- and once an initial group of "early adopters" had bought one, the consumer market slowed down. With all of that new DRAM capacity on board, this led to soaring inventories, which in turn led to crashing prices. DRAM revenues ended up falling 55% in 1985 compared with 1984, and many smaller and/or less efficient manufacturers, including Intel (NASDAQ:INTC), Advanced Micro Devices (NYSE:AMD), and National Semiconductor, decided to get out rather than face additional losses.

As brutal as the 1985 crash was, better days did eventually arrive for the DRAM industry. As computer prices fell, hardware capabilities improved and Microsoft's Windows went mainstream, so the industry managed to quickly pick itself back up. Many of the companies that rode out the storm, such as Samsung and Micron Technology, did quite well for themselves. Micron's shares delivered a return of more than 24,000% from January 1987 to their peak in July 2000.

From DRAM to solar
From a growth standpoint, solar's long-term story could easily mirror DRAM's. Solar panels still account for only a minuscule percentage of global electricity consumption, and thanks to crashing prices of the polysilicon used to make the solar cells inside of panels, costs are becoming much more competitive with grid electricity -- even before factoring in government subsidies and tax credits. In Italy, which has plenty of sunshine and high electricity rates, solar is nearly cost-competitive already, and other markets should follow.

But just as the DRAM crash kicked out many weaker manufacturers, the solar downturn is also separating the wheat from the chaff. While a recent Credit Suisse report estimated that solar panel shipments (on a megawatt basis) would be up only 5% this year, it predicts that several companies will record shipment growth of 60% or higher for 2009. Vertically integrated Chinese manufacturers such as Trina Solar (NYSE:TSL) and Yingli Green Energy (NYSE:YGE) are faring better than less-integrated rivals such as JA Solar and Suntech Power. And the two American giants, First Solar (NASDAQ:FSLR) and SunPower (NASDAQ:SPWRA), are outperforming the industry by leveraging their technological strengths.

Two outperformers
Among vertically integrated Chinese companies, Trina Solar is a name that investors looking to join the solar bandwagon should take a look at. On a per-watt basis, Trina's manufacturing costs are among the industry's lowest. The company has translated this into one of the industry's highest gross margins (27.4% in the most recent quarter), and unlike many competitors, it has also managed to post positive free cash flow during the downturn. With further cost reductions on the horizon, Trina's margins should move higher still.

SunPower might not have the lowest manufacturing costs, but its cells are among the most efficient at converting sunlight into electricity, which means that less of them are needed for a given job. This leads to lower solar installation costs, and that has delivered some healthy pricing power. Meanwhile, SunPower's systems business, which does the actual design and installation work for large-scale solar systems (mostly using SunPower's modules), has given it a leg up on competitors that rely entirely on third parties.

SunPower's strength in the U.S. should also give it a boost as the solar tax credits and grants tied to the stimulus bill begin to make an impact. So should its leading market share in California: Thanks to plentiful sunshine and the state's own initiatives, it has become the epicenter of the American solar market. And the fact that the company has less net debt than many competing solar manufacturers should give it more financial flexibility going forward.

What about First Solar, you might ask? Its thin-film technology gives it a low cost structure and high margins, doesn't it? It sure does. But the problem is that thin-film's cost advantage comes from using very little polysilicon. With polysilicon prices crashing, that strength is eroding, and while First Solar should hold on to a pricing edge, its narrowing is going to do a number on the company's margins. First Solar still has a bright future, but unless the polysilicon trend reverses, shareholders might not benefit the way that they're hoping.