|
|
|
|
|
by pcr910303
2074 days ago
|
|
> It unwisely rejected the parsimonious case and chose tremendous complexity. Swift's keyword syntax isn't complex at all. > Keywords? Or parens? Both! I know you like Smalltalk, but keywords and parens are used together in a lot of languages (e.g. Python) so it's a tested idea. > And the weird case of having two keywords, one with a colon and one without, because we decided to make the keywords the names of the parameters. Sometimes. You don't have two keywords, you have an optional variable name. It's intuitive at the first time you see it - you're phrasing makes it seem much more complex than it really is. I think you're trying to imply that Swift isn't an elegant language with it's syntax fitting in a postcard, but that doesn't mean it's 'tremendous complexity'. This whole comment is a bit too harsh to Swift, calling the legitimate differences between Swift and Smalltalk as 'complexity'. |
|
> Swift's keyword syntax isn't complex at all.
Yes it is, particularly compared to the parsimonious options. Either parens or Smalltalk-style keywords can do the job, so you absolutely, positively do not need both.
Particularly, if you are going to have keywords, you just don't need parens. So it's already more complex than it needs to be (not parsimonious). Just explaining the various omitted or extra keywords takes 4 pages in the Swift book, the entire Smalltalk syntax fits on a Postcard.
What is complex or not obviously depends on what your baseline is. If it's C++, Swift might seem simple (though many disagree).
> (e.g. Python) so it's a tested idea.
The question was not whether it was tested, but whether it was a parsimonious design, which it is not. It was also not a good design, because it led to a number of follow-on problems that they had to incrementally fix while adding even more complexity.
Python is not a good comparison because they didn't really have a choice: they already had the paren syntax, which they could hardly deprecate.
However, choosing that design without a backwards compatibility restriction is unconscionable, IMHO, particularly if you already have a different keyword design all over your code-base. That's cutting off your nose to spite your face.
Anyway, even the baseline keywords-in-parens is complex and more complex than it needs to be (because it isn't parsimonious), but then you get follow-on problems: blocks inside parens are really ugly, so you add trailing closure syntax. Yet another special case, which is very different from arguments inside the parens. But then you discover that sometimes you need more than one trailing closure, and then you need yet another special case, the open-keyword-trailing-block syntax, which is different yet again.
Of course, instead of having 3-4 different syntactic mechanisms, you could have chosen just the one and not needed any of the others.
> You don't have two keywords, you have an optional variable name. It's intuitive at the first time you see it
No, it's absolutely positively not the least bit intuitive. And it makes no sense, because internal variable names have no business leaking to the interface. If you want to rename the names of your variables inside your method, it changes the signature! Not even C does this.
> that doesn't mean it's 'tremendous complexity'
Although the argument could be made, I wouldn't, not by itself, no. However, this is just one example of countless others, see for example Rob Rix, whom I quoted before:
Swift is a crescendo of special cases stopping just short of the general; the result is complexity in the semantics, complexity in the behaviour (i.e. bugs), and complexity in use (i.e. workarounds).
I also talk more about it here:
https://blog.metaobject.com/2015/05/i-am-jealous-of-swift.ht...
> is a bit too harsh to Swift,
Nope. The comment I replied to made the indefensible claim that Swift was parsimonious. Which it's not. Not even close.