[erlang-questions] Binary string literal syntax
Loïc Hoguin
essen@REDACTED
Thu Jun 7 12:15:52 CEST 2018
On 06/07/2018 11:57 AM, Sean Hinde wrote:
>>>> Sure, most people have no clue how to program sockets these days so they use HTTP for everything -- but that isn't *most* protocols, that's a relatively small set of overwhelmingly *prolific* protocols. My prediction is that binary protocols will become more prolific as the extremely limited shared resource of wireless bandwidth becomes more and more saturated (and I don't think compression is a fix-all here, though it certainly helps).
>>> I don’t think it really matters how we count. Text based protocols are here and Erlang ought to provide a great programming environment for them too.
>>
>> But they're on the way out. You won't find many new text-based protocols, and for good reasons. Even HTTP/2 went binary (and QUIC/HTTP will do the same).
>>
>> Plain-text is still king for content, but the trend has been toward binaries in recent years. Look at the number of binary serialization formats that popped up. Of course, it will be harder to take over JSON.
>
> Even as an old school telecom protocols guy I’m not sure I really like this move for web based protocols. It’s nice to be able to read a protocol as text - however good one gets at reading hex dumps. HTTP Headers are a minuscule percentage of internet traffic which is dominated by video.
>
> In any case these things tend to have pendulum like properties :)
Perhaps.
I don't think the "I can read it" argument is a good reason to go one
way or the other though. You can read debug, trace or wireshark output
just fine. And the protocol being text is not necessarily helpful
because of two reasons.
One is invisible characters, which requires you to make sure you can see
them when debugging anyway (using \n instead of \r\n for example).
The other is that on content like JSON, unless your payload is small
you're not going to be able to parse it in your head anyway, so you'll
need tools to make sense of it. Same reason why developer tools are so
useful when writing HTML/CSS.
Ultimately I think a language should be good at both, and I think Erlang
is doing a fine job at parsing both text and binary. The <<"syntax">> is
certainly unfortunate for binary strings, even more so when Unicode is
required. I'm not sure this is something that should be fixed at the
language level though. Some editors put a ) when you write (, perhaps
they should also put >> when you write <<, with or without double
quotes. Perhaps they already do? It's a strategy that's worked well for
more verbose languages like C++ and Java I think.
--
Loïc Hoguin
https://ninenines.eu
More information about the erlang-questions
mailing list