Carbon easier to learn than Cocoa?

Posted:
in macOS edited January 2014
After being forced to learn C++ in a DOS environment and briefly attempting to learn Visual C++ (What a piece of crap!), I really want to learn how to write Mac programs. I know Cocoa is recommended for writing new applications in OS X, but since I'm not familiar with Smalltalk and already know a good deal of C++, wouldn't learning Carbon be easier? Is there anything you can do in Cocoa which you can't also do in Carbon?

Comments

  • Reply 1 of 12
    kickahakickaha Posts: 8,760member
    Shame you had to learn C++ and screw up your concepts of OO... :/ [1]



    If you're more comfortable with procedural programming, then Carbon will be easier.



    If you're more comfortable with a dynamic OO environment, then Cocoa will be easier.



    Personally, I VASTLY prefer Cocoa. Others disagree... but Apple's own advice is that if you're starting a project from scratch, or if you don't have a bunch of legacy code lying around, use Cocoa. Remember, you can always splice in your C++ experience with Obj-C++, and you can use a lot of Carbon calls from a Cocoa app, if you prefer that route.



    You don't need to know Smalltalk to learn Cocoa, by the way... just dynamic OO programming concepts. Apple's Obj-C document is actually a pretty good starting point for having those concepts presented in a clear way. The hardest part will be *un*learning much of what you had to work around in C++.



    [1] I use C++ for many projects. I know it inside and out. Doesn't mean I think it's a well designed *OO* language. It's class-based, not object-oriented, and plays under a different set of assumptions and rules.
  • Reply 2 of 12
    pp Posts: 12member
    I have a background fairly similar to yours, and I found Cocoa a lot easier to get going with. Learning Objective-C is a snap. In fact, it works like this:



    You have an object myObject with a method myMethod. Calling that method is done by



    pointerToResult = [myObject myMethod]



    Calling a method with arguments works like this:



    pointerToResult = [myObject myMethod2WithArgument:value1 andArgument2:value2]



    See, that's all you need (except declaring a subclass, but ProjectBuilder does that for you, pretty much). Seriously, learning Obj-C is a trivial matter compared to learning either Carbon or Cocoa. I used the book "Cocoa Programing for Mac OS X" by Aaron Hillegass, ISBN 0-201-72683-1. I found it very useful, and the author has a site for support on the 'net.
  • Reply 3 of 12
    kecksykecksy Posts: 1,002member
    How is Objective C++ different than regular C++? Is the syntax pretty much the same? That would make learning Cocoa no more difficult than learning Carbon. Both will require me to become acustomed with the Mac enviorment. Maybe I could learn both at the same time? Or is there no point? Is there any situation where knowledge of Carbon would be useful.
  • Reply 4 of 12
    I'd go with Cocoa because so much stuff is done almost automatically for you when using Cocoa.
  • Reply 5 of 12
    kickahakickaha Posts: 8,760member
    Obj-C++ is just Obj-C and C++ code mixed.



    No, really.



    See, the two syntaxes are essentially orthogonal, so the compiler can't get confused as to whether a construct is Obj-C or C++.



    So, you can mix them at the statement level, with some caveats:



    obj = [otherObj method];

    cppobj.othermethod(obj);



    Neat, huh?



    So you can pull in your old C++ code if you'd like, but work in Obj-C as your main language.
  • Reply 6 of 12
    kickahakickaha Posts: 8,760member
    This might be of some interest... LinuxJounral article titled "Objective-C: The More Flexible C++"



    <a href="http://www.linuxjournal.com/article.php?sid=6009"; target="_blank">http://www.linuxjournal.com/article.php?sid=6009</a>;
  • Reply 7 of 12
    [quote]Originally posted by Kickaha:

    <strong>Obj-C++ is just Obj-C and C++ code mixed.



    No, really.



    See, the two syntaxes are essentially orthogonal, so the compiler can't get confused as to whether a construct is Obj-C or C++.



    So, you can mix them at the statement level, with some caveats:



    obj = [otherObj method];

    cppobj.othermethod(obj);



    Neat, huh?



    So you can pull in your old C++ code if you'd like, but work in Obj-C as your main language.</strong><hr></blockquote>



    ... didn't know that, very cool!



    I guess Microsoft is trying to knock off Java with C#, forgetting all the cool things you can do with Obj-C, of which Java was a knock-off - but with much of the dynamism removed.



    I suppose at some point in the future, people are going to realize a wrong turn was made between at the dynamism fork in the code road back in the mid 80's, especially since, the one issue that makes software faster and more powerful than any else is the ease and speed with which you can get to your third re-write!
  • Reply 8 of 12
    Best way to go is learn Cocoa and Carbon.
  • Reply 9 of 12
    kecksykecksy Posts: 1,002member
    That's what I'm doing. Learn both at once.
  • Reply 10 of 12
    [quote]Originally posted by Kecksy:

    <strong>That's what I'm doing. Learn both at once.</strong><hr></blockquote>



    Unless you plan on making a living bringing some legacy app up to date, or you plan on importing softare that can't be imported any other way - your best bet is probably to just learn Cocoa, with a smattering of Carbon basics along the way.



    Otherwise, for the most part, you'll just spend an awful lot of time learning a more difficult way to do almost the same thing.
  • Reply 11 of 12
    kickahakickaha Posts: 8,760member
    Agreed... Cocoa is the 99% framework for 50% of the effort.



    Carbon can definitely step in and assist where Cocoa isn't up to snuff yet, and is useful to have to plug gaps... but I can't say that I'd recommend putting a lot of time into it.



    If you can program even reasonably well, you can pick up sections of Carbon quickly - it's the comprehensive whole that's the royal pain in the keister.



    Cocoa's the opposite - you'll feel like you don't get it, you don't get it, you don't get it, then *bam* you get *all* of it. The comprehensive whole is slick... but the pieces don't seem to make much sense on their own. Steep initial learning curve, but then smooth sailing.
  • Reply 12 of 12
    dfilerdfiler Posts: 3,420member
    [quote]Originally posted by Pismo:

    <strong>After being forced to learn C++ in a DOS environment and briefly attempting to learn Visual C++ (What a piece of crap!), I really want to learn how to write Mac programs. I know Cocoa is recommended for writing new applications in OS X, but since I'm not familiar with Smalltalk and already know a good deal of C++, wouldn't learning Carbon be easier? Is there anything you can do in Cocoa which you can't also do in Carbon?</strong><hr></blockquote>



    Quick, high-level comments from a self proclaimed code and API monkey:



    I highly recommend learning Objective-C and Cocoa. Simply doing so will teach you much about how programming languages should be structured. Unfortunately, these skills may not be directly marketable since there are few commercial developement houses currently using them. Most Mac companies code in carbon and will continue to do so for the foreseeable future.



    Its now almost torturous for me to use lesser development environments at work. I frequently wish that Java had come out as nicely as cocoa/obj-C. Also, the advantages of OO programming are much more apparent with these tools. I got my start in the procedural era and it seems now as if I've jumped straight over the first generation of OO environments. C++, while extremely flexible, doesn't seem to coerce programmers into code structures which can be rapidly developed and easily maintained. The syntax of Obj-C message passing alone can change the manner in which you conceptualize your program's object tree. Cocoa's is a nicely structured framework that will also spoil you. Java's APIs are similar but Cocoa shows you how fewer, simpler objects can be used to provide the same high-level functionality.



    In summary: Cocoa/Obj-C will show you just how few lines of code are actually required when software is written correctly. You may never get payed for coding with these tools. However, even if you end up coding in C#, VB, java, or cobol, you will find yourself wishing that you were allowed to do things the easy way. This wish is the hallmark of any good programmer.
Sign In or Register to comment.