[erlang-questions] Binary string literal syntax

Sean Hinde sean.hinde@REDACTED
Thu Jun 7 12:50:48 CEST 2018

>> 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.

I recall the “I can read it” argument was made at the time in part as a rebellion against the "save every bit" mentality in the communications industry standardisation.

Encryption also pretty much kills off wireshark unless you have the keys, so we are only talking about end point debugging.

But sure, it’s not a big reason.

> 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.

Without reader macros syntax can’t be fixed except at the language level (and no, I’m not arguing we should make another lisp!)

But it does feel that when the time is right we ought to be able have the nice things with elegant syntax.

BTW The Erlang mode I’m using for VSCode auto adds the closing >> (the one from Pierrick Gourlain, which is really very nice)

Also BTW I’m using REST mode of cowboy for this json based system and it’s really very nice. Thank you!


> -- 
> Loïc Hoguin
> https://ninenines.eu

More information about the erlang-questions mailing list