Make "fewerBraces" available outside snapshot releases

My 2 cents …

I’ve worked extensively with Python, and with CoffeeScript. And have played with F# and Haskell, which also have significant white-space.

I never liked significant white-space because:

  • it can lead to situations in which the compiler gets confused, multiple interpretations being possible, as it happened in CoffeeScript; this is less of a concern in Scala, because it’s statically typed, and there are no instances in which you expect a function value and get a dictionary instead, but still, after all this time, the concern persists;
  • it can lead to the syntax becoming conservative; Python has not implemented multi-line anonymous functions, not just because of their culture, but also because it would cause trouble with existing syntax;
  • there are multiple ways to express white-space, see the endless spaces vs tabs debate, and you need smart good tooling to recognize this and do conversion on the spot, which is much easier when you have braces, and more difficult when that whitespace has meaning;
  • in Python, it led to very long lines of code, although this happened as a combination with other Python warts and practices;
  • in Python, you really need 4-space indentation, in order to visually discern where blocks begin or end; I remember experimenting with 2-spaces in my own code, and it wasn’t working well;
  • operations that are simple in Scala 2, like reformatting, or copy/pasting of blocks of code, become more complicated, increasing tooling dependence;

I don’t like that Scala switched to significant whitespace syntax, as I feel that Python had success not because of its significant syntax, but in spite of it. But then I don’t really care that much, as long as it’s properly implemented and a standard.

My wish is for the syntax to be clear, with no ambiguity. And preferably with the number of choices limited.

I don’t think we can say that the syntax is unambiguous, and Scala has been sliding more and more towards Perl’s TIMTOWTDI. We aren’t able to write in the Klingon language yet, but we aren’t very far; and it’s not just the new significant whitespace, but also the ambiguity of new keywords; like I’m still struggling to like given and using instead of implicit, and I can’t find a reason to, especially as both exist and usage of given yields surprises, but that’s for another day, another rant :slight_smile:

Either way, I believe that such experimental syntax changes shouldn’t be rushed, and it isn’t too late to retract them completely.

4 Likes