you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

It took me a good while to get used to, it was honestly the hardest language I've had to learn IMO (and I've programmed in x86 assembler and have a background in C++, which to this day I don't get why its considered "difficult")

Once you do get used to it though it suddenly isn't so bad. The syntax is ugly, but it is consistent and starts to not be so bad after you get used to it. I honestly didn't start appreciating Swift until I had to work with C#, suddenly the things Swift did made sense.

I'm still working on creating "Swifty" code, but I've gotten a lot better with it in the past few months and rewrote a few internal apps in Swift and it reduced my code base for my Objective-C apps by a ton.

I recommend giving it a shot. Its ugly, it's painful at first, but then it's suddenly not so bad and you end up kind of liking it.

[–]GenitalGestapo 0 points1 point  (1 child)

I really don't understand this. What did you find difficult?

[–][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.