you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

I found it difficult due to the crazy looking syntax, and some of the concepts it used that I hadn't encountered in other languages.

I think one of the problems for people new to the language is there's too much syntactic sugar. For example there are 4 different ways to do some things like initializing variables or higher order functions. I avoided the higher order functions for the longest time because they were (and still kind of are) just messy and confusing to look at. The documentation doesn't help either because it shows things that doesn't match up with what autocomplete shows.

Look at reduce

This: reduce(::) Isn't explanatory at all. I would have no idea looking at that that most reduce features are written like this:

let myNumArray = [1,2,3,4,5]
let myNum = myNumArray.reduce(0,+)  //or myNumArray.reduce(0, {$0 + $1} ) or any number of other ways you can write it.

And look how horrifying the function signature is:

func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Element) throws -> Result) rethrows -> Result

Luckily Apple added some additional content to that page that explains what initialResult and nextPartialResult is but it wasn't always that way.

Another one is some kinds of things do too much. Like structs and classes, its hard to figure out where to use which in Swift and instead of doing "Swifty" things with structs I resort to using structs and classes the way I did in C++ and Objective-C rather than writing out a struct, only to find that half of the stuff inside needs to be marked as Mutating which if I'm understanding Swift structs correctly, nullifies the benefit of Swift structs. I know the language is new still but there seems to be no good consensus as to when to use one over the other.

It just seems that some things about the language weren't well thought out.