Setting an em-dash used for parentheticals closed (with no space)—or sometimes with thin spaces—is the common American literary/academic style (Chicago Manual, APA, and MLA all prefer closed); setting it open—with full word spaces—is the common American practice in journalism (reflected in the AP style guide). Not using em-dash at all for that use, but instead using an en-dash set open is the common British practice.
Even for Americans, there are several style guidelines/modern preferences (particularly around web content) which don't guarantee the lack of spaces around an em dash. Hence even American LLMs using spaces. Ecen my natural em dash usage always included spaces as an American.
When I go to print, I use hairspace, but it’s not worth the trouble in comments.
I’m not sure I agree with using length as the metric to decide which style guide is more appropriate for comments. I’d rather follow one consistent style in general than change it depending on the type of content I’m writing.
Still, good point on the style guides targeting specific usages.
I used to love Linux's compose keys, though, where I could just press `<win>--.` to get an en dash and `<win>---` to get an em. Most of the compose combinations were guessable, like `<win>a'` for á, `<win>co` for ©.
MacOS has a great keyboard locale switcher, but the lack of real compose keys limits things. Most characters you can press and hold and get some accented versions, but it's very slow if you're typing in French or something in the EN layout. It also has a built-in character picker, which is really nice but even more slow.
Just wait until I decide to go all in on TWO-EM DASH⸺I have thought for a long time that EM DASH isn’t wide enough. Or maybe THREE-EM DASH⸻though it’s normally too wide. But alas, font support isn’t good on these so you might get bad alignment or line-height inconsistency; and I might end up wanting to surround it with THIN SPACE or HAIR SPACE, and HN mangles exotic spaces to just SPACE. :-(
(Honestly, my original comment would be improved by using TWO-EM DASH, or maybe even THREE-EM.)