I wonder if people dislike "syntactic sugar" partially because the name contains an implied presupposition that it's bad to use
personally I love it, but that's just from my limited C# perspective so idk
personally I love it, but that's just from my limited C# perspective so idk
Comments
With Scala, on the other hand, everything is so heavily sugared I became diabetic IRL.
Records, Pattern Matching, Properties, Elvis Operator, Collection Expressions, Extension Methods, Collection Initializers, Indices and Ranges, String interpolation, a lot more.
That's why they can innovate in a rapid pace. No Runtime changes.
And ofc, you can go overboard and end up with whatever Haskell nerds seem to do
It’s not a bad thing per-se but it can create extra friction when using a language
Personally - if it fits into the language, doesn't introduce too many footguns and makes sense - it's fine.
Go for example, does not have ?: ternary syntax, even tho it improves a lot of code.
I see a similar problem with C++'s Operator overloading. Because of operator overloading, EVERYTHING is done via operators. (why does PRINT require << etc.?)
It's just a marketing gimmick, call it for what it bloody well is - language specific syntax.
Like yeah, you could have a + b mean the same in an overwhelming majority of languages, but also there are languages that might use postfix notation and they write the same thing as a b +.
Like a for loop is just syntactic sugar for a loop around an iterator
Like all abstraction, it is only as good or bad as it is useful for your particular purpose.
There’s also a huge cultural/historical aspect to it, and that’s more where the debate tends to happen.
myTransform.position.y = 5;
Here position is a struct property and y is a variable of that struct. Have to do this, which is infuriating to me:
var pos = myTransform.position;
pos.y = 5;
myTransform.position = pos;
Also the new switch expressions are just gorgeous.
I dislike - what I call - "attribute programming;" when a bunch of functionality is added from a [...] on a property or method.
But my personal code...
Sugar is just one more layer of abstraction, on what the lang already abstracted.
Abstraction is always complicated sugar or not. And all of programming is abstraction
syntactic fat
syntactic acid
syntactic heat
The importance of unwanted side-effects depends on the use case.