Just wanted to add my voice to the list of opinions about the Pre-SIP:
I like the initial proposal with rewrites to apply
, and not only collection literals. In fact, Iâve already written code similar to it:
perlinNoise(
seed = 0,
sideLength = 512,
layers =
(frequency = 2 , persistence = 0.5 ),
(frequency = 10, persistence = 0.25 ),
(frequency = 20, persistence = 0.125),
(frequency = 40, persistence = 0.125)
)
This is from some recent code that uses named tuples and I find it very readable. In my opinion, the missing âconstructorâ that would be there if it used a case class for a perlin noise layer would not add to legibility. In fact, I find both the naive case class approach, i.e.
perlinNoise(
seed = 0,
sideLength = 512,
layers =
PerlinLayerConfig(2, 0.5),
PerlinLayerConfig(10, 0.25),
PerlinLayerConfig(20, 0.125),
PerlinLayerConfig(40, 0.125)
)
as well as a âcompleteâ approach, i.e.
perlinNoise(
seed = 0,
sideLength = 512,
layers =
PerlinLayerConfig(frequency = 2, persistence = 0.5),
PerlinLayerConfig(frequency = 10, persistence = 0.25),
PerlinLayerConfig(frequency = 20, persistence = 0.125),
PerlinLayerConfig(frequency = 40, persistence = 0.125)
)
less readable. I think with the initial proposal, []
as syntax and no varargs it would be written as
perlinNoise(
seed = 0,
sideLength = 512,
layers = [
[frequency = 2 , persistence = 0.5 ],
[frequency = 10, persistence = 0.25 ],
[frequency = 20, persistence = 0.125],
[frequency = 40, persistence = 0.125]
]
)
which is very close to my initial code and I find it still very readable.
With that out of the way, a couple of points. I like the initial proposal, because:
- It is close to code Iâve already written
- Even though it can be misused, like any feature, I donât think it lends itself overly easy to being misused, even though it can be used in a wide range of circumstances.
- I too find it uses existing Scala infrastructure pretty well and is easy to understand as soon as you understand
.apply
, which is a must for Scala developers anyways.
- I seem to find visual noise much more detrimental than most of you, I think, and I find
[]
to be less visual noise than named constructors, âŚ
- Scala is my language of choice, but I find other languages (like Typescript) more lightweight. I think this would help narrowing the gap.
Iâm aware that the points I made above are largely subjective. Just wanted to add my opinion into the mix.