Hacker News new | ask | show | jobs
by smtddr 4024 days ago
You have to understand though, Swift is like a really nice wrapper around Objective-C. Imagine adding try/catch to C programming language? I know python & java and all of today's relevant high-level languages have it since forever, but implementing that in something that wasn't designed for it from the start is a big task. I'm by no stretch of the imagination an Apple fanatic but as a person who is about to send out their first mobile app, which happens to be for iOS, I acknowledge the difficulty of adding try/catch to Swift... and by extension any Obj-C or plain C used in that same XCode project.
2 comments

While Swift was designed to interface well with Objective-C and runs on the Objective-C runtime, it is not a wrapper around Objective-C. It was written from the ground up, started by Chris Lattner at Apple.
Obj-C already had try / catch, it just wasn't considered idiomatic to the platform. Amazon caught a bunch of flak when they wrote an Obj-C interface to AWS and all of the error handling was try/catch instead of NSError (probably, they just line-for-line transliterated their Java interface).
"The standard Cocoa convention is that exceptions signal programmer error and are not intended to be recovered from. Making code exceptions-safe by default would impose severe runtime and code size penalties on code that typically does not actually care about exceptions safety. Therefore, ARC-generated code leaks by default on exceptions, which is just fine if the process is going to be immediately terminated anyway. Programs which do care about recovering from exceptions should enable the option."

http://clang.llvm.org/docs/AutomaticReferenceCounting.html#e...

ARC was short lived and is deprecated.
Am I missing something? ARC is the default when you start any ObjC-based Xcode project. It's not deprecated.