Professional Web Applications Themes

Carbon and Cocoa -- I don't have a grip on the diffs - Mac Networking

I remember from ancient times that there were three rings ... No, wait. There were three somethings that would run under OS X. Carbon and cocoa were supposed to be the better of the three, with one of them being the one that binds them all or something. Anyway, what's the diff between carbon and cocoa, and since one is preferred, why? -- Philip Stripling | email to the replyto address is presumed Legal Assistance on the Web | spam and read later. email to philip http://www.PhilipStripling.com/ | my domain is read daily....

  1. #1

    Default Carbon and Cocoa -- I don't have a grip on the diffs

    I remember from ancient times that there were three rings ... No,
    wait. There were three somethings that would run under OS X. Carbon and
    cocoa were supposed to be the better of the three, with one of them being
    the one that binds them all or something.

    Anyway, what's the diff between carbon and cocoa, and since one is
    preferred, why?
    --
    Philip Stripling | email to the replyto address is presumed
    Legal Assistance on the Web | spam and read later. email to philip
    http://www.PhilipStripling.com/ | my domain is read daily.
    Phil Guest

  2. #2

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    In article <tdl.com>,
    Phil Stripling <zzn.com> wrote:
     

    Carbon is a compatibility layer -- applications that use this API will
    run under both OS 9 and also natively under OS X (i.e. they don't have
    to be run under the Classic emulator). But this means that they can't
    make use of features that only exist in OS X.

    Cocoa is OS X's full-featured API. If you're OK with requiring OS X as
    a minimum for your application, you should use this.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  3. #3

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    Barry Margolin wrote:
     

    This is not true. Most APIs are available in both Carbon and Cocoa, and
    if an API isn't available under one it is easy enough to switch
    contexts. Some APIs are available only under Carbon.
     

    Unless you want to work with other platforms or have existing C++ code,
    in which case you're probably better off with Carbon.

    Neither is inherently better than the other, except that Cocoa
    applications get some things for free. Like services -- AppleSpell.
    Carbon applications can have these, too, but it's a lot more work.

    --
    "Any sufficiently advanced stupidity is indistinguishable from malice."
    Steven Guest

  4. #4

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    In article <tdl.com>, Phil Stripling
    <zzn.com> wrote:
     

    The differences are solely the realm of developers. They should make
    no difference (or not much) to the end-user, who should be more
    interested in the feature set of the software than how it was built.

    Cocoa is an OS X programming API, usable only through Objective-C
    written in Apple's development tools (XCode, Project Builder). It is
    inherited from the NeXT OS, which is the basis for OS X. It's pretty
    cool, but it sure makes supporting your app on both OS X and Windows,
    or even OS X and OS 9, rather difficult. You'd have to have a
    different code base. That means most Cocoa apps are not likely to ever
    see the outside of OS X.

    Carbon exists mainly because there had to be some way to easily port
    old apps to OS X. It will always exist, most likely, because things
    like Photoshop will likely *never* be rewritten from the ground up just
    so they can say they're written in Cocoa. A Carbon app can run
    natively on OS X or on OS 9 with CarbonLib present, making it possible
    to distribute one app for both 9 and X. Some people claim that Carbon
    is less capable, but the truth is that there are things Carbon can do
    that Cocoa can't (or can't easily), and things Cocoa can do that Carbon
    can't (or can't easily).

    As far as "since one is preferred"... well, both have strengths and
    weaknesses. I wouldn't say one is definitely preferred over the other
    in a general sense. Developers use the one that suits their purposes
    best.

    --
    -Thomas

    <http://www.bitjuggler.com/>
    Thomas Guest

  5. #5

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    Steven Fisher <net> wrote:
     
    >
    > This is not true. Most APIs are available in both Carbon and Cocoa, and
    > if an API isn't available under one it is easy enough to switch
    > contexts. Some APIs are available only under Carbon.

    >
    > Unless you want to work with other platforms or have existing C++ code,
    > in which case you're probably better off with Carbon.
    >
    > Neither is inherently better than the other, except that Cocoa
    > applications get some things for free. Like services -- AppleSpell.
    > Carbon applications can have these, too, but it's a lot more work.[/ref]

    All of that is right (you correctly corrected the previous poster):
    neither is better or preferred, and neither inherently has more power or
    access to anything than the other. Indeed, they can be mixed in the same
    app; Cocoa apps often make Carbon calls, and Carbon apps often include
    one or two Cocoa windows.

    But you have not really explained to the OP what the difference is. The
    difference is that Carbon is just a set of toolbox calls, the same as
    Mac programming has always been, whereas Cocoa is an application
    framework. In Cocoa you (the programmer) "draw" your interface, and you
    can have a working application without writing a single line of code.
    The nice thing is that this application framework is present on every OS
    X machine, so Cocoa apps can be quite small in and of themselves. m.


    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  6. #6

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    In article <ash.giganews.com>,
    Barry Margolin <mit.edu> wrote:
     

    Incorrect.

    R.
    --
    Rich Siegel <net>
    Bare Bones Software, Inc. <http://www.barebones.com/>

    Someday I'll look back on all this and laugh... until they sedate me.
    Rich Guest

  7. #7

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    On Wed, 25 Feb 2004 8:52:34 -0500, Thomas Reed wrote
    (in message <250220040852342418%spam.me>):
     
    >
    > The differences are solely the realm of developers. They should make
    > no difference (or not much) to the end-user, who should be more
    > interested in the feature set of the software than how it was built.
    >
    > Cocoa is an OS X programming API, usable only through Objective-C
    > written in Apple's development tools (XCode, Project Builder). It is
    > inherited from the NeXT OS, which is the basis for OS X. It's pretty
    > cool, but it sure makes supporting your app on both OS X and Windows,
    > or even OS X and OS 9, rather difficult. You'd have to have a
    > different code base. That means most Cocoa apps are not likely to ever
    > see the outside of OS X.
    >
    > Carbon exists mainly because there had to be some way to easily port
    > old apps to OS X. It will always exist, most likely, because things
    > like Photoshop will likely *never* be rewritten from the ground up just
    > so they can say they're written in Cocoa. A Carbon app can run
    > natively on OS X or on OS 9 with CarbonLib present, making it possible
    > to distribute one app for both 9 and X.[/ref]

    Not quite correct. A _properly written_ Carbon app can run natively in OS X
    or OS 9. MS Office X, for example, was written using Carbon. It cannot run in
    OS 9. IIRC this is also true for Quirk 6.
     

    Quite correct.
     



    --
    We are Microsoft of Borg. You will be assimilated. Stability is irrelevant.
    Where _you_ want to go to today is irrelevant. We will add your currency to
    our own. Bend over right now. Resistance is futile.

    Charles Guest

  8. #8

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    In article <newsguy.com>, Charles
    Dyer <com> wrote:
     

    not quite correct either.

    carbon apps can be compiled to either mach-o or cfm binaries. if its
    mach-o, it *cannot* run on os9 since os9 knows not of mach-o. however,
    if its cfm, it can run in either if there aren't any osx specific
    carbon calls and if the developer chooses to support 9.
    nospam Guest

  9. #9

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    matt neuburg wrote:
     

    That's a good short answer, but with all of the cross-calling it's maybe
    a bit over-simplified.

    You know, OP actually asked very good question. Apple has made it very
    difficult to draw the line.

    Maybe the best thing to do is go to the source:
    http://developer.apple.com/cocoa/
    http://developer.apple.com/carbon/

    And, having read that, I can summarize them much faster:
    Cocoa: System provides an object-oriented API. Use for Objective C
    applications. As you noted, a lot of the handling of the interface is
    built into the objects.
    Carbon: System provides a procedural API. Use for anything.

    Of course, even though Carbon is procedural, the user can put a OO
    framework on top of it...

    --
    "Any sufficiently advanced stupidity is indistinguishable from malice."
    Steven Guest

  10. #10

    Default Re: Carbon and Cocoa -- I don't have a grip on the diffs

    nospam wrote:
     
    >
    >
    > not quite correct either.
    >
    > carbon apps can be compiled to either mach-o or cfm binaries. if its
    > mach-o, it *cannot* run on os9 since os9 knows not of mach-o. however,
    > if its cfm, it can run in either if there aren't any osx specific
    > carbon calls and if the developer chooses to support 9.[/ref]

    I think the issue is "properly written." Better to say that an
    application intended to do so can run natively under Mac OS X or Mac OS
    9. One of the restrictions on such an application is that it be cfm.

    That doesn't make CFM superior. Mach-O is apparently faster now (at
    last!) than CFM. It's all a matter of priorities and balance.

    --
    "Any sufficiently advanced stupidity is indistinguishable from malice."
    Steven Guest

Similar Threads

  1. Replies: 19
    Last Post: December 3rd, 10:32 AM
  2. Cocoa in Carbon - weird behaviour
    By Eric VERGNAUD in forum Mac Programming
    Replies: 0
    Last Post: October 1st, 12:22 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139