At Whitbread, whose Chiswell Street premises, on the edge on the City of London proper (the "Square Mile"), was one of the top two or three London porter breweries, in 1805 the firm used 160 quarters of pale malt and 56 quarters of brown malt to make both its porter and single stout, and 136 quarters of pale together with 40 each of amber and brown malt to make its double stout. From these 216 quarters of malt it would make 798 barrels of porter (3.7 barrels to the quarter, around 6 per cent alcohol by volume), or 720 barrels of single stout (7 per cent abv or so) or 580 barrels of double stout (2.7 barrels to the quarter, around 8 per cent abv).
Four decades later, in 1844, the Whitbread brewing books show it was making five different black beers: porter, KP (keeping porter), single stout, double stout and triple stout, all from pale malt and brown malt only, in a ratio of approximately three quarters pale to one of brown. The stouts were generally parti-gyled with one or other of the porters, that is, the stout was made from a first, strong mashing, while the porter was made from a second mashing of the same grain, possibly mixed with a third or four mashing. The only difference between the stout and the porter, therefore, was in strength.
Ron Pattinson's research shows that in the second half of the 19th century, London brewers' recipes for porter and stout began to diverge – but the stouts were now getting LESS patent malt, where used, than the porters, and more brown malt, with the probable result that the stouts were becoming sweeter and less dry than the weaker porters.
Roasted barley became a permitted ingredient in beers in the United Kingdom (which still included Ireland at this time) in 1880, with the passing of the Free Mash Tun Act. However, there was no rush to start using it: one writer in 1885 insisted that roasted barley did not give as permanent a colour as roasted malt, and "the flavour is also very inferior; and the aroma can bear no comparison." Guinness in particular does not appear to start using roasted barley in its stouts until around 1930.
The First World War, and the high taxes and restrictions on beer that it brought, did terrible and permanent damage to the strengths of beers in the British Isles, and by the 1920s porters were down on average to around 3.6 per cent alcohol by volume, and stouts to only 4.7 per cent or so. Guinness Extra Stout, which had been around 7.7 per cent alcohol in the 19th century, was down to 4.4 per cent in the 1930s.
When the "small brewer revolution" started in Britain and the United States in the 1970s, there was more than 250 years of different styles and strengths of stout and porter to choose from, and different brewers picked different sorts to recreate. The result is that, in some cases, some brewers now brew "porters" that are stronger than their stouts. The need to categorise beers for brewing competitions in the U.S. has meant a plethora of micro-managed style descriptions, few of which, however, have any historic validity.
The answer to the question: "What's the difference between a stout and a porter" is that originally a stout was simply a strong version of porter: today the difference is whatever you want it to be.