Communism is bad at short term and long term allocation. I should have explicitly said that; my comment was misleading without it. (Cuban exception aside: they are indeed good at soil management, but they were more or less
forced into learning to be good due to total economic collapse + lack of inputs required for intensive/destructive agriculture. In general communism was an ecological disaster)
I'm actually not sure we can easily include some externalities in capitalism, and I've worried it's an achilles heel of the system. I say this as a capitalist.
Specifically, the transaction costs of including small externalities are too high. By small, I mean that if I burn a litre of gasoline, I have harmed every human on the planet by an incredibly small margin. Too small to properly charge.
In that specific example, a carbon tax could fix it. But, there are many such externalities. Many harder to measure than carbon burning (which is hard in itself).
Other things equal, if it is cheaper to ignore an externality, the system will gravitate to those solutions. And with computers, globalization and cheap container shipping, it has become much easier and much faster to optimize the system. Such optimizations are mostly excellent (I am a capitalist), but we're also optimizing the system in ways which produce negative externalities as well.