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.
Seems like you answered the question yourself. (Score:5, Interesting)
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.
Re:Best Framework for Mac OS X (Score:2, Interesting)
Mozilla (Score:5, Interesting)
Several advantages:
Patrick
Don't overlook REALbasic (Score:4, Interesting)
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).
QT can be the right solution (Score:3, Interesting)
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++
Re:Nothing wrong with Objective C (Score:3, Interesting)
By default, I recommend Cocoa / Objective-C (Score:2, Interesting)
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++.
what is wrong with objective-c? (Score:3, Interesting)
Re:Java -- no question about it. (Score:3, Interesting)
Absolutely you can write good software in Java. I've seen it done, although I admit that I don't have the mad Java skillz to do it much myself.
But you can't write good software with Swing. Swing may be a fine user interface toolkit on UNIX, where there are no superior alternatives, but on a Mac, a Swing application-- unless it's specifically tweaked to use the Aqua look and feel-- is kind of an embarrassment. Java Swing apps run on OS X just fine, but they're unpleasant to use.
this post just makes me angry
I'm sorry. You get angry at strange things. Must have missed my post in another discussion about how disappointed I am that Mozilla is irrelevant; that post made lots of people angry.
Try Qt (Score:1, Interesting)
Cocoa (Score:2, Interesting)
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.
Re:Best Framework for Mac OS X (Score:1, Interesting)
A cocoa app takes less code to write and you get it done a lot faster. If you are a programmer, you learn new languages all the time. It took me 2 hours to learn objective c, and I came from a strong c++/java background.
Its a cakewalk to take a commandline unix app and wrap a cocoa gui around it. The Gui made in interface builder takes up NO CODE.
You can also intermix c, c++, and objective C.
Cocoa is the best way for new programmers. If you doubt me, do the Currency Converter tutorial the Carbon way first, then do it the Cocoa way.
There *is* a good reason for java cocoa (Score:2, Interesting)
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.
Re:The Master Of C (Score:1, Interesting)
Imagine bytes in memory are simply numbered pigeon holes. The first hole is '0', and you go up from there.
A pointer is a variable that holds the address of another pigeon hole. Pretty fucking simple. And from there, it's only a simple step to pointer arithmetic. If a piece of data takes up two pigeon holes, incrementing a pointer of that type will increase the address value by 2.
The problem really is that not enough people learn about computers. They learn 'programming' as if it was at a higher level than it really is, and this is both bad and stupid. Teach the low level first - you need to UNDERSTAND the computer before you can instruct it.
Cocoa-Java Bridge (Score:2, Interesting)
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=10
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
Re:QT can be the right solution (Score:1, Interesting)
I say that all should keep away from Trolltech QT whilst these problems continue (write once yes, get the lowest common denominator on all platforms) until they either do a GUi abstraction layer to native widgets on platforms or give a better experience than Cocoa development. For chrissakes, they even wrote it in Carbon, but wrong, so that compiles broke on 10.2....
Re:my experience (Score:3, Interesting)
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.
Re:You also have Carbon (Score:2, Interesting)
GUI framework for OS X (Score:2, Interesting)
If time was money we should all sit around waiting to get rich.
Check out wxWindows (Score:1, Interesting)
It's a cross-platform GUI (or all-around) C++ library that works on Windows, Linux (and then implements either Gtk+ or Motif), Mac OS X and I think a few others.
It's easy to learn although it may feel a bit weird at first.
However, if you're not interested in (true) cross-platform functionality, then you might as well go with Carbon/Cocoa in C++/Obj-C/Java.
I've been able to compile all my code on all three platforms without any significant problems (and all of those problems have been to my lack of knowledge), always using GCC (which ships with Mac OS X and Linux, and is available with the MingW and Cygwin packages on Windows).
Hope you like it. I sure do.