News for hackers. Stuff that matters.
Re:What's Going Down at the Tiobe Index? Swift, Surprisingly by epynonymous on Saturday April 27, 2019 @10:16PM (#19768872)
have used swift since version 2.x to create several mobile apps so i consider myself proficient, for the record, i have also used php, nodejs, c/c++, java, ruby, python, and golang quite extensively. i consider myself a full stack developer.

regarding swift, i am not a fan of the language at all, i use it more out of necessity, when i started to write ios apps, swift was available and i had already gotten used to not having to deal with memory management and such so chose the language, i also thought objc as a language for ios apps was a bit too verbose after looking at some tutorials, i had been used to using interpreted languages and syntactically concise languages like golang so thought i'd give swift a try.

somehow, over the years, i've managed to write a few apps with swift, so it does the job, the 2 things i dislike the most is the "as/as?/as!" statement, e.g. when i have a dictionary like object [String: Any] and having to "as" that is annoying to me, and you can't cast which to me is more direct, you have to first "as? Int" and then de-convert the optional with an !

The second thing i really hate about the syntax is the whole thing with "let" constants, i'm fine having to check for NULL first, but to do if let apples = fruits["apples"] as? String {...}, i guess this is kind of related to the first issue.

my swift code is such a spaghetti mess of these statements, i imagine a lot of it has to do with me, but this doesn't seem to be a problem with other languages. it could also be that i'm just trying to plow through the code so that i can get functionality working asap.

Re:What's Going Down at the Tiobe Index? Swift, Surprisingly by infinisil on Saturday April 27, 2019 @10:41PM (#19768964)
If you're doing so much casting you're doing something wrong. Swift's power comes from the type system, which alleviates the need for all casting in general. Instead of using a [String: Any] dictionary which bears no meaning at all, consider converting it to a struct with accessors of the right types. If you work with the type system, Swift will be a joy to use, because that's where it shines.
Re:What's Going Down at the Tiobe Index? Swift, Surprisingly by pixelrevision on Sunday April 28, 2019 @02:08AM (#19769629)
I’d agree with this completely. A lot of the people I see having issues with it are trying to write it like python or something. For this style of coding objective-c is a much better choice.
Re:What's Going Down at the Tiobe Index? Swift, Surprisingly by epynonymous on Sunday April 28, 2019 @08:24AM (#19770756)
also not sure why you were downvoted, i voted you back up.
Re:What's Going Down at the Tiobe Index? Swift, Surprisingly by epynonymous on Sunday April 28, 2019 @08:23AM (#19770753)
not sure why you were downvoted, i voted for your comment, makes perfect sense. i was using a generic [String: Any?] to hold a mix of variables, you are absolutely correct, should use a struct or maybe even a class.