Does Objective-C compile to native code or byte-code?

前端 未结 4 1053
孤独总比滥情好
孤独总比滥情好 2021-02-14 09:58

On OS X, does Objective-C compile to native code or byte-code?

Can Objective-C programs be compiled on Linux?

相关标签:
4条回答
  • 2021-02-14 10:39

    Objective-C is compiled to native code by either GCC or LLVM[*]. You can compile ObjC programs on Linux (the generic GCC will happily support ObjC, though it uses a different runtime library than either of the Apple ones). For a cross-platform API similar to Cocoa (i.e. derived from Cocoa) which will happily work on Linux and let you port some code between OS X and Linux, check out GNUstep: http://www.gnustep.org

    [*]In fact, LLVM internally compiles the Objective-C to an internal bitcode representation, then to code for the target machine, so perhaps the answer is "both"…

    0 讨论(0)
  • 2021-02-14 10:47

    Objective-C is a variant of C. It compiles to native code.

    0 讨论(0)
  • 2021-02-14 10:50

    Yes, Objective-C compiles to machine code.

    Objective-C compilers exist for Linux, but Cocoa is an OS X-only technology. I've heard of an open replacement called GNUstep, but don't know much about it.

    0 讨论(0)
  • 2021-02-14 10:54

    It's native.

    There is GNUstep which an Open Source implementation of the NeXT OpenStep specification written in Objective-C. Their implementation of the Cocoa API is not a direct match so a direct compilation without porting is not possible.

    0 讨论(0)
提交回复
热议问题