(Apologies to people on mobile for the following...)
One of the things I miss about Usenet was that
nearly everyone read it with a fixed with font
so that if you choose your phrasing well so as
to make your text come out naturally perfectly
justified, it would come out that way for them
too.
English has so many synonyms and near-synonyms
for every word, and so much flexibility in the
ordering of words that you can write like this
in near real time.
You get to the end of a line, find that you're
just a little long or short, and you backtrack
just a couple words or so most of the time and
you can usually find a way that works. In this
paragraph, for instance, I was one too long in
the first line, but contracting "you are" down
to "you're" fixed it. I was short in that last
sentence, but inserting "down" fixed it.
Perfect justification by inserting extra space
is for amateurs.
Now we've got all fancy and use variable width
fonts and automatic wrapping and posting isn't
quite as fun anymore.
Give it a try. Use an editor with a fixed font
to compose your next post and try to get it to
come out perfectly justified without having to
insert extra spaces. When you paste it into HN
that will get lost, but the composing can be a
fun little English puzzle.
I read at one point that the typesetters at the New Yorker would work with the copy editors to fix cases of bad justification (huge word space, awkward hyphen). It's rare to see that kind of care, but automatic algorithms are getting better.
On topic to the original post, I implemented Knuth-style line breaking in the Android text stack (working with Anish Athalye who was an intern at the time and did the first prototype). There were a bunch of nicely tuned implementations of advanced data structures and algorithms in there.
Eric's mit video on this : https://www.youtube.com/watch?v=ENyox7kNKeY
leetcode https://leetcode.com/problems/text-justification/