3 ms·
It seems to me that their threshold for introducing new language features is extremely low. If something cannot be made to look flawlessly pretty using existing
by fauigerzigerk 3y ago
It seems to me that their threshold for introducing new language features is extremely low. If something cannot be made to look flawlessly pretty using existing syntax they will go to any length to fix it, regardless of how much extra complexity they have to introduce.
Result builders are a case in point. Essentially, they didn't like the bracket and the comma between array items in the special case where a function returns only a single array.
// So rather than this
let items = makeUgly {
[
Item("One"),
Item("Two"),
Item("Three")
]
}
// It had to look like this
let items = makePretty {
Item("One")
Item("Two")
Item("Three")
}
Yes, it's prettier. There's a bit less clutter. But there's a cost too. makePretty uses entirely different language semantics without any syntactical clue at the call site.
So now there are essentially two separate syntax modes in Swift, and every time you look at some code you have to make up your mind on whether to read it in normal mode or in result builder mode. Sometimes that's easy to know in context. But it's another thing you have to pay attention to at all times.
- bsaul 3y agoI feel swift really makes it impossible to learn as a language. The number of idioms has grown exponentially at the detriment of orthogonality. I think the red line was crossed with result builders indeed. Looks like a manager once said "we've got to look like jsx/html, now !" and the poor devs had to obey. It makes absolutely no sense from a language design POV.