Protos or a custom wire protocol would be far better suited to the task.
Protos or a custom wire protocol would be far better suited to the task.
Moving to a binary format would be better for 99.9% of users and would be a slight inconvenience to a few people creating bots. Discord could easily publish a library for reading the format if needed.
Also how much can you realistically win when the payload for small messages where the difference matters are text?
Custom protocol would be binary.
They could make a custom extension but it wouldn’t be that easy.
I worked on browser devtools for IE and edge.
Even chrome/vscode use jsonrpc over websockets for ease of development.
IIRC it’s used in the desktop client and some community libraries (specifically JDA) have support for it.
There were some quirks regarding ETF usage with Discord’s Gateway but I can’t recall at the moment.
To a second approximation it gets more complicated. Atoms can save you some repetition of what would otherwise be strings, because they are effectively interned strings and get passed as tagged integers under the hood, but it's fairly redundant to what compression would get you anyhow, and erlang term representations of things like dictionaries can be quite rough:
3> dict:from_list([{a, 1}, {b, 2}]).
{dict,2,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
{{[],
[[a|1]],
[[b|2]],
[],[],[],[],[],[],[],[],[],[],[],[],[]}}}
Even with compression that's a loss compared to '{"a":1,"b":2}'.Plus, even if you're stuck to JSON one of the first things you do is shorten all your keys to the point they're as efficient as tagged integers on the wire anyhow ("double-quote x double-quote" can even beat an integer, that's only 3 bytes). Doesn't take a genius to note that "the_message_after_it_has_been_formatted_by_the_markdown_processor" can be tightened up a bit if bandwidth is tight.
It isn't clearly a loss over JSON but it is certainly not a clear win either. If you're converting from naive Erlang terms to some communication protocol encoding you're already paying for a total conversion and you might as well choose from the full set of option at that point.
Does this change anything w.r.t your response?