To say it has been a tough few years for coal investors would be an understatement. The stocks of Peabody Energy (BTU), Arch Coal (NYSE: ACI), and Alpha Natural Resources (NYSE: ANR) have been absolutely crushed on fears that the fossil fuel would bite the dust. Just one look at the following chart is enough to make any coal investor's stomach churn.

BTU Chart

BTU data by YCharts.

Things haven't been much better for these companies in recent weeks, either, as coal stocks were crushed earlier this month on warnings that Chinese demand isn't picking up. That being said, the commodity doesn't appear to be dead just yet. In fact, Peabody Energy's comments on its second quarter would suggest that coal's best days just might be ahead of it.

40-year high
While Peabody Energy lost money this past quarter, its revenue improved as coal continues to take global market share away from oil and gas. The company noted that coal now accounts for 30% of global energy consumption, which is its greatest contribution to the energy mix since 1970. Furthermore, Peabody Energy said it sees coal taking more market share: The world continues to turn to coal as a competitive fuel source, and that should remain the case as urbanization and industrialization trends are expected to fuel long-term demand growth.

Peabody Energy's case for coal is compelling. It noted that China's coal generation rose 5% through June and that the country's economic expansion and government stimulus programs were just starting to gain traction. It sees accelerating economic growth translating into improved steel production and increased metallurgical coal imports in the second half of this year. That has to be music to the ears of investors in Alpha Natural Resources, which is a major exporter of metallurgical coal.

Source: Peabody Energy. 

Peabody Energy also noted that India's coal generation rose 12% through the first half of the year, while its metallurgical coal imports rose 26%. It added that coal stockpiles are at extremely low levels in the country. In addition, the country's new prime minister has stated that he wants to increase coal imports as part of his plan to boost economic growth, according to Peabody Energy. That's good news for Arch Coal, which has stated that it wants to increase coal exports to India.

Japan is another market that offers cause for optimism. Because nuclear generation remains offline there following the Fukushima Daiichi disaster, and natural gas is expensive to import, Japan's only economical option is coal, which is why coal powered generation rose 9% through May. Overall, coal's share of electric generation in Japan has risen from 27% in 2011 to 35% this year.

Peabody Energy expects coal demand to rise by 600 million tonnes by 2016. Fueling this increase is the 250 gigawatts of new coal-fueled generation set to be built over the next three years, requiring another 750 million tonnes of thermal coal. However, because local production will fall short, Peabody Energy sees coal imports in India and China growing by 100 million tonnes. Needless to say, coal isn't dead yet.

The problem is the near-term outlook
While the longer-term outlook for coal looks compelling, it is challenged in the near term. Peabody Energy noted that the global seaborne marketplace for coal remains oversupplied. This is forcing producers around the world to cut back on supply, but those capacity reductions won't take hold until later this year.

Source: Peabody Energy. 

Meanwhile, coal's outlook in the U.S. is also a bit cloudy at the moment. While coal filled 92% of the incremental electricity demand in the first quarter, it faces an uphill battle to grow. The EPA's carbon dioxide emission rules, as currently proposed, would have a negative impact on coal power generation in the nation, which could have a big effect on coal production. Until there is clarity on these proposed rules, they will act as a weight on coal producers.

Investor takeaway
Coal certainly can't be counted out yet. However, its future in the United States remains uncertain, and the proposed carbon rules here, if enacted, could eventually spread abroad. That makes it particularly hard for investors to buy the global growth story, as coal stocks still have a tough uphill battle to fight.