TL;DR: Explanation of why the escape sequence for 256 color and 24 bit color modes are weird and can vary. \E[38:5:_n_m is technically the correct form for 256 color, but \E[38;5;_n_m is the form terminals more widely support.
I saw this on Hacker News today, and found the article interesting because I’d recently seen a Terminal Guide page on 256 color that mentioned how terminals support different versions of the codes (with semicolons being the most compatible). Semi-relatedly there’s XTerm’s criticism of Gnome Terminal and VTE (which is talks about compatibility in general).
If you’re using emacs, stick to the GUI unless you have good reasons not to. The GUI is more or less a smart terminal. You’re missing out on a lot of features if you opt for the terminal.