The problem is that today we have a scene where there appears to be a difference between the two drinks, but nobody can agree what that difference is. Is it that stouts contain roasted barley? Is it that porters are lighter, or sweeter? Is it that stouts have patent malt in them, while porters have chocolate malt?
Historically the answer is "none of the above," and most especially it's not true that stouts have to contain roasted barley, or patent malt, since stout was being brewed when roasted barley was an illegal ingredient and before patent malt was invented.
If we go back to the latter half of the 18th century and the first part of the 19th century, stout, more particularly brown stout, was simply the name for the strongest version of porter. Here's a quote from a book called "A General Dictionary of Commerce, Trade and Manufactures," published in 1810:
"Porter may be divided into two classes, namely brown-stout and porter properly so called … Brown-stout is only a fuller-bodied kind of porter than that which serves for ordinary drinking. A great deal of this is exported to America and the West Indies."
That "brown stout" simply meant "strong porter" is confirmed by a court case reported in The Times of London in 1803 over the theft of the contents of a cask of "porter, of superior quality, called Brown Stout" on its way from London to Barnsley, in Yorkshire. In court the stolen beer was described as both "remarkably fine old porter and very strong" and "excellent brown stout." Research by the beer historian Ron Pattinson among the records of London brewers in the early 19th century has shown that early 19th century brown stouts very often had identical recipes to the same brewer's porter, differing only in the amount of wort drawn off a given quantity of malt: less water was used for mashing stouts, so that they would be stronger.
Strong porter was called "brown stout" because it was still possible to find pale stout: "stout," when applied to beer, originally just meant "strong" (and the opposite word, for weak beer, was, at least occasionally, "slender"). Barclay Perkins of the Anchor brewery in Southwark, one of London's biggest porter brewers, was still brewing pale stout in 1805, made from 100 per cent pale malt, at a strength of around 7.9 per cent alcohol by volume. A brewer’s manual published around 1840 called "Every Man His Own Brewer," still referred to “stout ales” meaning strong ales in general. In 1843, Beamish and Crawford of the Cork Porter Brewery in Ireland began advertising "Bavarian Pale Stout", manufactured "under principles personally explained by Professor Liebig [a German scientist famous, at the time, for his studies of fermentation] to the manufacturers."
Patent malt, when it arrived in 1817, was specifically hailed as a way of making porter cheaper, since it could now be brewed from almost all pale malt, which gave a much better extract for the cost compared to the mixture of pale and brown malts that had been used before. While Irish brewers (or at least Guinness) went over eventually to using entirely pale malt and patent malt to make their stouts and porters, London brewers, at least, used a mixture of pale, brown and roast malts in their stouts and porters, though some continued to use just pale and brown malt.