Although they were at one point the dominant form of rail transportation, steam locomotives have fallen out of fashion, replaced by diesel or electric locomotives filling the same role. However, there's still a role for the steam locomotive today; although they are more complex and generally less efficient than their competitors, steam-powered locomotives still have certain advantages that, in specific conditions, might make them preferable.
Advantages at High Altitude
For the same weight and horsepower, diesel locomotives are generally more efficient across a wider range of speeds and operating environments; for this reason, they quickly overtook steam engines in common freight applications. At high altitude, though, lowered air pressure means that diesel engines develop substantially less power unless they are fitted with superchargers. Because boiler pressure is relatively constant, steam engines are not really affected by high altitudes, and remain useful movers on mountainous or strongly elevated terrain.
Advantages in Fuel Flexibility
Diesel engines require a particular type of fuel to operate, whereas steam engines can use virtually anything that burns, from coal to wood or other biomass. Although diesel has a higher energy density than competing fuels, in areas where diesel is particularly expensive --- or other sources of energy are conspicuously cheaper or more accessible --- it may be more cost-effective to utilise coal-burning steam locomotives. This is useful, for instance, in countries like India or China that have large coal reserves but would have to import petroleum.
Advantages Compared to Electric Locomotives
Electric locomotives can develop large amounts of torque and don't require the deadweight of fuel that diesel and steam locomotives must carry. Because they require an external power source that must be conveyed to the train, however, electric locomotives are more expensive to develop. In areas without electric rail infrastructure, steam locomotives offer cheap, effective transportation. Notably, they continue to see mainline freight and passenger use in China, where the low cost of coal has obviated the need to develop expensive electrified rail networks.
For freight and commercial use, steam locomotives are almost always outclassed, but tourists respond positively to steam engines and a number of railways continue to operate steam locomotives for this reason. Tourism continues to drive the construction of new steam locomotives over cheaper alternatives: in 2008 a trust of private citizens in the United Kingdom finished an 18-year project to build a replica A1 steam locomotive from scratch. This locomotive, the "Tornado," now operates main-line passenger service for people looking to experience the nostalgia of a trip on a steam train.