Somewhat famously, Knuth came up with a dynamic programming algorithm for breaking paragraphs into lines with full justification (both left aligned and right aligned). Later on there are of course further innovations like character protrusion and expansion to achieve that optically aligned look without much (if any) hyphenation.
The best typeset books I've seen in Devanagari (a non-Roman script, used for Sanskrit, Hindi, Marathi, Nepali) have been typeset with XeTeX (XeLaTeX). Of course this involves other system libraries like Harfbuzz to handle the kerning and measure widths of individual words, and leaves some of the complexities mentioned in the post to the user, but the Knuth–Plass algorithm from TeX is still what is at the heart of it, for breaking paragraphs into individual lines. Take a look at TUGboat and the TUG conferences or the TeX.SE website to see it being used for many languages and scripts (including Arabic, Hebrew, etc). TeX is also big in Japan it appears, and they maintain their own variant engines (ptex, eptex, uptex, euptex).
In the 80's, I did the typography design for two books with TeX and LaTeX, so it's not as if I'm unfamiliar with the stuff :) However, it is true that I haven't seen many examples of non-Roman script being well-set with TeX, so I guess I should take another look.
Not that long ago, typesetting math formulas was extremely expensive, unless you used TeX. It was not very commercial and companies were not interested but certain individuals were.
The same happened when you wanted your Hebrew or Arabic or Japanese just to look right. Japanese uses at least four scripts plus latin words in the same place.
Over time, commercial entities added support for those, most of them just incorporating TeX source code (as it was public domain). They added the visual interfaces and the easiness of use that TeX lacks.
Which four? I can only count to 3. My understanding is that all the characters are "fixed width", even the Latin ones. I imagine that makes typesetting easier, and presumably doesn't require the complexity of the Knuth algorithm.
Japanese text is often set not fixed-width in real life. If it includes non-CJK characters like Latin text and punctuation that may be proportional in a font that matches the other text, for instance.
And when you’re not talking about a book, but an ad or something like that, it’s common to have a bunch of different text sizes or make some of the words in a sentence bigger to emphasize them.
Kanji, katakana, hiragana, Arabic numerals, Latin text, and punctuation. It depends on the quality of the typesetting and the formality, but you can expect the Arabic numerals, Latin text and punctuations to have different widths than the rest. Of course it's acceptable to make everything full-width, just like in English.