Cocoa? Obj. C? Java?

Jump to First Reply
Posted:
in General Discussion edited January 2014
Since there is no forum for Programming/Development here, I have chosen to post this question here. If it is not the correct one, please help me move it to an appropriate forum (Just a suggestion, why not create a forum for programming/development?)



Ok, now this is my dumb question. I have learned some basic programming skills in university as a comp science student. I know C/Java/Perl/unix shell script/Pascal. Since most of the programming work I have done so far is just exercises from school, my knowledge about the real world is very limited.



Since I have bought this iBook G4 last spring and I love it so much, I would like to learn to program on it using Xcode. But I have a few questions before I can start.



1. What is Cocoa actually? Is it a language like C or Java?

2. What should I do to start learning it?

3. Is it portable? I use FreeBSD, Linux and Windows, too.



Thanks for any input.

Comments

  • Reply 1 of 7
    kickahakickaha Posts: 8,760member
    Cocoa is a MacOS X-only API (set of libraries) that can be used from Obj-C, or Java. (You can also program primarily in C++, but use Obj-C snippets to call Cocoa if you want.)



    So it's not a language, but an *extremely* rich set of libraries that allow for very rapid development of powerful applications.



    Like, say, a web browser with XHTML, CSS1, JavaScript, drag and drop, an address bar with feedback, reload and forward/back buttons... with 0 lines of code. Seriously.



    Objective-C is the primary language for Cocoa development, and the one I'd recommend, especially if you have a good solid C background. It *is* portable, since it is now part of the default gcc compiler suite. (It isn't *installed* by default, but it is *included* by default with the gcc source code.) And frankly, it's one of the nicest languages out there in my opinion. (But I do programming language research professionally, and we're a bit weird. )



    You can also use Cocoa from Java, but I'm not a huge Java fan overall. It's not *bad*, just not as nice to use as Obj-C IMO.



    As for cross-platform portability, pretty much any API that plans on being a good player on a platform isn't going to be particularly cross-platform. Swing? Eh, not so much. KDE/Gnome? Eh... My recommendation is that if you're going to want to go cross-platform, that you make sure your logic code and UI code are well-partitioned. Then you can migrate the important part of the system around as needed.



    And on MacOS X, Cocoa and Obj-C are the way to go.



    As for how to start learning it, that's a toughie. See, Cocoa is big, rich, and beautiful, but it's not easy to get started with. There's a bit of a learning curve before the 'aha!' moment hits on how everything should work. Some people never get to that point, and walk away frustrated. (I think it's mostly more of a function that people see the world differently than anything else.)



    I *can* however, give you some resource pointers.



    1) Apple's developer site. Head on over to http://developer.apple.com/ and sign up as a free member. That will get you access to all the documentation and sample code. (Also, be sure you installed the developer tools that came with your Mac.)



    2) Scott Anguish's Stepwise site. http://www.stepwise.com/ is a great place for old school NeXTies to share tips and techniques in Cocoa. Scott also co-wrote a great text 'Cocoa Programming', $42 at Amazon.



    3) Speaking of books, Aaron Hillegass' 'Cocoa Programming for MacOS X' is similarly fantastic. Be sure to get the latest edition with the Cocoa Bindings information.



    4) Bill Cheeseman has the Vermont Recipes Tutorial set that is now also a book 'Cocoa Recipes for MacOS X'. Another good one.



    5) Omnigroup.com has a developer section that is top-notch with some *excellent* source code that they use in their shipping products. They also host several of the *major* MacOS X developer mailing lists.



    That should be enough to keep you busy for a while.
     0Likes 0Dislikes 0Informatives
  • Reply 2 of 7
    Quote:

    Originally posted by Kickaha

    Objective-C... it's one of the nicest languages out there in my opinion. (But I do programming language research professionally, and we're a bit weird. )



    I'll agree with that... the weird part, that is.



    Damn, maybe I will become fond of Objective C some day, if and when I ever get around to spending much time with it, but for now I find the syntax of the language painfully ugly to look at. [Brackets] for method calls???



    I say this as someone who has been doing mostly Java the past five years, C++ before that, and C before that. I even find Objective C uglier looking than Perl... and that's saying quite a bit.



    Quote:

    You can also use Cocoa from Java, but I'm not a huge Java fan overall. It's not *bad*, just not as nice to use as Obj-C IMO.



    Fan of Java or not, it's hard to be a fan of the current rendition of the Java/Cocoa bridge. It just doesn't work very well and is missing a lot of features.
     0Likes 0Dislikes 0Informatives
  • Reply 3 of 7
    kickahakickaha Posts: 8,760member
    Quote:

    Originally posted by shetline

    I'll agree with that... the weird part, that is.







    Quote:

    Damn, maybe I will become fond of Objective C some day, if and when I ever get around to spending much time with it, but for now I find the syntax of the language painfully ugly to look at. [Brackets] for method calls???



    I say this as someone who has been doing mostly Java the past five years, C++ before that, and C before that. I even find Objective C uglier looking than Perl... and that's saying quite a bit.





    Heh. I'd say it took me all of about 15 minutes to get used to the syntax. (Then again, I deal with so many language that syntaxes come and go several times a week... I gotta be flexible.)



    After that, I came to really appreciate the named parameters, and the [] notation makes it *REALLY* easy to find calls to object-methods vs. calls to plain functions. Both are highly useful at making debugging more efficient. And when you're working in Obj-C++, the distinction between "Now I'm calling a C++ object" and "Now I'm using an Obj-C object" is CRITICAL. Being able to quickly and instantly see which is which is a godsend... especially if you're integrating cross-platform C++ code with Cocoa. You can instantly see what bits deal with which sections.



    From my perspective (prog lang geek), if a personal opinion of a minor syntax problem is all you can find wrong in a language, they did a damned good job designing it.
     0Likes 0Dislikes 0Informatives
  • Reply 4 of 7
    Thanks guys



    I think I am going to spend some time with the resources pointed out by Kickaha first before going deeper. I will come back here when I have more questions



    Thanks again.



    p/s I still think that a Developer/Programming forum would be cool! :P
     0Likes 0Dislikes 0Informatives
  • Reply 5 of 7
    emig647emig647 Posts: 2,455member
    Yah obj-c is the nicest lang out there IMO... I love it.



    Don't forget you can use the perl-objc bridge to use perl in your cocoa apps . If you are just starting out ... definitely go with cocoa instead of the carbon API's... this is how I compare these libraries with M$'s....



    Cocoa == WinForms / C#

    Carbon == WinAPI / C / C++



    Good luck.. i'm all for a programming forum... lets do that
     0Likes 0Dislikes 0Informatives
  • Reply 6 of 7
    kickahakickaha Posts: 8,760member
    You can use a *lot* of languages with Obj-C... there's also a Python/Obj-C bridge (PyObj-C) that is pretty darned slick.



    Nothing like coding up Cocoa in Python...
     0Likes 0Dislikes 0Informatives
  • Reply 7 of 7
    emig647emig647 Posts: 2,455member
    Yah you're right... You can use obj-c to build almost any program. If you use gcc you're set since its built in . MMM build a QT program in linux
     0Likes 0Dislikes 0Informatives
Sign In or Register to comment.