Here comes my personal views of optional braces from a university teacher’s perspective (apologies for long post, and I might now be spoiling my poll as I give the teacher’s preferences that might bias late answering students if they happen to read this):
I think optional braces will be a great improvement, as lagom (meaning well-balanced) conciseness can make code much easier to read for beginners.
I also think surface syntax is important in the sense that, ideally, optional braces should be exactly just that: namely optional; and thereby, in its literal meaning, be removable or addable without further change (or if that turns out to be “impossible”, with as few changes as possible).
When with
was available as indentation token in older dotty versions, I gave it a serious try by porting significant amount of code and also write a good deal of new code from scratch, but I could never get used to with
instead of braces. It looks bloated, feels non-intuitive, and I often forget to write it even after a great deal of practice.
Colon is much easier for me to adapt to and I don’t find it disturbing or bloated. I sometimes forget to write colon, and sometimes I even have written =
after class and object instead of :
when I get carried away in a coding flow, but that happens less and less often as I practice more.
I am strongly opposed to the with
keyword after classes and objects; I can appreciate that, from intellectual argumentation on e.g. consistency, there may be advantages, but with
just don’t fly for me, after writing a whole bunch of lines with it. So I really really hope, and keep my fingers crossed, that it does not re-appear as the final choice.
I have during the fall tried to follow the development of Scala 3 by trying out the new and changed stuff in my own code with focus on the stuff that will impact my students in introductory programming and my teaching material. Optional braces will impact almost all of my code, but I deliberately intend to blend styles in our course material, to make students comfortable with reading and writing both styles. I think as a community we must be prepared for and open to a “blended” style wrt braces, in mixed code bases, Q&A-sites, blog posts etc.
I understand and agree with the arguments put forward by Martin, not to restrict optional braces behind a compiler flag and to include this change in 3.0.0 and not later. But the implication of that is, IMHO, that the release of 3.0.0 should be delayed until this is settled on the best possible solution. And with
is just not the best possible solution, IMHO.
There will be many fantastic new things in Scala 3 that will help beginner learners (including enum, top level defs, main-functions etc.). So let’s make optional braces intuitive, beautiful and concise.
POLL UPPDATE: after 5 hours since the poll was posted (sent to 134 students and 17 teaching assistant via Discord) there are now 41 responses:
93% want colon or nothing while only 7% (3 persons) want with
(The 93% is summed up by 51% nothing and 42% colon, but if nothing is not available, I believe the nothing voters would all go with concise colon rather than the longer with.)