[erlang-questions] Binary string literal syntax

Sean Hinde sean.hinde@REDACTED
Wed Jun 6 10:01:38 CEST 2018



> On 6 Jun 2018, at 00:45, zxq9@REDACTED wrote:
> 
> On 2018年6月5日火曜日 19時51分32秒 JST Sean Hinde wrote:
>> I’ve been writing a lot of Elixir over the last few months (plus Swift, Java, C) and just came back to Erlang. There are a few things I’ve come to very much like about Elixir I think might be quite useful to bring to Erlang.
>> 
>> The first, and topic of this email, is arguably trivial, but having to surround <<“modern”>> string literals with <<>> is irritating and not getting any less so.
> 
> I like ideas such as this but believe the core language is not the place to implement them.
> 
> Syntax is like ocean plastic -- it lingers forever, works its way into unexpected places and interacts with the metabolism in surprising ways. Adding syntax to an existing language, especially syntax that represents something that is already one can represent, is *dangerous*. It makes the overall language less useful and each addition dramatically increases the cognitive overhead of learning the language.

I have happy memories of waiting eagerly each year to see what new things would be added to the language. The bit syntax was a truly stunning addition. When sometime later the ability to write literal strings inside a binary was added it was pretty convenient.

The Erlang team has not shied away from adding features where they push the language forward in its practicality for dealing with the protocol related problems of the day.

Back then it was bit twiddling, these days protocols are more string based.

> 
> Typing two different characters two times each, as in <<>> does not exhibit much advantage in keystrokiness over typing a widely gapped sequence ~s''. Magical quote interpretation, as in Python, to avoid the need to escape one or the other kinds of quote literals within a string is handy, but doesn't change much about the difficulty of the language. As Erlang already makes a distinction between single and double quotes, though, diddling with this is a dangerous change (adding syntax) in the interest of glyphy familiarity.

Keystroke saving was not really a motivation, though having to add them at both ends of a string is a bunch of navigation as well as the extra keystrokes.

> 
> Erlang is a small language. A large part of its utility stems from the fact that the core language is TINY and not littered with a ton of conveniences. This should be strongly protected. Compare the universal readability of C vs the wetware-level incompatibilty among various styles of C++ (or Haskell, for that matter); that's astonishing and sad about C++.
> 
> If Elixir does what you like, then use it. There is a strong chance that Elixir will explore so much in terms of language conveniences that it will blow up the way C++, Ruby, and Perl have. That's fine, because we'll learn a lot and Elixir's grandchildren will really be something! Introducing Elixirisms into Erlang, a stick-in-the-mud, traditional, old, venerable language with a very low learning curve at the level of language complexity, is purely a risk.

I guess there is some risk that adding a nicer way to write binary strings would break the camel’s back and make the language more difficult to learn.

I happen to believe that this change would have the opposite affect. It ought to reduce the cognitive overhead for newcomers to the language (“Why do I have to write these weird angle brackets just to get a ‘normal’ string?”), and make the choice between the two string forms less biased by syntax and more based on utility for the rest of us.

I can see your point for the full scope of Elixir sigils, but I think there is a level of addition that would simply just help. Maybe just the #”Syntax"

> 
> I'm an Erlang conservationist. Don't corrupt the pristine Erlagnessness with your stays-around-forever-like-marine-plastic syntactic litter!

lol. I also love the considered pace of language additions. Maps took a pretty long time to finalise and they have turned out nice. Having written a decent amount of C++ in the last 10 years I am the last person who would want to wish that on the language :)

> 
> -Craig
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list