What makes code “Swifty”?
swiftbysundell.com
swiftbysundell.com
> So, to make our code more “Swifty” from a performance point of view, sometimes all that we have to do [is literally the same thing we would do in Objective-C]
Is anyone writing consistently good, up-to-date Swift documentation for experienced programmers? Some of the early books haven't been updated since the earliest Swift versions.
SwiftUI is very poorly documented by Apple and much of the third-party SwiftUI docs are for the obsolete WWDC version.
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.
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
http://pointfree.co - high quality content, emphasizing functional programming.
https://oleb.net/blog/ - blog of Ole Begemann, co author of Advanced Swift (good resource itself)
https://appventure.me - Benedikt Terhechte’s topical guides to Swift features
https://andybargh.com/blog/ Andy Bargh’s topical articles
The second example is strange. It's improving the code by making it call the correct method from the standard library rather than the wrong one. I guess that's not bad advice, but I have no idea what it has to do with Swift in particular.
The third one is a missed opportunity. Swift has some unusual ideas around how things should be named (partially inherited from Smalltalk via obj-c, but also partially new), but instead of talking about that it's just generic "give things useful names" advice that has little to do with Swift.
IMO the most important things about Swift code is that it has nice safety features, and it is easy to write clear, self-documenting code.
The initial promise was to have it be comparable to other compiled languages ( java , c++, whatever), but i've yet to find a real benchmark.
Or rather, the ones i've seen made it look more on the range of interpreted/dynamic languages ( ruby / python or node), at least for server side projects. Which came as a surprise to me.
Has any real work been work on that issue somewhere ?
Also, it's a benchmark which needs special hardware to be run, so it's not easy to try to reproduce or improve on this result.
Secondly, with exception of Java, the remaining ones on that benchmark support value types and native heap allocations.
Also I would love to see an implementation of the swift benchmark which doesn't lean on reference types, which is not idiomatic swift and is likely the reason the ARC penalty is so high here.