Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Apple Businesses

Which Coding Framework for Mac OS X ? 334

DrStrangeLoop asks: "I am in the progress of getting into coding for Mac OS X, and I am wondering which GUI framework/language i should focus on. Apparantly, there are at least three options: the Cocoa Objective-C API [I don't want to learn Objective-c, but it seems that's how Apple wants me to code], the Cocoa Java API [gets compiled to PPC binaries, lots of APIs available [think Google], but absolutely no decent documentation to be found] and Swing Java classes [look 'n feel of Cocoa, but portable]. However, the most important feature for me is a clean and easy IPC with BSD layer processes. I figure sockets will work with all options, but what about the other mechanisms? Any suggestions?" Update: 10/13 22:08 GMT by C :For those curious about the Cocoa/Carbon debate, you can find an article that discusses this very issue, here. Thanks to the folks over at Freenode's #macdev for providing the link.
This discussion has been archived. No new comments can be posted.

Which Coding Framework for Mac OS X ?

Comments Filter:
  • You also have Carbon (Score:5, Informative)

    by akac ( 571059 ) on Sunday October 13, 2002 @01:13PM (#4441282) Homepage
    Carbon is a good API to begin with. You can use C++ or C and access all the nice GUI of OS X.

    Cocoa just makes things a lot easier.

    I like to think of it this way (though technically its wrong, its a nice way to think of it): Win32 == Carbon; .NET == Cocoa
    • by BitGeek ( 19506 ) on Sunday October 13, 2002 @06:52PM (#4442518) Homepage

      Carbon only exists to support people who have existing Mac OS applications that they want to move to OS X.

      If you're beginning, learn Objective C and use cocoa.

      There is no reason to use carbon for new applications. You can access every API that exists in carbon from within cocoa apps and objective-c, but the reverse isn't true.

      With Cocoa you get everything Carbon has, but with Carbon you don't get everyhting Cocoa has-- especially the superiority of Objective-C and the Appkit and Foundation frameworks.

      Anything you really need to do, you can do in carbon, its just a lot harder.

      There's no reason not to use Cocoa for Mac applications.

  • I'd go with Cocoa. The more native, the better.
    • Though I prefer Cocoa, Carbon is just as native as Cocoa is.
  • learning objective c (Score:5, Informative)

    by Dougal ( 1492 ) on Sunday October 13, 2002 @01:16PM (#4441298) Homepage
    To be honest, I'd say get over it and learn Objective C. For an experienced programmer it won't take you long to get to grasps with the basics of Objective C, and Cocoa is really easy to work with. Who knows, you might even grow to like it :) At first I thought Objective C was weird, but now I really like it.

    Get a beginners book and work your way through it. I recommend Cocoa Programming for Mac OS X by Aaron Hillegass, published by Addison Wesley, ISBN 0201726831. This seems to be what most people learn from.
    • by T-Kir ( 597145 )

      I agree, I used to program on the NeXTStep platform (my placement/internship company were typesetters, the native PostScript came in handy) and it is virtually (I may be completely wrong here, I havent touched OS X, let alone Macs ;) ) the same thing, just a tad older

      With our NeXT systems, you could program in Objective C (being the staple diet), but you could also use C/C++ code as well if you wanted. It won't take to long to get used to (I've heard some peeps say that Objective C is more of a proper OO than C++, but I'm not taking any sides here!)... plus as a programmer, once you know the basics it is just a case of getting used to the semantics, syntax style and quirks of the different language you're learning. Good Luck!

      • The NeXTSTEP API is quite a bit different than Cocoa. They're both Objective-C, use MVC throughout, and share many of the same class names, but the API is a lot different.

        OpenStep and Cocoa, however, are virtually the same thing. OpenStep was a big revision of the OS and the API.

        But all the same, I heartily reccomend using Objective-C and Cocoa, especially above the other options presented: Java and C/Carbon.
  • by tqbf ( 59350 ) on Sunday October 13, 2002 @01:17PM (#4441306) Homepage
    If you need "clean and easy" integration with "BSD IPC" (the native programming interface of the underlying Darwin operating system), you need to be able to use its C-language calling interface. Of the 3 kits you mentioned, Cocoa/Objective-C is the only one that offers that.

    The ready-made integration offered by your two Java alternatives may not be useful for hardcore I/O anyways. How do you get a handle on an fd-based resource (/dev/bpf*, for instance) and then integrate the fd with your event loop?

    My moving-forward plan has been to maintain my application logic in standard C/C++, and use Cocoa/ObjC to build UI (and nothing else) on top of that. Since most good BSD code is asynchronous, and Cocoa/CoreFoundation lets you control the event loop at the "select()" level, this works fine for me.

  • Cocoa all the way (Score:5, Informative)

    by petrilli ( 568256 ) on Sunday October 13, 2002 @01:17PM (#4441308) Homepage
    As someone who grew up around Macs, and then moved to NeXT, I'd have to say that if you know C, and understand OO principles (prefferably in the Smalltalk model, not C++), then you can pick up Objective-C in an afternoon. It's really just some extensions to C. Carbon is a great set of APIs if you've got 10 years of Toolbox experience on the Mac, but otherwise, it's much harder to learn the ins and outs.

    Cocoa, because of it's past with NeXTstep, has a lot of emphasis on rapid-prototyping and dynamicism. Lots of delegation, lots of easy stuff to do to get an effective solution. As for Java, I'd have to follow Aaron Hilldegrass' advice... don't. Not on the Mac, not unless your goal is cross-platform. If you're writing for the Mac, write in Objective-C, C++, or even REALbasic, but not Java. There's simply no good reason.

    Having written nearly identical programs many years ago for Mac, PC and NeXTstep, I'd say this. Mac and PC (Mac = traditional Toolbox on OS7.x) and Win32 are roughly equivelent to get the work done. Different, but one isn't necessarily easier. The NeXTstep app was implemented in 1/3 of the time, and that included me learning NeXTstep.
    • by Anonymous Coward on Sunday October 13, 2002 @01:33PM (#4441376)
      The above poster hit the nail on the head.

      Now, for my own two cents regarding Java+Cocoa: Don't do it. Some friends and I programmed a Jabber-based instant messenger in Java and Cocoa before OSX was officially released. Working with the beta frameworks was a nightmare, for one simple reason: Nobody else was doing anything with Java and Cocoa. To my knowledge, there are only a handful that work with it now.

      Like other posters have said, if you're just starting out on a platform, get over your fear of learning a new language. Objective C + Cocoa on OSX and C# + Windows Forms on WXP are the way to go. Also, Carbon, like MFC on Windows, is only really useful if you've got a lot of experience with the older Mac operating systems. There's a lot of cruft in there that's not really necessary and can be a pain to learn. You should find yourself developing a lot cleaner code a lot faster if you take the time to learn the newer tools available.

      Have fun. =)

      Obligatory resume (on topic because it lists the project!... riiight): http://www.cs.hmc.edu/~awooster/resume.htm
    • I also thought that it was pointless to create a native application using java, but then, out of necessity, that's exactly what my first OS X application ended up being.

      I have a web-based app that I wanted to create a non-web GUI for (involved various file uploads and stuff that could more easily be handled via a native GUI). The server supports XML-RPC, but at the time, I didn't have an XML-RPC framework I could use from Objective C. However, I did have a fully functional commandline app that did it that I'd written in java.

      So, I just fired up project builder, told it I was writing a java cocoa app, and spent a while getting the UI the way I wanted it, then just plugged in a couple methods to the controller to call the existing code.

      Because this was my first OS X application, it was a learning experience as far as picking up the cocoa concepts and stuff, but it only took a day of me being home sick (and I felt pretty crappy, so I wasn't working all that fast).

      The time I spent learning cocoa concepts was not wasted at all. I figured out how to build frameworks and get them into my application, so I had the stuff I needed to go full objective C. I *copied* the UI I'd already made into a new project, and pasted a lot of the code straight from the java app to the objective C app (mostly controller stuff). Of course, I had to convert the java cocoa calls to objc, but for the most part, that was it.

      Moral of the story: If you intend to write a native OS X app, and you don't have all the parts you need in objc, but you do have most of it in java, do it in java! It was a good proof-of-concept anyway. :)

  • by ageitgey ( 216346 ) on Sunday October 13, 2002 @01:20PM (#4441320) Homepage
    I think you are missing a vital point. You can't just say "I'm getting into coding, is X or Y better?"

    What is it exactly that you are writing? If you are writing a 3-D game, then the Java-Cocoa API is probably out. If you are porting your java-based massive application to Mac, than ObjC is probably out.

    Basically, choose the one that fits your application's needs. If you just want to mess around though, go with Java-Cocoa just because it's more immediate.
  • by zulux ( 112259 ) on Sunday October 13, 2002 @01:21PM (#4441328) Homepage Journal

    I love C++, templates, and think nothing of derfrrencing a pointer to a vector of objects that are stored in a crazy containter that I cobbeled together last night while high on cough syrup and mountain dew:

    However -

    Objective C kicks ass for GUI apps. It's easy to learn, and hides some of c's rough edges, and it's fast to compile. Make no mistake - nobody's going to code the next operatig system in it - but for GUI apps, take this good tool and run with it.

    • Make no mistake - nobody's going to code the next operatig (sic) system in [Objective C].



      Funny, that's just what Apple did.
      • Funny, that's just what Apple did.


        Are you seriously claiming that the kernel of the OS is written in Objective C?

        If it is, please tell me, as I'd be quite impressed.

        AFAIK - the Kernel and Darwin are C, but hey, I'd like to know if otherwise.

      • Unless I am sorely mistaken, the kernel that runs OSX is not written in ObjC. While a OS is more than a kernel (as RMS will gladly point out) the bits that talk to the hardware are the important ones and they are not ObjC.
        • I've not downloaded the XNU sources to take a look, but I do know that OS X kernel extensions are generally written in C++, amazingly enough.

          I've done a bit of hacking on the keyboard driver to rearrange my TiBook's keyboard. There's a fairly elegant way to patch things, all object-oriented.
        • Yes, they are, fucking look at the kernel source before you post drivel like this. Various parts of the kernel are coded in C, C++, and Objective-C++
        • While a OS is more than a kernel (as RMS will gladly point out)

          But an "Operating System" without a kernel is NOT an operating system, and that's why RMS doesn't get any respect anymore.
  • Mozilla (Score:5, Interesting)

    by Fished ( 574624 ) <amphigory@@@gmail...com> on Sunday October 13, 2002 @01:28PM (#4441355)
    I asked myself the same question a few months ago, and came to the conclusion that unless/until I have an application that requires a native API, I would do everything in Mozilla. In practice, this means a combination of XPCOM, XUL, RDF and javascript. It's like developing a really advanced web page, but you're not stuck in a browser framework.

    Several advantages:

    1. Easy cross platform. Your app will run on any platform Mozilla/Netscape run on.
    2. Easy development. Subjectively, development goes a lot faster than under a traditional framework.
    3. Something you probably already know: most people I know who program already know HTML and Javascript to some degree. From there, it's a very small leap to XUL and Javascript.
    The major disadvantage is that it will necessarily be a little slower than a custom coded native solution. But who cares for most apps? With recent Mozilla versions, it's more than fast enough. Anyway, my $0.02

    Patrick

    • Re:Mozilla (Score:5, Insightful)

      by Lao-Tzu ( 12740 ) on Sunday October 13, 2002 @01:41PM (#4441410) Homepage

      As a co-author and currently sole developer of a Mozilla component application, I feel I'm qualified to voice an opinion on this. (MOOzilla [www.moo.] being the application)

      Mozilla is really damn cool. You can do some amazing things by combining existing Mozilla code with your application. For example, yesterday I discovered a way to dump an entire MOO/MUD session into an HTML file by using a function in nsContentAreaUtils.js. This was funky. It was not, however, exactly what I wanted, so I now need to write similar code myself. The point is that Mozilla is great...

      But I can't see using it for anything that doesn't somehow relate to web browsing or networking. I know there have been efforts to do elaborate things like writting Office suites in Mozilla, but I don't think it's really feasible because the API availble through XPCOM is more geared towards this kind of web-based development. In MFC, for example, you have access to beautiful serialization and dynamic runtime creation and other nifty stuff that makes coding easy.

    • Re:Mozilla (Score:5, Informative)

      by Fished ( 574624 ) <amphigory@@@gmail...com> on Sunday October 13, 2002 @02:01PM (#4441497)
      People responding seem to be missing a crucial point: I am not talking about a web application here. I am talking about using the mozilla framework to develop a local application. This is actually how Mozilla, including Mail, Messenger and Composer, is developed.

      If you haven't looked at it closely, don't knock it. Take a look at Creating Applications with Mozilla [mozdev.org], from O'Reilly (of course.)

    • You could develop for Mozilla (and, with some effort, wind up with something that would work in the COM/ATL/XYZ equivalent environment that Windows provides). You might even be productive in that environment. But you're not developing and OS X application, and you shouldn't kid yourself.

      Mozilla/XUL on OS X is hard to take. It reimplements the entire UI toolkit (and what it comes up with looks nothing like the Apple guidelines). It's also incredibly slow (as in, KEYSTROKE LAG in text inputs!). And unlike in Win32, where IE can hide in the background and leave you with something that looks like an application, in OS X you'll be literally running your application through the nightmarishly bloated Mozilla environment.

      You're also kidding yourself if you think you'll wind up with something cross-platform. XPCOM doesn't magically make a C library compiled PPC Mach-O work on x86 ELF.

      Don't get me wrong; I like the COM/DOM/C++ environment and have worked on teams that used it successfully. But right now I think it's mostly applicable to dynamic web applications (people put up with more in client/server situations).

      • I have to wonder - what version of Mozilla are you basing this on? I am running Netscape 7 as we speak, and it seems quite snappy to me. As far as environmental bloat .. that seems to be true of virtually all the environments out there nowadays. Looked at .net lately?

        I recognize that xpcom components are not automatically portable, but they are a heck of a lot more portable than most similar environments. XPFE takes care of most of the nitty-gritty work necessary to make them portable.

  • by dpbsmith ( 263124 ) on Sunday October 13, 2002 @01:31PM (#4441369) Homepage
    I'm not sure whether it is suitable, but It does give access to the full API via "declare" statements.

    Don't reject it out of hand just because it isn't a "macho" language.

    I don't say it's the right environment for you. I do say you're being foolish if you don't at least take a look at it.

    You can make a very good evaluation because REALsoftwarelets you download a version that is complete, and comes with full documentation (it produces time-crippled applications that only work for thirty days).

    • by Pahroza ( 24427 ) on Sunday October 13, 2002 @01:45PM (#4441428)
      How could someone possibly overlook RB? Have you seen the footprint of RB apps ? Blech. Cocoa is the way to go.
  • by statusbar ( 314703 ) <jeffk@statusbar.com> on Sunday October 13, 2002 @01:39PM (#4441398) Homepage Journal
    If the app GUI is fairly simple, do the back end in a c++ library, and do the front end in Cocoa.

    But if you have a complex GUI, do take a look at QT/Mac [trolltech.com] from trolltech. It isn't FREE but it is quite good and allows your program to be portable between Mac/Linux/Windows.

    --jeff++

  • Cocoa / Obj-C (Score:5, Informative)

    by Sahib! ( 11033 ) on Sunday October 13, 2002 @01:39PM (#4441400) Homepage

    Definitely, learn [apple.com] Cocoa and Objective C if you can, just for the experience of realizing how much better it is that most of your other choices. With InterfaceBuilder [apple.com], you can completely abstract your UI [apple.com] from the core of your code.

    Since you say you want to use the BSD layer, I suggest making a command-line [apple.com] version of this core code first (you can do this in C or C++), since this will be immediately more portable to other Unices. Once that is done, tying that code in with the UI you build in InterfaceBuilder is simple.

    Also, there are some pretty interesting [apple.com] native IPC libraries [apple.com] in Mach. If you don't mind your code [apple.com] being tied to Mach, you should check that out as well.

    Oh, did I mention that Apple's developer tools and documentation are free for download [apple.com]?

  • use Cocoa (Score:5, Insightful)

    by d3xt3r ( 527989 ) on Sunday October 13, 2002 @01:40PM (#4441406)
    As another person just getting into the OS X programming game, I was wondering the same thing. After looking around Apple's web site, and playing around with the different frameworks, it became apparent to me the Cocoa + Obj-C was the way to go.

    Objective C is easy to learn and can be intermixed in the same source files with C++ (and obviously C). It's one of those "use the right tools for the right job" things. The GUI is most easily programmed with Cocoa using Objective-C, but if there's a nice library you want to utilize that's written in C++, there's nothing stopping you from using it.

    Once you get comfortable with Objective-C, you realize that it is almost as easy to use as Java.

    Now for the alternatives:

    1. Java Swing on OS X: I have a database tool that I am creating as a cross platform app that is written entirely in Java using Swing. It runs beautifully on OS X and looks (almost out-of-the-box) like a native application. However, it is still slower than a native app. Users who expect a snappy GUI will be disappointed with a Java Swing app on OS X. While it performs admirably better on OS X than Windows or Linux, I'd stay away from Java Swing if cross-platform binary compatability is not a major requirement.
    2. Carbon: From what I could understand from Apple's web site, Carbon exits for one reason: to give developers a migration path from OS 9 to OS X. Carbon is a gateway API since Cocoa simply is unsupported on OS 9. It is obvious that Apple's go-forward plans are for Cocoa and Objective-C.
    3. Java and Interface Builder: I serisouly recommend not using this combination. You are going to force your Mac OS X only application to run in a Java VM without the cross-platform benefits of Java. This approach only seems logical if your backend is written Java and you want to create native GUIs on all platforms. I would stay away from this for an OS X only application.
  • How about Qt/Mac (Score:3, Informative)

    by SilverSun ( 114725 ) on Sunday October 13, 2002 @01:42PM (#4441414) Homepage
    Qt/Mac [trolltech.com] from trolltech:


    Qt/Mac runs on Mac OS X. It uses the native Carbon API and does not require any special libraries.

    Qt/Mac can be used with Apple's Project Builder and the gcc compiler that is shipped with Mac OS X.


    I used gtk for a while and now switched to Qt. It is just wonderful. I can just recommend it to anyone who is willing to use C++/perl/pyth/ruby or so. It is pretty solid, and (wit exeption of the moc-precesser) very beautyfully designed. It is portable and available on Win/Unix/Linux/MacX.

    I ported some of our apps to Qt/Mac. Well, I recompiled the Qt stuff and the porting was related to other parts.

    Even though many people don't seem to realize, it Qt is fully GPL. The plain, good ol GPL. So if you project is GPL it is a very good choice. If not, you probably have the money to pay and it is still a good choice.

    Cheers, Peter
    • Only on X11 (Score:2, Informative)

      by yerricde ( 125198 )

      Qt is fully GPL.

      Only when compiling for the X11 target, which requires Mac users to install XDarwin and Windows users to install Cygwin and XFree86.

  • Java Cocoa (Score:5, Informative)

    by BlueGecko ( 109058 ) <benjamin.pollack ... om minus painter> on Sunday October 13, 2002 @01:43PM (#4441418) Homepage
    the Cocoa Java API [gets compiled to PPC binaries, lots of APIs available [think Google], but absolutely no decent documentation to be found]
    First, Java Cocoa is not native. Your application will still run on the Java VM. In my mind, it fills a very narrow purpose: it allows you to quickly turn a 100% Java application into an application that behaves exactly like a truly native OS X application and which can take advantage of the niceties that provides (for example, Services support, Sheets, Quartz, etc.). Secondly, I hear the complaint about the lack of Java API documentation all of the time, and I honestly don't understand it. Admitting that I've been working in NEXTSTEP and later OpenStep and then Cocoa for a very long time, Apple provides a detailed Java API reference that has class-for-class and method-for-method documentation exactly on par with the ObjC documentation and also provides a tutorial for Java developers that literally produces exactly the same application as the ObjC Cocoa tutorial. You need merely do both tutorials to see how exactly the two APIs line up. The only somewhat legitimate complaint is that Apple examples typically come as ObjC, but how hard is it, honestly, to figure out that [aSpellingChecker ignoreWord: @"bodacious" inSpellDocumentWithTag: myTag] becomes aSpellingChecker.ignoreWord("bodacious", myTag)? The rules for ObjC-to-Java conversion of APIs and code are very straight-forward:
    1. Any code relating to autorelease pools may be deleted and ignored (at least in basic code; by the time you need to make use of manual garbage collection in Java Cocoa (multithreaded code in the GUI being a big one), bluntly, you'll already know enough that it won't bother you)
    2. Java class names remain identical to their ObjC counterparts, and are in either com.apple.cocoa.foundation if they are part of the ObjC FoundationKit and part of com.apple.cocoa.application if they are part of the ObjC AppKit. (QuickTime is in its own API and really is a separate discussion, since "QuickTime for Java" has existed for several years now and is more a part of Carbon than Cocoa.)
    3. Method names for Java always consist of the first part of the ObjC identifier and always take the same parameters (except that NSStrings become java.lang.String). For example, (void)NSSpellChecker>>ignoreWord:(NSString *)inSpellDocumentWithTag:(int) becomes void NSSpellChecker.ignoreWord(String, int).


    All that said, I would strongly recommend you take the time to learn ObjC Cocoa. I use Java Cocoa when I am grafting a Cocoa UI onto Java code, but ObjC is still faster (though the gap is narrowing) and I still honestly believe the language is still a bit more productive due to things such as Categories, Smalltalk-style method names, and other things. If you know C and Java and are familiar with the concepts of reference-counted garbage collection, learning ObjC will take you the better part of a morning.
  • by Have Blue ( 616 ) on Sunday October 13, 2002 @01:44PM (#4441426) Homepage
    If you are developing a GUI application from scratch and portability is not a concern, learn Cocoa. Interface Builder is hands down the best GUI-building tool in the industry.

    If you are already a C++ expert and have no desire/resources to learn a whole new language, or you want to use a more traditional toolkit that's easier to port, or you are porting an app written for Windows or OS 9, use Carbon. It's essentially identical to the Mac Toolbox, with a few types changed and memory hacks replaced with accessors.

    If portability is very important, use Java. OS X's implementation of the various Java GUI toolkits provides the Aqua interface automaticaly, as well.

    It is possible to use all of OS X's native APIs (Cocoa, Carbon, and Posix) in the same project, if you really must. The libraries are already quite interdependent and any potential conflicts are noted in the documentation (i.e. don't use NSThreads and pthreads at the same time).
  • by critic666 ( 317551 ) on Sunday October 13, 2002 @01:48PM (#4441440)
    Truthfully, Objective-C takes ~2 hours to learn. In fact, check out the first chapter of my (needing-to-be-updated) tutorial, Using Objective-C++ on Mac OS X here [areax.net] for a comparison of ObjC to C++.

    I used to be a C++ programmer, and then I spent some time playing w/ Cocoa, learning how the system works, and now, if Cocoa goes away, I think I'll quit programming. Its simple elegance and power is astounding, and freeze-dried objects in the NIBs are just cool. Just play w/ some of the tutorials (e.g. currency converter) before you discount it.

    However, Cocoa-Java is kind of worthless. It's a kludge, and some of Cocoa's coolness comes from the weak-typing (id is slick--sort of a void* you can send messages to). Take a look @ cocoadevcentral, too.

    Carbon, though, is klunky by comparison. Programming for that is just like programming for Windows/Linux...it's an API, and you can do nifty stuff, but it's not slick. Cocoa is slick. 'nuff said :)

    Josh
    • Probably because that is the reason I decided to support mac development. My apps need a common code base (since they are for linux, windows and mac os x) and java is the easiest way to go. Custom UI, standard classes.

      As far as the Carbon programming maybe it's the developer not the tool. I could try building my own house (by hand) but why when I couldn't frame a house to save my life? My framer is skilled in building and I am not. Same goes for Carbon programming, Adobe Photoshop seems to run just fine and it's a carbon app.
  • Use Cocoa (Score:3, Insightful)

    by Anonymous Coward on Sunday October 13, 2002 @01:54PM (#4441464)
    Let's get this straight: you want to learn an entire framework, and your primary complaint is about learning a minor extension to C?.

    Objective-C is a small, elegant object-oriented version of C. It's very easy to learn, easy to document, and easy to modify. Compared to the size of Carbon and Cocoa, this is absolutely the least important part of your framework-learning experience.

    So here's the deal. Cocoa is an elegant, brilliant, clean and simple framework derived from the (rightly praised) NeXTSTEP/OpenStep libraries. Carbon is an evily patched hulking pile of OS9-compatible goo. The difference between these two libraries could not be more stark.

    Apple's proclamations otherwise (made to make Adobe and Microsoft happy), Carbon exists for exactly one purpose: as a porting library for legacy code. The nastiness of Carbon lends some insight into the hideousness of developing for OS9, one of the reasons Apple simply could not get the Copeland project working.

    Use Cocoa.

  • Comment removed (Score:5, Informative)

    by account_deleted ( 4530225 ) on Sunday October 13, 2002 @02:00PM (#4441489)
    Comment removed based on user account deletion
  • by Mindcrym ( 52114 ) on Sunday October 13, 2002 @02:01PM (#4441495)
    Check out the article Introduction To and Experiences With Mac Cocoa [kuro5hin.org] from Kuro5hin.
  • Why not wxWindows? (Score:3, Insightful)

    by kollivier ( 449524 ) on Sunday October 13, 2002 @02:05PM (#4441514)
    wxWindows is a cross-platform GUI toolkit which emulates the native look n feel of the platform it is running on. It's written in C/C++ and runs on Windows, Mac, and Linux. The url is http://www.wxwindows.org [wxwindows.org]. It gives you the cross-platform benefits of Java, as well as access to the underlying BSD layer.

    I have started using wxPython (Python bindings for wxWindows) as my primary development platform, and am quite happy with it. It enables me to develop my application on OS X, even though my primary target audience is using Windows. =)
    • by Anonymous Coward
      It's doesn't emulate at all. It actually calls the carbon api, they're just adding a portability layer on top that makes sense for all platforms.

      I've been using wxWindows for linux and windows for about a year now, writing diagnostic tools for our manufacturing plant (some very complex). I've needed to get down and dirty with process monitoring, threads, and IPC, and I can tell you, that wxWindows is great. I was able to write once in linux (my prefered platform at work) and just compiled it on windows.

      As for the mac, I would imagine it's similar, but I don't have the experiece yet (just got my mac a month ago).

      And the best part is, it's free.
  • by Dr. Awktagon ( 233360 ) on Sunday October 13, 2002 @02:15PM (#4441551) Homepage

    I just started programming Mac OS X (I did a little Mac programming in the System 7 days and HATED it, since I was programming Unix at the time). But OS X is great.

    I'm focusing on Cocoa myself, but here are some data points for you:

    Objective-C is a lovely language. I looked it at back in the NeXT days and thought "cute, but it'll disappear and be replaced by a better version of C++". Well, Objective-C is still here, and C++ never got any "better". So you ought to learn Objective-C, it's very much like Smalltalk mixed with C, very elegant. I might start writing Linux and BSD programs in it. Also, it interfaces easily with the BSD side of Mac OS X. For instance, you want math libraries? You just use the standard math.h stuff! That's nice.

    Don't use the Java Cocoa stuff. It STINKS. I think they just added it for a "bullet point". The documentation isn't as complete. It's very slow. Objective-C is a nicer language anyway, since it is dynamic. With Java you have to use a lot of reflection hacks to get the same results, not nearly as elegant.

    Java DOES NOT (correct me if I'm wrong) compile to native code with ProjectBuilder. ProjectBuilder simply wraps a launcher around the java bytecode. If you drill down into the application package, you'll find the regular jar files.

    The use of the Java Swing (non-Cocoa) stuff is simply to get your existing Java apps up and running fast. It took me just a few minutes to turn a Java program I wrote on Linux with Forte into a double-clickable (but slow) Mac OS application. Don't bother using this for new stuff. Your program might LOOK like an Aqua app, but it's really Swing.

    Carbon let's you use C/C++. But it isn't a "compatibility layer" .. it's not obsolete or "going away". It's simply a cleaned-up version of the original Mac API. So if you choose this route, don't feel like you'll have to stop using it one day or something. I think Apple will support it indefinitely, alongside Cocoa.

    Cocoa is a little slower than Carbon, because Objective-C is a dynamic language, and it has to decide things at run-time (like, say, Perl). Not a big deal these days, but raw speed is not a selling point of Cocoa GUIs.

    AppleScript Studio: if you like applescript, you can write full applications in it. Just like on Linux you might want to throw together a simple Python script, etc., with a GUI. It doesn't hurt to learn applescript, especially if your Cocoa apps will be scriptable.

    Interface Builder is just soil-your-pants awesome and let's you create, instantiate, and hook together non-GUI objects, right along with GUI objects. Also note that IB actually creates the GUI and other objects and serializes them to a disk file. It doesn't create any code or do any other tricks. And XML is used throughout for properties, etc..

    So IMO your best choices are: Cocoa/Objective-C, or Carbon/C (or C++, blech). And I think everyone should learn Objective-C .. I'd like to see it used more for non-Mac stuff too.

    Everything you need, including books and tutorials, comes on the Developer CD. Go through the Cocoa/ObjC tutorial.

    Also note that if you sign up for the Apple Developer stuff, you have to agree to some pretty disgusting terms, including giving Apple the right to search your place of business on 24 hours notice. I shit you not.

  • by Anonymous Coward
    Mac users care a great deal about nativity and the app behaving like a good Mac OS X app. (Otherwise we could be using something cheaper and less elegant, right?) Cocoa is the most native thing on OS X. If you use Cocoa, you have an immediate advantage over competitors who use Swing or Carbon.

    With Carbon you have to implement a lot of stuff Cocoa gives you for free. I still haven't seen a non-sample-code Carbon app with proper Unicode support. Then there are things that Swing apps just can't do. (And don't believe Sun's pluggable talk. You can't just plug in Aquaness without designing for Aqua.)

    The Cocoa Java API feels like an Objective-C API anyway, so you might just as well learn Objective-C unless you already have Java back end code.

    Objective-C is way cooler than C++.
  • by the_2nd_coming ( 444906 ) on Sunday October 13, 2002 @02:17PM (#4441562) Homepage
    you can still compile C code with an objective-c compiler, infact, Objective-C isw a true supper set of OO features appened to C, so would you then not be able to use Coaca with C code as long as you compile into an objective c binary?
  • ...I'd also suggest taking a look at wxWindows [wxwindows.org]. They're open source, the results look very mac native (they have screenshots), and it seems to be very portable....having libraries for windows, most *nux (using GTK, Xt, or Motif), and macs, and maybe a few others. Oh, and it's c++ for those with an objective-c phobia, like me :)

    I honestly don't know why more isn't done with this framework outside of those crazy python people. It looks good, and is completely free (both as in beer and speech), unlike Qt (not trolling, just stating a fact!)

  • First of all, there's a "fourth" alternative that you did not mention: Carbon. It's a C API that represents a subset of the old Mac OS 9 APIs. It will give you access to Cocoa and CoreGraphics goodies while also giving you access to all of the wonderful Mach and BSD APIs.

    However, Carbon is no fun, IMHO. It's just not as easy to work with as something like Cocoa or Swing.

    Second, why do you say that Cocoa/Java is not well documented? Just look at developer.apple.com and read all about it... Besides, all Obj-C Cocoa APIs have equivalents in Cocoa/Java. So it shouldn't be that hard.

    But, why use Java? Maybe you like it, in which case, go for it... But I think that if you have C and C++ experience you'll find Objective-C to be much more robust for Mac programming, simply because: 1) you can learn it quickly if you already know C/C++, and 2) you get a well thought-out API (Cocoa, formerly NeXT's AppKit) with access (both via Objective-C and via libc and other C APIs) to Mach, BSD, and Mac OS X specific goodies.

    And, for the love of all that is good, pure, and holy, don't use Swing. It's disgusting. Someone needs to beat it into the ground and start from scratch. The only reason that I would see for using it (and, granted, it's a good reason) is for portability... But in that case, I highly recommend Qt (www.trolltech.com). It works nicely on Windows, Linux, and Mac OS X... Only problem is it isn't necessarily free. =(

    Personally, I learned Objective-C in a couple of evenings after reading Apple's (formerly NeXT's) excellent book on Objective-C. It's available for download in PDF format from developer.apple.com.

    So I say go for that, I'm sure you'll be impressed with the results you get.
  • Cocoa (Score:2, Interesting)

    by Anonymous Coward
    Cocoa is the framework of choice for most OSX programming. The mechanics and syntax of Objective-C is easy to learn--you can pick it up in a couple days. (Making full use of what it provides you is a different matter--it can take months to stop thinking like a C++ programmer and take full advantage of the dynamicism of the language.) If you're doing any GUI programming this is the framework you should use.

    Carbon exists to provide a way for old codebases to run on OSX. Consider it only if you're already familiar with pre-OSX mac programming, and then only if you have a big, old codebase.

    Java is useful for cross-platform server apps.
  • If you had done the least bit of research before asking this question, you'd already know to pick Cocoa.

    Carbon is old, and fastly deprecating.

    Cocoa is "the" API to use, and you can intermix C and C++ code to your heart's content with it (eg. BSD code)

    Cocoa/Java is considered crap, even by Apple (see Apple dev docs), and is not ready for prime-time.

    Pure Java is alright, but doesn't give you access to BSD stuff.

    In short: duh.
  • by tim1724 ( 28482 ) on Sunday October 13, 2002 @03:14PM (#4441804) Homepage Journal

    There are two separate issues here: which GUI toolkit to use, and whch language to use. First, choose the GUI toolkit, and then choose one of the programming languages which can be used with that toolkit.

    1. Choose a GUI toolkit
      • Carbon - a cleaned-up version of the original Macintosh Toolbox. It's big and complicated (as should be expected for something which has been evolving over 18 years) and may be somewhat annoying if you don't have previous Mac Toolbox experience.
      • Cocoa - the OpenStep API with a few new features. Clean and simple object-oriented interface designed around the Objective C language. Good for rapid development of GUIs.
      • Swing - Apple provides a Mac OS X implementation of Swing. With a little work, you can make a Swing program look almost native. (But not quite.. a few things end up looking or behaving slightly wrong.) A good choice if you want cross-platform Java code.
      • QT - The Mac OS X version is based on Carbon, so it should look like any native program. A good choice for cross-platform portability.
      • Tk - as in Tcl/Tk .. there's a Carbon port of Tk, but I've had some problems with it.
      • other cross-platform toolkits - There are a few others (wxWindows, for exmaple) but I don't know much about them. As far as I know, they're all built on top of Carbon.
      • Mac-specific libraries built on top of Carbon - things like PowerPlant (a C++ library from Metrowerks) make dealing with Carbon a bit easier.
    2. Choose a language

      Most of the toolkits support multiple languages.

      • Carbon: It's intended to be used from C (although you'll still find a few remnants of its Pascal roots) so it's not object oriented. You can use it from C, C++ (directly or via object-oriented layers like PowerPlant), RealBASIC, and probably a few others.
      • Cocoa: It was designed around the Objective C language, but Apple also provides Java bindings. Java isn't a particularly good fit for Cocoa (better than C++ would be, though) so I don't recommend it. There is a Perl binding called CamelBones which works rather well (Perl and Cocoa go together very well in my opinion). I think Python and Ruby bindings may be available as well.

    For new development, I'd strongly recommend using Cocoa with Objective C. Don't be afraid of Objective C! It's a very simple extension to plain old ANSI C. The additional syntax is minimal (unlike C++) and most of the code you write will be plain old C. Once you've learned Cocoa using Objective C, you may want to use it in Perl via CamelBones. But I'd strongly recommend using Objective C to learn Cocoa, otherwise you won't understand a lot of the reasons why things work the way they do. Don't use Cocoa with Java, unless you don't know C. And even then I'd recommand learning C so you can use Cocoa with ObjC.

    If you want a plain old non-OO API, Carbon isn't all that bad. You'll need to get a good reference, as there are a lot of functions and types to learn about. (Whereas Cocoa is predictable enough that you can usually guess method names!) Or you can use one of the C++-based wrappers such as QT or PowerPlant.

  • Cocoa (Score:2, Informative)

    I have to tell you, I LOVE Cocoa/Objective-C. There are a million benefits to both - Cocoa ( in combination with Interface Builder) gives you fantastically easy GUI creation and control.
    The Objective-C language has got to be the coolest language I have ever used. I love being able to add a method like -encryptWithKey: to the NSData class without subclassing it.
    The automatic memory management with -retain and -autorelease is great, too. Almost never have to worry about it.
    Besides all this, you can use straight ANSI C code (and C++, too, in Objective-C++) right in the same source file.
    In short, give Cocoa a look. If it doesn't meet your needs, try using one of the other solutions. The only thing I can come up with where you would need to not employ Cocoa is if you desire easy portability.
  • my experience (Score:4, Insightful)

    by g4dget ( 579145 ) on Sunday October 13, 2002 @04:46PM (#4442146)
    Unfortunately, there really is no ideal solution.

    I would not be scared of learning Objective-C--it is a very simple language and easy to learn, and its object model is very convenient. But in other ways, Cocoa using Objective-C is a somewhat outdated programming environment: the GUI design tools were great in the 1980's, but they are pretty dated by today's standards. And resource management in Objective-C and Cocoa is a lot more work and a lot more error prone than in Java or C++. On the plus side, Cocoa is what Apple really wants you to use, and that's where they seem to be putting a lot of their efforts.

    Cocoa using Java is probably in a certain sense "the best" programming environment for the Mac: it's modern, easy to develop in, and mostly safe. It's also pretty well supported. But it retains many of the warts of the Cocoa APIs and, as you observed, is not all that well documented.

    With either Cocoa-based solution, you also have to ask yourself whether you believe that Cocoa has a future and whether it's worth learning it. I don't see much of a future for Cocoa, at least in its current form. Apple has made no moves to standardize it or open it up, so it is Mac only. Even if Apple pushed for more widespread adoption, they'd have to make big changes to make it palatable to industry, like adding precise garbage collection and better error checking to Objective-C, with the resulting changes to the APIs. An example of work in that direction can be found here [gerbil.org] (yes, that is "gerbil.org", but it's a site about programming, really).

    Swing Java is probably the least hassle: it's well documented, it works very well on Macintosh, and you still get the native look-and-feel. It has modern resource management and modern layout management. Knowing Swing is useful and helps you on other platforms as well. And its object system is fairly similar to that of Objective-C. But some of the more advanced features have been buggy in the past (e.g., audio input, etc.). You can, however, combine Swing and Cocoa APIs, using Swing for the GUI and dropping down into native APIs only when Sun's cross-platform APIs fail you.

    If you use one of the Java-based solutions but find the Java type system too constraining, you can use Jython [jython.org], a Java-based implementation of Python. You can choose to run it interactively or compiled. It's great for exploring the Cocoa APIs (or the Swing APIs).

    Another choice you may want to consider is wxWindows [wxwindows.org]. Recent versions run very well on MacOSX and look native. If you want to see an example of an application written in wxWindows, take a look at Audacity [sourceforge.net].

    I tried all these different approaches, and I ended up doing most of my Mac programming in Java/Swing and wxWindows.

    • Re:my experience (Score:3, Interesting)

      by bnenning ( 58349 )
      Cocoa using Objective-C is a somewhat outdated programming environment: the GUI design tools were great in the 1980's, but they are pretty dated by today's standards.


      That's a matter of opinion; I and many others would disagree.


      And resource management in Objective-C and Cocoa is a lot more work and a lot more error prone than in Java or C++.


      Not really. Objective C has no built in memory management (neither does C++), but it uses a reference counting system that works well enough that you rarely have to manually allocate or free memory.


      I don't see much of a future for Cocoa, at least in its current form.


      Apple does. Virtually all apps that come with Mac OS X are written in Cocoa and Objective C. iTunes and iMovie are Carbon, but that's only because they were designed to also run on OS 9.

  • If you want something portable and easy to use you might try Python with the pygame library. It has what you need to create games and if you get the right add-on libraries some nice looking GUI programs.
  • Cocoa-Java Bridge (Score:2, Interesting)

    by mxcantor ( 315879 )
    The answer is really obvious - the Cocoa-Java Bridge!

    Any Cocoa program can use any java class nearly transparently as if it were Cocoa! For some reason, Apple has hushed up this amazing feature. So, create a Cocoa app, and then use Java classes as necessary! Most of your code will run native, but if you need the VM, it'll be started for you.

    This is what I used for my no-longer-being-worked-on front end to MySQL called CocoaSQL http://www.versiontracker.com/moreinfo.fcgi?id=108 87&db=mac [versiontracker.com]

    I basically wrote a cocoa app using the mm.mysql drivers, very simple. The source code should be up there, if it isn't, let me know.

    Good Luck, Max
  • First off, the Swing Thing isn't a thing like Cocoa in terms of look-and-feel. It looks-and-feels awfully second-class on many levels.

    Don't even think about Carbon. It's 18 years of evolution from a bitty-box API that was in Pascal.

    Cocoa, on the other hand, is NeXTSTEP, and as any NeXTer can tell you, NeXTSTEP was the best operating system ever (at least the best API ever). It's amazing. Ten minutes with InterfaceBuilder and you'll be hooked. Where as most tools of this sort just give you some kind of data thingy that you have to interface with programmaticly using some magic codes, you can actually put OBJECTS in a NIB file, which will be unpacked at runtime, and automagicly referenced in places where you have references to them. They have these actions and connections. It's great.

    Java is my favorite language (although recently Ruby has been fighting hard for that space), but I must say, the docs for Java-Cocoa are terrible. I gave up and learned ObjC.

    That, inititally took about 45 minutes (I've done C++), but actually getting through the qwerks to where I could use the language well took 2 weeks or so. In a nutshell: If you are used to garbage-collection, you will hate ObjC. Period. It stinks. In almost every other respect, however, ObjC is a great language.

    The Java documentation may have improved a lot since I ws reading it.

    No, in short: Cocoa, cocoa cocoa. And Java if the docs are decent by now, otherwise Objective-C.
  • by BitGeek ( 19506 ) on Sunday October 13, 2002 @05:31PM (#4442303) Homepage

    IF you already know C then learning Objective-C will take a week or two. If you know C++ or Java, then learning Objective-C will take a day or two.

    Cocoa is, bar none, the best environment to develop applications under, on any platform. Therefore, if you've already chosen the Mac platform for your App, then use Cocoa.

    Carbon is there fore backwards compatibility. Some parts of the OS are still carbon, and carbon and cocoa have been "toll free bridged" in places so you can use data structures interchangably. but it is much slower to build an app with carbon than cocoa.

    So here's the simple way to answer your question:
    1) IF you simply must use Java, or want to eventually run on multiple platforms, use Cocoa-Java (Which is well documented. Get Cocoa Browser to get easy access to the docs.) Use any Cocoa book to learn how to write in cocoa-java, just use the Java APIS instead of the Objective-C ones. Though Java isn't perfectly supported and Objective-C is recommended if you don't HAVE to use Java.

    2) IF you have a large application ( greater than 10,000 lines) then it may be better to use carbon. A huge app, like photosohop, it definately makes sense. but any small application would be better off with rewriting the UI using the Appkit and Objective-C and just bringing over the calculation and graphics stuff from the previous version as-is. After all, Objective-C and C code (and even C++ code and Java) can be intermixed.

    3) You should never start a new application using Carbon. Carbon is for backwards compatibility. IF you're starting a new application, use Cocoa and you'll save so much time with the superior cocoa apis that the time it took to learn them will be more than made up for.

    I had a Java application that I wanted to bring to Mac OS X. I started down the path of Cocoa-Java and quickly realized that objective-c was recommended, so I checked it out and discovered even the fact that I was learning a new language, as well as a bunch of new frameworks, I was getting a lot more work done faster using Objective-C and Cocoa than I have in the past with Java.

    Carbon is there for backwards compatibility when it doesn't make sense to rewrite the app. Cocoa-Java is there when you have a JAva app you want to migrate. But Cocoa with Objective-C is the clear, definite, best way to go under Mac OS X.

    And anyone who's taken the time to learn it will tell you that it is far superior to the alternatives.

    I dread dealing with Carbon APIs now as they invariably turn into time sinks where it seems to tkae 4-8 times as much effort to get something done as it would if there were a cocoa api for the area in question.

    Go Cocoa/Objective-C.

Some people claim that the UNIX learning curve is steep, but at least you only have to climb it once.

Working...