The state of then

It’s tempting to see Scala 3 as the possibility to introduce breaking changes. But every breaking change adds to the upgrade cost (*), which we should try hard to minimize. IMO the benefit/cost ratio is low here, we should spend the available budget on important issues.

(*) The cost of implementing the change and the rewrite tool rule are small. Asking everyone to do the change in their code is already more costly. And then we cannot run a rewrite tool across old documentation, unmaintained example code, StackOverflow, books.

6 Likes

Dotty seems to allow both Java/C parenthesis style and if-then style.
If it promised that current style will not be deprecated for another decade, would that make it a softer landing?

It does increase the surface area of the language, but compared to recent SIPs that are being considered/added, having if sugar has almost no worries about actually breaking the semantics of the existing code.

3 Likes

I keep my opinion here: it causes work (even if spread out over 10 years) and confusion (newcomers) for very little (for me personally: no) benefit. The best restaurants have a small menu; I would not add more of “multiple ways to do one thing”.

2 Likes

Just to concurre: having multiple ways to do the same thing with ONLY syntaxt variations (ie not semantic change whatsoever) is a BAD part of Scala, not a good one.
I don’t talk about Python or some other language with extremelly high, imposed regularity, but all other things being equal, I would much prefer to reduce the number of syntaxic variation in Scala that to increase it.

6 Likes

Fully agreed with Lukas and François: there is a massive wake of papercuts following a syntax change. To me, it’s just not worth it tweaking small things. (And I have been in bitter disagreement with Martin on the spacing around the parens of if's condition for a decade now :grin: .)

tl;dr:

  • removing deprecated stuff / redundancy / sharp edges / confusion: :white_check_mark:
  • new features: :rocket:
  • syntax tweaks: :face_with_head_bandage:
10 Likes

https://docs.scala-lang.org/style/control-structures.html

control structures should be written with a space following the defining keyword

if (foo) bar else baz // right!
if(foo) bar else baz // wrong!

Some people prefer even

if ( foo ) bar else baz

especially when foo is more or less complex. This generally does not contradict with the main style guide (however, this is arguable).

This all is about what people like to see and how do they feel about syntax. And this is not a field of constructive discussion because some people like one way, some like another and some people do not like several variants for one thing, however other people do not mind. Someone must voluntary set the rules because such discussion cannot end in the community and whatever solution will leave a lot of disagreed.

2 Likes

Thank you both for weighing in on this. I mostly wanted clarification around the situation, so I am happy to see various perspectives laid out.

1 Like

Why introduce syntax that’ll change nothing?
many people are already lost with scala syntax. I’m also sometimes confused whether use curly brackets or not. More freedom in such trivial case is a bad idea, things should be as straightforward as possible.

All changes’ll stay with Us for very long time (hopefully). Each of them blocks future changes in some way. There is so many great ideas we can change in language but having 2 almost identical syntaxes probably won’t help anyone.

3 Likes

Thank you for taking the time to say this. I completely agree. I feel this way for multiple reasons, but one of them is as someone who teaches Scala to students. More syntax damages the language and, IMO, gives ammunition to those who complain that Scala is hard/complex.

‘Allow significant indentation syntax’ - https://github.com/lampepfl/dotty/pull/7083

3 Likes

Can we have then even without the indentation-based syntax? :pleading_face:

2 Likes

Yes

2 Likes

To clarify the OP, Scala 2.13 REPL still warns:

$ scala
Welcome to Scala 2.13.0 (OpenJDK 64-Bit Server VM, Java 11.0.3).
Type in expressions for evaluation. Or try :help.

scala> val then = 1
           ^
       warning: then is a reserved word (since 2.10.0); usage as an identifier is deprecated
then: Int = 1

(There was an interregnum where usurping syntax was ignored.)