News for hackers. Stuff that matters.
Re:What makes code “Swifty”? by saagarjha on Sunday February 23, 2020 @04:11PM (#22399551)
> Most of this applies to Objective-C.

Objective-C’s type system is much poorer than Swift’s, and it lacks a number of expressive operations. The “before” examples are generally how a lot of people would actually write code in Objective-C.

Re:What makes code “Swifty”? by refulgentis on Sunday February 23, 2020 @05:30PM (#22400007)
Which ones?

I wrote ObjC for 7 years, Swift for 3. I only looked at the first two examples, they both were generic programming advice, nothing to do with the language

Re:What makes code “Swifty”? by saagarjha on Sunday February 23, 2020 @05:39PM (#22400047)
The first three. Objective-C doesn't have enums with associated values and it's common to store things in heterogeneous collections or stringly-keyed collections. Creating protocols for generic constraints is also rare–informal protocols (respondsToSelector, anyone?) are instead quite prevalent. And Objective-C's "collection" APIs are much less powerful than Swift's: I might use a regex replacement instead of four calls to replacingOccurrences(of:with:), but it's the same principle.