Proper typsetting will check for lakes and rivers. I do not see mention of this so it probably is not "as good as possible".
Proper typsetting will check for lakes and rivers. I do not see mention of this so it probably is not "as good as possible".
The kind of river that is distracting is typically caused by an unfortunate combination of two things: having wide spaces between words, and having them aligned closely enough from one line to the next that the white space they cause joins up visually.
TeX's hyphenation and justification algorithm is, in simple terms, trying to optimise for even spacing throughout a paragraph, with a bias towards using the natural spacing or as close to it as possible. Notably, it can do this by increasing or decreasing the space between words. In this environment, you are much less likely to get wide spaces in the first place than if you have a typical word processor algorithm that justifies line-by-line and only by increasing space. If the spaces aren't as wide, then they are less distracting in themselves, and there is less scope for them to overlap for several lines to form the long rivers that are so distracting to the reader.
This doesn't mean that rivers are impossible using a TeX-style algorithm. It is just less likely to happen, and probably less noticeable if it does, than with a line-based H&J algorithm.
I have an old TeX reference which suggests TeX pays attention to rivers. But based on your challenge, I skimmed through the description of the line-break algorithm in Knuth's "The TeXbook," and found nothing about rivers. (There is a bit of attention paid to making sure adjacent lines are compatible in terms of how squashed or spread out they are, but apparently nothing that tries to catch rivers.)