News for hackers. Stuff that matters.
Re:What’s New in Swift 5.2 by sramsay on Thursday February 06, 2020 @01:41PM (#22258859)
> They add way too much surface area to the language by allowing too many ways to do a given thing.

Not relevant to most situations, but I'll just add that this also makes it extremely difficult to teach a language.

I have taught Ruby -- a language with quite a sweet tooth -- for almost twenty years, and I feel like it gets worse and worse every year. Students run off to look at example code online (as they should), but discover that I have been teaching them what seems to them like a different language.

It really leaves me with no choice but to spend a lot of time in lectures saying, "You can do it this way . . . or this way . . . or this way . . . and by the way, these are all semantically equivalent."

Re:What’s New in Swift 5.2 by favorited on Thursday February 06, 2020 @02:02PM (#22259104)
The concept of progressive disclosure means that you shouldn't teach this kind of stuff to beginners. Stuff like callAsFunction, dynamic member lookup, etc. are for people who are writing DSLs, providing rich libraries, etc.
Re:What’s New in Swift 5.2 by zionic on Thursday February 06, 2020 @02:12PM (#22259226)
Progressive disclosure does absolutely nothing for your students looking up example code only to be greeted by alien syntax that does the same thing.

Pretend you know nothing about a language, why would you assume .map { $0.thing } and .map(\.thing) are even remotely similar?

Re:What’s New in Swift 5.2 by Razengan on Thursday February 06, 2020 @03:57PM (#22260206)
You would look it up, as you would for anything else you see for the first time.
Re:What’s New in Swift 5.2 by keenmaster on Thursday February 06, 2020 @05:49PM (#22261296)
I wonder if there's a coding interface for beginners that works as follows:

The beginner types a declaration of "I want to _____" and the interface uses ML to auto-suggest code. The auto-suggest would be context-sensitive and fit in with previously written code. Auto-correct would work similarly. If the declaration isn't specific enough, then the auto-suggest tool would ask a series of questions that illustrate the different choices a programmer can make in achieving their goal. Finally, the tool would output code that reflects the beginner's choices.

This would increase the speed of the think-do feedback loop. Beginners would be able to jump into coding with very minimal education and "make" the application they want straight away. Of course, it would usually behoove them to eventually read some programming books and take classes, but this tool would pique their interest. The power of the auto-complete would scale back as the beginner progresses unless they get stuck. Maybe this would only work on a finite set of projects that the ML was trained on, which is fine because you can just give a lot of projects to choose from. That is until the ML becomes more powerful and generalizable.

Re:What’s New in Swift 5.2 by hndc on Thursday February 06, 2020 @06:15PM (#22261485)
Among the drawbacks of excessive syntactic sugar is that it is often difficult or impossible to look up
Re:What’s New in Swift 5.2 by Razengan on Monday February 10, 2020 @04:22AM (#22287579)
Do you have examples of that?
Re:What’s New in Swift 5.2 by zionic on Thursday February 06, 2020 @02:05PM (#22259149)
Syntax duplication has a huge cognitive overhead.
Re:What’s New in Swift 5.2 by pkolaczk on Thursday February 06, 2020 @10:53PM (#22263088)
Scala knows something about this and made a 180-degrees turn recently.

Swift is a lot like Scala. Swift creators, please not repeat Scala's mistakes.

Re:What’s New in Swift 5.2 by cmollis on Friday February 07, 2020 @06:59AM (#22265168)
I use Scala everyday (in spark) and generally prefer it over java but I agree that the surface area is too large. This is really evident when you start to import someone else’s libraries. The breadth of the language affords many different paths for the library writer depending On how much of a language sniper they are.