2016-09-07 21:11:23 UTC
All of it can. Objective-C is just C with some syntactic sugar on top.There’s a large amount of semantic sugar too, i.e. the runtime libraries. (If you think the runtime part must be trivial, go read some of Mike Ash’s posts about the implementation of objc_msgsend. That’s some of the most insanely optimized code I’ve ever seen.)
Really. There’s nothing magic going on. (In fact, the original compilers were really just preprocessors that churned out C code.)You can say this about nearly any compiler, though. Bjarne's original C++ compiler output C code too. The first-generation Go compiler output C code, but Go is absolutely not like sugary C. Most compilers used to output assembly code (nowadays Clang outputs LLVM bitcode), but it seems meaningless to say that those languages are “assembly with some syntactic sugar.”
But yes, you can use the Obj-C runtime API from C to do pretty much anything you can do in Obj-C, like calling methods and implementing classes. It’s just much, much messier, error-prone, and difficult to read compared to writing the damn code in Obj-C.
There’s no pride in refusing to switch languages. I abjured C++ a long time ago, but guess what, my current project is 99% C++ because that language best meets the performance and portability requirements. Next time maybe I’ll be using Swift, or Rust, or Pony. C is an ancient, primitive language and it’s not a good career move to refuse to move past it :)
Cocoa-dev mailing list (Cocoafirstname.lastname@example.org)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription: