3 ms·
Hi HN—author of the post here! Feel free to check out the source to our Swift example on Github and explore the iOS SDK. Happy to answer questions - https://git
by bengotow 12y ago
Hi HN—author of the post here! Feel free to check out the source to our Swift example on Github and explore the iOS SDK. Happy to answer questions - https://github.com/inboxapp/inbox-ios/tree/master/InboxExamples/SwiftEightBall https://github.com/inboxapp/inbox-ios/tree/master/InboxExamp...
- greggman 12y agoCan you explain the appeal of Swift? Geninuely curious
- augbot 12y agoIt's fun compared to Obj-C
- niuzeta 12y ago/thread
- bengotow 12y agoI'm a huge fan of Objective-C - it's been around for ages (it actually predates Java) and it's design makes it enormously flexible. That said, it has it's problems: many people dislike the "brackets everywhere" syntax and it's compatibility with C constrains the compiler (you can actually write C in the middle of your Objective-C, move pointers around, etc.) In Objective-C, you can write code that looks fine at compile-time but still crashes the app, which is bad for us developers and bad for iOS as a platform. Swift can be used to write first-class, native apps just like Objective-C and even used alongside Objective-C in the same project. It includes features borrowed from other modern languages (Rust, Go etc.), like generics, tuples and explicit optionals. Many of the features of Swift are designed to ensure that the compiler can catch issues at compile-time. It's much more difficult to write code that will crash a Swift app. As a seasoned Objective-C developer I'll probably reminisce about the good old days when I swizzled methods and did all sorts of bad things, but it's a good move for the platform :-)
- tel 12y agoIn my own experiments Swift is a fairly "modern" statically typed, functional language with enough ObjC bolted on and mixed in to serve as a suitable replacement for ObjC. You can do fairly ridiculous things in the functional fragment of Swift [0][1] which match the expressive power of languages like Haskell/ML/Scala. You also gain the standard complement of * Immutability all over * Actually decent type inference * Optional types * Anonymous functions all over * Pattern matching * Real tuples * Real sum types On the OO side you've got powerful generics, classes open to explicit extensions, and protocols (traits, typeclasses, etc) along with a pretty firm commitment to ARC. From my understanding of ObjC there's not a whole lot gained in the OO side of Swift. * Clear reference/value differences * No pointers * No NULL [0] http://tel.github.io/2014/07/27/calkin-wilf-in-swift/ http://tel.github.io/2014/07/27/calkin-wilf-in-swift/ [1] http://tel.github.io/2014/07/30/immutable_enumeration_in_swift/ http://tel.github.io/2014/07/30/immutable_enumeration_in_swi...