Which Coding Framework for Mac OS X ?
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.
Carbon is a good API to begin with. You can use C++ or C and access all the nice GUI of OS X.
.NET == Cocoa
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;
I'd go with Cocoa. The more native, the better.
There they were, sitting in the van with all those dials, and the cat was dead. -V. Marchetti, CIA
While Apple wants you to use Cocoa, they're provided a more typical C/C++ API called Carbon. I suggest you use that- everybody else does. :)
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.
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.
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.
Do not use Carbon. The Carbon API has to go through a compatability layer, so any program written in Carbon will always be slower and less capable than its Cocoa version. Also, the Cocoa API is actually very easy to use once you learn the very simple connect protocols. Go to www.macdevcenter.com and goto the cocoa column for some great examples.
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.
Uninnovate - Only the finest in engineering.
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.
Moneyed corporations, non-working 'poor' and criminal prisoners are turning productive citizens into tax-slaves.
Forgive my inexperience with OSX programming, but some of the features you seem to be interested in are not OSX specific.
Easy IPC can be accomplished numerous ways using vanilla Java (RMI, conventional Thread communication), and you can go with CORBA for language-neutral IPC. And I think Java Threads are as good or better than BSD processes.
The UI decision is less important than the underlying program architecture and language/framework choice. Swing is the most obvious choice, but there are others.
I wish I hadn't posted to this topic so I could use my remaining mod points to mod this down. Could someone do it for me, please?
There they were, sitting in the van with all those dials, and the cat was dead. -V. Marchetti, CIA
Let me put my own spin on this question for the
Several advantages:
- Easy cross platform. Your app will run on any platform Mozilla/Netscape run on.
- Easy development. Subjectively, development goes a lot faster than under a traditional framework.
- 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.02Patrick
"He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
I have been programming for Macs for the past 7 years..
;)
First of all, Java. Java unfortunately is still too slow in its execution time. Yes there have been improvements, but they're not up to par yet.
Cocoa is alright, except that it uses Objective C. Objective C is a bastard child of C and C++, and it doesn't really mesh too well.
Which leaves Carbon. Nice, clean C++. Speedy execution too. Go for Carbon.
Now Nextstep, that's a whole different ballgame.
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).
"How to Do Nothing," kids activities, back in print!
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 am not sure of your position, (because the developer license costs money for Mac OSX) but QT has the advantage of porting to about every platform there is.
Guess what? I got a fever! And the only prescription.. is more cowbell!
Ouch! One big problem with "going native"
is that you tie your design and implementation
to the vendor's world view du jour. Don't
fall for this. Keep portability in mind;
you may have to implement it "native" to
actually get in running and take advantage
of some features. Keep it so that you can
port it any environment or support other components.
But if you have a complex GUI, do take a look at QT/Mac from trolltech. It isn't FREE but it is quite good and allows your program to be portable between Mac/Linux/Windows.
--jeff++
ipv6 is my vpn
Definitely, learn 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, you can completely abstract your UI from the core of your code.
Since you say you want to use the BSD layer, I suggest making a command-line 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 native IPC libraries in Mach. If you don't mind your code 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?
I prayed about it, and God said, "Don't do it!" But I thought, "I know better."
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:
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
KdenLive/PIAVE - non-linear video editing
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.
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).
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 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
Yeah, after all, there's no reason to write good software when you can just write portable software.
Least-common-denominator approaches are good for nothing-- except grade-school arithmetic exercises.
I write in my journal
If you want to make non-trivial use of sockets then there are plenty of things you can't do in Java anyway. Even if you find that Java can do what you want to with sockets you may find that it's not portable (particularly if you are combining sockets and threads).
I agree with most of those who have said that Objective C is easy enough to pick up in an afternoon. And in my experience, Objective C is preferable to Java for Cocoa development. And in my experence Cocoa is preferable to Carbon, not only because the Carbon featureset is a subset of the Cocoa featureset, not only because Cocoa is the native framework for OS X, but also because you can leverage the excellent development tools provided by Apple (especially Project Builder and Interface Builder). A dedicated programmer can learn how to use PB and IB and Objective C in a day or two, and proficiency in those tools will speed up your actual coding work more than enough to merit the time spent learning them.
Documentation for the development environment, as well as Carbon and Cocoa API tutorials and reference, can be found on Apple's Developer site.
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.
If you use Project Builder to build Mach-O Carbon apps (rather than CodeWarrior and CFM), you can use all the C-based Unix API's. This myth that only Cocoa's api's work on top of the BSD layer is so incredibly false.
Also, remember that CoreFoundation gives you some of Cocoa's advantages (reference counted data structures, for example) in Carbon. Not knocking Cocoa, but having Carbon as well gives you a lot of choices.
You wrote:
:stares in disbelief:
um actually, stuff that is Free under the MacOS/MacOS X costs money on Windows for the same thing from another developer.
I use Windows at work and getting the same function as provided by a freeware Mac app costs money on Windows.
Mind you there are always exceptions to the rule.
My theory is that all Windows developers code fro money while some developers on other platforms code to give something back or just for the love of the platform (be it Linux, BSD, Mac, or something else).
Once you've mastered C-- which takes about two days
Oh yeah it's a piece of cake. What a lamer !
Just another one of those fresh new wannabe programmers. If you think you can master C in a couple of days, you probably didn't understand much about computer science to start with.
Comment removed based on user account deletion
Check out the article Introduction To and Experiences With Mac Cocoa from Kuro5hin.
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.
Will I retire or break 10K?
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. 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. =)
If it isn't true, explain to me why what are free utilities for Windows machines are $20-$30 extortionware for the Mac.
Which utilities that don't already have equivalents in Fink (i.e. d*b**n gnu/mac os x) are you talking about?
Will I retire or break 10K?
write your basic classes in java and
use jython to set up the application.
Have you had a look at SWT ? Eclipse is written in it and it is really fast !
Why not just use AppleScript? :)
-CowboyNick
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.
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++.
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 am the Alpha and the Omega-3
Who's to say that you can't write good software in Java?
Good software design is NOT about the language you use, its about how you use it. (something I'm sure you've heard before)
Saying that all Java code is poor is like saying that all books written in russian are poor.
this post just makes me angry
...I'd also suggest taking a look at wxWindows. 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!)
You say
Forgive me but I must say it! I hate the word "coding".
I think it's an unsophisticated word.
It's like using the word "boink" to describe sex, it doesn't work if you're having a serious discussion.
// -- http://www.BRAD-X.com/ --
Uhhh... dude
Hell
Dude yourself !
Plus, do people in here have to say "Hell" all the time ? Just speak normally, be yourself.
You seem to be so above things. It's easy to have an attitude, it's another matter to actually know how to code.
Knowing the rules of Chess doesn't make you a champion, or even a player worth its name.
If you follow a sane strategy, and don't use Objective C OR Carbon C++ (and its associated event and I/O management cruft) to handle your application logic, I don't see what the advantage to Carbon is.
That is to say, if all your application logic is straight C++, and you're only doing UI and event integration in "Native" MacOS, why would you choose to use Carbon (which seems approximately as complex as Win32) instead of Cocoa?
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.
Who's to say that you can't write good software in Java?
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.
I write in my journal
In order to fully utilize all the features of the Mac UI, you MUST use Cocoa with Objective-C.
Both Java/Swing and C/Carbon are subsets of what's available with ObjC/Cocoa.
I recommend you write the core functionality of your app in good 'ole crossplatform C++ and integrate it with a Cocoa/ObjC UI. Google for "Objective-C++" for documentation on how to bridge the two runtime environs.
You *could* write your entire app in Objetive-C, if you really dig late-binding and aren't a big fan of crossplatform compatibility.
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 like Cocoa, and the best Kit I have foudn that will let me Develop Cocoa and still write Classic Mac Apps is Code Warrior it handles it all very nice. Also if you wanna learn how to program or anything sign up over at Apple Developer Connection http://developer.apple.com/ It is free to sign up for it, and if you are a student you can sign up for The Student Subscription for 99 bucks. but thats how I would do it.
---
If Moz is half as powerfull as IE it shouldn't be a problem, I've done some pretty amazing client side app development with IE and so has MS - actually i did it for MS, but thats another story.
The only issue i can see is if one wants to get out of the sandbox that is the browser, in those cases we used ActiveX objects, i dont know how possible something like that would be in Moz, at least with any portablity.
-Jon
this is my sig.
The IO was completely redone for 1.4. Maybe that cures your concerns. Now includes non-blocking io, which may be related to your threading issues.
You may be right about portability wrt some situations involving threads and sockets. I haven't run into this myself and would be interested in some examples.
All in all, I think one's chances of getting a portable app using Java are better than with any other language.
There's a better sockets wrapper at http://fozztexx.com/FZBase/. It's multi-threaded which allows your program to receive data while it's interacting with the GUI, and also doesn't require you to mutilate your stock system just to compile it.
Not only is Qt portable across 3 major platforms (MacOS, Linux/Unix, Windows), but its api really rocks.
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.
Assembly. Show us what you've got.
Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
If I read him correctly, he wants to be able to pipes, semaphores, or shmsegs, not any of the Java-specific IPCs. However, if he's amenable to other options, I've got to throw Cocoa's Portable Distributed Objects (PDO) out there; it is, bar none, the easiest IPC framework ever developed. Writing an IPC-enabled or network-enabled Cocoa application is quite literally only a few lines different than a standalone app.
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++
Don't bother with these people that have used one and not the other. The fact of the matter is that oyu can actually do alot more in Cocoa, and its alot faster than Java apps, plus it also has many interfaces adn methods that carbon still doesn't have yet. Cocoa has free support for all of the Mac OS X services that are offred by other apps.
As for the learning curve, its no more than hour at most, its like C/C++ cept with different syntax when working with classes and objects.
There are many more reasons, a stroll through the Apple develope pages will shouw you what I mean.
http://sourceforge.net/mailarchive/forum.php?threa d_id=1173890&forum_id=4355
You can now build pure Cocoa apps in Python...
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.
Most of the toolkits support multiple languages.
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.
-- Tim Buchheim
an OS with a spell checker, idiot! then again, this way we can tell you are an idiot without having to waste too much brain time.
So, C is easy conceptually, but hard to use because it is brain dead. People who like C either like to tinker or believe they're going to live forever.
Cocoa is also relatively portable via GNUstep--an open source implementation of the Openstep API from which Cocoa was derived. GNUstep is a little bit rough around the edges, but apparently very usable at this point. See google for various links.
There is already a port of wxWindows to the Mac, and quite sure to OSX soon enough.
Also, don't forget Qt Designer. It's one of the most capable interface designers I've ever had the pleasure to use.
.ui file (XML) containing a description of the class you've created. You edit code within designer (A major improvement) and then the user interface compiler (uic) and Meta-Object Compiler (moc) get their punches in and create source code/headers from the interface. Then your code can just use it like any other class.
For those who don't know, It outputs a
Better yet, qmake handles all the dirty makefile generation from a project file format that one can learn in about four minutes (and that designer generates).
I wrote a fulle graphical and very functional remote services debugger in about eight hours total using designer (I had used Qt, but not designer before)
Best of all it's free and cross platform.
BTW, Access to files/sockets/threads and a host of other things (including GL) are included so you can do all of this cross-platform with just a source recompile.
Good stuff...
Brian
It's the set of libraries that will really take time to learn. Seriously. An int is an int in Java, C, and Obj-C. But how do you structure your application? What call do you make to turn your window blue? And what's the right way to get text to show up in the typeface you prefer (or better yet, in the typeface the user prefers?)
Answering any of these questions depends on the API you choose to use. If you know Swing already then you'll get bits on the screen a lot faster than if you decide to learn Obj-C and all the Cocoa Frameworks. On the other hand, if you're starting from scratch on all of them and you don't have any portability concerns then go for Cocoa -- you'll get going quickly and you'll love the result.
Most C prorammers that I have met never exploit the full power of the base language (or even know that you can do things like pointers to functions) much less the standard library. And don't even get me started on the standard library. Every major C project that I've worked on has had a 'system("rm somefile");' somewhere in the code because some dipshit couldn't be bothered to look up unlink. And these are experienced, "professional" programmers.
And they still haven't figured out everything you can do with C++ yet, despite the fact that it only adds "a few more keywords." I've seen a turing machine and a set of LISP keywords implemented completely in templates.
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.
-- The world is watching America, and America is watching TV.
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.
Use CodeWarrior's PowerPlant. It's a full C++ framework that will let you code to Naitive OS X. CodeWarrior is put out by Metrowerks so see the link for more details.
-- DuckWing
Of course, MS will claim that C++ did get better with C#...
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 (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, 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. 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.
I tried all these different approaches, and I ended up doing most of my Mac programming in Java/Swing and wxWindows.
The link didn't work right. so here it is again. Metrowerks
-- DuckWing
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.
Hypercard!
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.
Yeah, and you guys panned the ipod too: http://apple.slashdot.org/article.pl?sid=01/10/23
You've obviously never used Interface Builder then.... :)
.nib file (NeXT Interface Builder) which contains a "freeze-dried" set of GUI objects linking targets and actions (the equivalent in QT would be slots and signals) to a set of proxy objects, typically controller and delegate classes in your code. IB can also generate the headers for those controllers and delegates.
A highly capable GUI editor for Carbon & Cocoa applications, it outputs a
'Sounds like Designer', I hear you say. WRONG! QT needs to recompile if you change the interface as you have to resave from designer and then use MOC to regenerate classes and so on. The IB NIB is a binary file containing working objects - in fact you can test a working GUI from within IB including working targets and actions such as a text field getting values from a slider without a compile. With this decoupling you can change the GUI of an interface, including targets and actions, without needing a recompile OR EVEN THE SOURCE CODE. People have found hidden code in Apple apps just by loading the NIB files from applications such as iPhoto, adding buttons and reconnecting actions.
It's incredible powerful, leading to dynamic coupling of GUIs, easy i18n support through automatic language NIB loads and very rapid application development.
I've used QTDesigner and IB and there really is absolutely no comparison. One feels like a piece of shareware compared to the other, and I think you can guess that I don't think IB is the cheapseats.
Why in the hell am I getting modded down for this? I was only trying to point out that there is a really nice option for those who have some money to pay for the developer license of QT for mac. I use QT as my main development for linux and have been very pleased -- good grief moderaters, READ THE COMMENT.
Guess what? I got a fever! And the only prescription.. is more cowbell!
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.
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.
"He who would learn astronomy, and other recondite arts, let him go elsewhere. " -- John Calvin, commenting on Genesis 1
Microsoft only has %40 market share. Linux has %10, and the various Mac OS versions have the remaining %50.
Get your facts straight!
PS- for the impaired, my point is to point out that the %95 number is just as fabricated as the numbers I gave.
Yeah, and you guys panned the ipod too: http://apple.slashdot.org/article.pl?sid=01/10/23
>[Qt is fully GPL] Only when compiling for the X11 target
Not if you purchase a license! Qt is well worth the money!
Only if you're in a for-profit business. Qt/Mac will expire after 30 days. Most hobbyist developers (such as myself) don't have upwards of $1500 for a widget set. And according to this FAQ entry, Trolltech releases Qt Free Edition only for operating systems that are free software. Thus, Trolltech will not release Qt for Windows until ReactOS is complete, nor Qt for Mac as free software until GNUstep is complete.
Will I retire or break 10K?
dream on fella....
I think you represent the average linux user.
Yeah, and you guys panned the ipod too: http://apple.slashdot.org/article.pl?sid=01/10/23
Objective C takes about 10 minutes to learn. Maybe a day to become fluent. Not wanting to use Cocoa because of Objective C is silly.
People who say "sheeple" have about as much sophistication as an AOL user, and in fact are probably actually AOL users.
Just give it one day. If you know Java, C++ or maybe Smalltalk, Obj-C is _not_ hard at all. Sure, it will look weird for maybe two hours, but after that... believe me, it feels like riding a bike.
Now, ocoa frameworks are rather large, but not at all difficult if you already know the Java framework or any other advanced OOP framework.
Cocoa and the tools are very nice to code in, and learning it is really fun. And, coding in Cocoa is almost as fast as Apple claims it to be. Easily 2-5 times faster than any language / RAD-tool I ever worked with.
Go for it! It is eeeeeasy!
All crucial userland APIs on OSX are written with at least a plain C API. They might be C++ inside (CoreFoundation, CodeAudio, MIDIServices) but they still are presenting C APIs to the OS.
The IOKit is embedded C++ (no multiple inheritance etc). The BSD stuff is plain C of course.
Carbon is a set of plain C APIs. Lots of stuff inside is C++, but well, the APIs published as C.
Now there is cocoa. Objective-C + Cocoa is a semi interpreted language. Calling Cocoa "Native" is like calling Java bytecode "native". Cocoa is not JUST Objective C. Objective-C describes the syntax changes and grammar relative to old pre iso99 C, Cocoa is a runtime it sits on plus a class library. Runtime that is MUCH larger than a C++ runtime, it has to analyze and runtime-link lots of stuff to get working.
So, yeah, writing apps in Cocoa is easier (if you don't want to stray) however the result is also quite slower than the same equivalent statically linked C/C++
Cocoa is strikingly similar to Qt -the messaging system is a large strength in both-. We also know that "lets send messages all around" approach leads extremely quickly to unmaintainable code, in both Qt, and Cocoa.
It's got full documentation on developer.apple.com, just as Cocoa does. They're even the same documentation - but you can choose to view either rhe Cocoa version of a class, or the Java version. For the most part, the classes have the same names, the same functions, but you just use either the Java or Cocoa documentation. The only real reason to use Cocoa-Java over Cocoa, in my opinion, is the fact that if you've already got Java classes you'd like to integrate - like, say, the Helma XML-RPC classes, which beat the arse off Apple's XML-RPC [which tends to miscode things] - then it's easy to import those and use them.
Then again, it's your call - it depends on what you already know, and what you'd like to learn.
Prepare to be burninated!
Would actually get me to buy an Apple, but it will never happen.
Unless you're planning for compatibility with MacOS 9, Objective-C and Cocoa are the language and API you should be using. The Quartz API is far more robust and does a lot of things better (e.g., rendering fonts) than Carbon does. Java Cocoa programs tend to have a huge memory footprint simply because Java comes with an enormous framework of classes that needs to be linked in.
Carbon also has the disadvantage of being a bitch to program. I think I'd rate Win32 and Classic MacOS API's (which is what Carbon is) as bing at about the same level of difficulty to program in. Objective-C isn't all that bad: it's like C with Smalltalk grafted in. Once you pick up the basic syntax, writing graphical applications using Cocoa is a breeze. The Developer Tools CD comes with everything you need, including compilers and full API documentation. Consider it a fun learning experience.
N4st0r, trixx0r h0bb1tz0rz! Th3y st0l3 0ur pr3c10uzz!
Has anyone read yet the cover story article in this month's Java Developer's Journal by Ian McFarland, president of Neo Ventures Ltd., a software consulting company in San Francisco, and author of Mastering Tomcat Development, available in September from Wiley?
The article's called "Building Installers for OS X" and McFarland writes that Java on OS X is "a first-class citizen."
A Java developer since release 1.0 alpha 2, McFarland apparently also maintains www.javaosx.com.
Proof by counterexample: I write free programs for Windows - so do a few thousand others, the last time I checked.
Ooh, that was easy! Give me another one! :-)
Tim
Has anyone read yet the cover story article in this month's Java Developer's Journal by Ian McFarland, president of Neo Ventures Ltd., a software consulting company in San Francisco, and author of Mastering Tomcat Development, available in September from Wiley?
The article's called "Building Installers for OS X" and McFarland writes that Java on OS X is "a first-class citizen."
A Java developer since release 1.0 alpha 2, McFarland apparently also maintains www.javaosx.com.
Don't write to the OS, write to the customer's requirements. If you *must* write to the OS, do what the vendor tells you, else they will cut off your oxygen when you can least afford it.
Unless it's GUI/multimedia intensive, it should be possible to pick an API that you and your customers can easily move to other OSes and other hardware.
Ask yourself, what framework and language is Apple using to create their iApps for Mac OS X?
The answer is Cocoa and Objective-C. You should too.
Get one of the books that have come out about Cocoa (hmm, they all use Objective-C as their language, wonder why?) and spend a week or two familiarizing yourself with it. You'll be building useful code in no time.
One of the best aspects of Cocoa/Obj-C is that it's perfect for wrapping chunks of plain C or even whole Unix command line programs. Apple's develolper web site has a few examples of doing this.
Carbon is a fine API - if running on Mac OS 9 is important to you or you have a large existing base of classic Mac OS code to bring to Mac OS X. Otherwise, there is no real point.
I've been a Mac programming for a dozen years and switched to Cocoa/Obj-C a year ago. I'm more productive than I've ever been before and am having more fun doing it.
Enjoy!
and also very elegant once you get used to them. Cocoa, Apple has stated, is the preferred programming API on Mac OS X. Objective-C is the best way to use it. As a former NeXTSTEP/OPENSTEP programmer and a current GNUstep contributor, my advice is to try it. :)
For more information about GNUstep, go to:
http://www.gnustep.org
The site also contains a plethora of information about Objective-C, OpenStep, and Cocoa.
Later, GJC
Gregory Casamento
## Chief Maintainer for GNUstep
That was a general rule.
Every rule has exceptions.
Mind you there are some decent free apps for windows (never said there weren't) but, there are fewer of them than on alternative platforms (free ones that are decent).
HTMLkit for example is a free Windows HTML editor.
On the Mac, there is a lot of freeware utilites and other things and the same freature set will cost money under Windows.
Basically it is a matter of numbers.
I always wondered about that, how conservatives and liberals can each see the other as "wrong-headed," and self-evidently so.
:)
Is it just a case of overgeneralization, i.e. if you understand the motivations of people like yourself, you believe they are the same for everyone else? One size fits all?
That's why I prefer to argue from facts!
What I'd really like to know is, what would be the best API for porting a large existing program to Mac OSX?
Say I have a medium-to-large C or C++ program. Currently it has a Windows GUI (using MFC or straight Win32) and an X GUI (using Gtk or Qt). Now I want to port it to OSX, taking as much advantage of existing code as possible. What API do I use?
(e.g. I am excited about all the possibilities of Cocoa, but is it really that easy if the core program is NOT OSX-only?)
It looks like Eclipse doesn't support Objective C, though it apparently supports Mac OS X now.
Are there any other good tools for developing Objective C apps on Mac OS X (other than Project Builder and CodeWarrior)?
There's no debate, the answer is Objective-C/Cocoa. It's definitely easy to learn, in three months you will be able to make great software using it.
rjrjr
I must recommend Qt. You'll get neat code, portable to Win32, X-windows, BeOS, etc. Get it from Trolltech!
whether the interface of your app is going to SUCK.
The NeXT APIs are easier to develop for in my opinion, however speaking as a user I have yet to use a Cocoa app I like. Nearly all apps I use in OS X are Carbon. This is mainly due to the schizophrenic nature of OS X which I believe will only improve if Apple makes the Aqua HI Guidelines more specific. I don't think NeXT even had guidelines, but rather (falsely) assumed the API abstraction would take are of this.
Comparing SimpleText (Carbon) with TextEdit reveals most of the differences (and most of the reasons Cocoa apps get on my nerves, like the behavior of NSLayoutManager).
You should also consider PowerPlant which I still use.
I would also add that Apple shouldn't have adopted Swing unless they could convince Sun to make the API more platform neutral. Don't use it.
>80 column hard wrapped e-mail is not a sign of intelligent
>life
So what you actually mean is, instead of saying this:
You should have said this:
as it's more accurate. And probably less contentious.
Hmmm....I think I feel another exception coming on... :)
Tim
I have to confess I don't fully understand this perceived dichotomy between Carbon and Cocoa. I've been doing Macintosh programming since system 7.x and I've recently gotten into Cocoa. There were some fears initially that I wouldn't be able to use any of the code I'd written previously, but that fear was allayed with this:
#import <Carbon/Carbon.h>
I can bring the Carbon headers right into any Cocoa project or object and then drag over old code. No biggie. (Although for the record, it's not 100% backward-compatible. You do have to tweak things a bit.)
I'm not sure that Apple ever intended Cocoa and Carbon to be rival approaches, but rather complements--that's how I'm using them. Still, this perception exists.
--Rick "If it isn't broken, take it apart and find out why."
If time was money we should all sit around waiting to get rich.
Not only is it horrible, but it is also about as slow as anything ever has been.
I suggest going with a native interface, and if you don't want to do ObjC do C++ and separate the logic and the display. Don't try too hard to get something portable, that will work against you. Concentrate on making a good piece of software and code clean and easy to understand C++. It will be much easier to port it if you have a good design.
Truth hurts, doesn't it, fanboys? If it isn't true, explain to me why what are free utilities for Windows machines are $20-$30 extortionware for the Mac.
ummm, well, that's a new one. I live daily in a mixed world of Windows, Macs, and Unix systems. Yes, you might be able to find the occasional product that is free under Windows and not free on the Mac, but honestly I would place the likelihood somewhere around the same level as pigs flying out of my arse every Saturday evening at 11pm.
I suggest you install Windows XP and place a DVD in your player. Then read the dialog telling you about companies that will sell you a suitable product to play that DVD thoughtfully provided by Microsoft. Of course, on a Mac, Apple just provided the application to play it.
The general rule is for everything to be shareware or a product on Windows. I have come across approximately zero free products that I would want to use. I daily use half a dozen products that people have written and made freely available on the Mac, or have been provided with the Mac operating system and are extra cost items under Windows. And let's not forget that the Mac OS is a lot less expensive than Windows XP despite providing more capabilities.
Cocoa OR Carbon - you don't actually need to choose. You can use both - if you have lots of old Mac code (I assume this isn't the case) then Carbon has a lot of offer. You can write new applications with it but this is a reworking of the old Macintosh Toolbox, so it isn't the most productive environment available (though Apple have made sure that everything works well in the developer environment).
:-)
Java, if you're using Java and Java Swing - you're not using the Cocoa environment at all. Programs written here are just like those written on other platforms. These programs are portable to other Java2 SE implementations. That's the point.
Cocoa, is written in Objective-C and "bridged" to Java2. (Java is actually based on the Objective-C programming model - so says Sun's Java Whitepaper, so it's quite a natural match) You can program against Cocoa in both Java2 and Objective-C.
A word on Objective-C, if you know C and you understand OO then you can learn Objective-C in an afternoon. Objective-C is C with OO - nothing more. Where C++ is C with everything including the kitchen sink and loses the essance of C (small is good) Objective-C is simple like C, and adds very little to the base language. Because Objective-C is based on ANSI C it can also be added to C++; this is known as Objective-C++. You might want to use Objective-C++ if you want to reuse existing C++ code (a good reason).
I think it's worth stating again, Objective-C is easy to learn, is available where GCC is (pretty much everywhere) and is a small programming language that is very productive. Personally I think this is worth the afternoon you'll spend learning it. The syntax of Objective-C is simple and elegant (unlike that of C++). Objective-C is not strongly typed like Java, and considers the "nil" object to be able to respond to any message (it simply returns nil). These two aspects make for much cleaner, simplier looking code. And it's real - big applications have been written with Objective-C - put simply: "It worked for them, it can work for you".
So if you're totally new the programming the Mac, I'd advise you to concentrate on Cocoa with Objective-C, learning the Cocoa framework is the big part of the effort, not Objective-C. You'll find that Objective-C makes the job (of learning those frameworks) much easier. This is the most productive development environment there is on any platform.
If you need to use Java2, feel free - either using normal Java2 technologies like Swing that'll run on other platforms that support Java2 SE. You can also use Java2 to write to the Cocoa frameworks, and this can be worthwhile if you have a reasonable amount of Java2 code you wish to use.
If you need C++ then Objective-C++ is perfect, you can use existing C++ code in your Cocoa projects. You can also mix Java2 in, in the normal way. Again useful if you want to leverage existing code.
Cocoa and Carbon can also be mixed more easily in the current release, this is especially useful when you want to make significant extentions to existing Macintosh applications using the more productive development environment of Cocoa.
Also of note is Apple's WebObjects, the current release is 100% Java2 and provides the ability to write web based applications, Java2 client applications and applets and also Cocoa/EOF applications that have significantly easier database access through EOF. (EOF uses JDBC to connect to the database so support for modern RDBMSs shouldn't present a problem).
I hope this helps
...is the best combination. With few lines of code you can create beautiful user interfaces in the snap of your finger. It is as easy as declaring one widget into the other, starting from QMainWindow.
Qt is available for Mac. You gain 100% portability to Windows and Linux. It provides very nice C++ primitives for IPC communication (QProcess).
Generally, you will not need anything else, if you touch Qt.
A nice complement to Cocoa Objective-C is F-Script, an interactive environment for easy exploration and scripting of Objective-C objects.
It's open source, graphical, easy to use and quite fun.
It really works very fast! It is like SWING, but uses OS's native GUI. Mac OSX version is just released. Also, you can use Eclipse open source IDE, which is available on all the platforms, and the best IDE that you can find around. It supports refactorings, and has a terrific plug-in structure. There are 100s of plug-ins ready to be used already. Check out : www.eclipse.org
Dear Bill, do you have a
SWT is from IBM. Try it. It is really fast GUI framework for Java, it is cross platform, and it really rocks! www.eclipse.org
Dear Bill, do you have a
Go with Carbon. Why?
-Your apps will run under OS 9.
-You can write in C. (I personally much prefer C to objective C, and there are more C compilers than objC ones if you're targetting other OSen)
-The library is very similar to Quickdraw, if you've done mac programming before you have to learn pretty much nothing
If you're starting from scratch knowing NO APIs, NO programming languages, and using ONLY OS X, then go with objective C and Cocoa. Otherwise, Carbon is just a better choice.
You might want to check out wxWindows. You can find it on http://www.wxwindows.org.
:) When I say true cross-platform functionality I mean using each OS'es native interfaces... when compiled on Windows, it's a Windows app. When compiled on Linux, it's a Gtk+ app and so forth.
;)
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.
I am a nontechnical businessman and I have a question about OS X. YOu seem to be knowleadgeable about this matter. so perhaps you can help me clarify one question. Is the source code for OS X available for licensing? Is it open source? is it published? I ask this because OS X derives from Unix and Next and must be related to Linux. I think it has a beautiful GUI and network capabilities and it would be fun (and profitable) to port OS X to other microprocessors, outside of the APPLE/Power PC niche. Apple will never do it themselves. Thanks in advance
"most" is indeed what I meant.
How about using c# and gtk see www.go-mono.com
:O)
Its in its infancy now, but it will be great
And one more reason: OmniNetworking has been set up to build with GNUstep. Write your Cocoa app in Objective C, write some makefiles for GNUstep, run your Cocoa app on Linux, BSD, HP-UX, etc. You might want to use GNUstep's IB and PB clones for development, however, since it's easier to go from GNUstep to OS X, than vice-versa.
I've used both and actually Qt supports dynamic loading of gui files too, the obvious example being the designer that loads .ui files, and allows testing of them without requiring that those .ui files be compiled into source.
The designer isn't special, other apps can do this too, just use QWidgetFactory. But for some reason this isn't very popular amongst Qt application developers, I guess they prefer to work directly with c++ classes rather than work indirectly through resource/NIB/.ui files.
Basically, having to slog through yet another API/Language can be considered a punishment, so let it fit the crime you want to commit (program to write).
Question 1: Am I going to port this application to lots of other platforms? Java's a good choice because Cocoa or Carbon are both platform specific. Other options include some other GUI toolkit, like QT, and cross-platform IDE's like RealBasic.
Question 2: Am I going to use a lot of APIs available only in [insert your language here]. For example, say you have a large transaction processing package written in Java, and that's a must-have in your application. That will probably dictate the language. Likewise, if you will need to use very Mac specific C api's Cocoa, Carbon or some toolkit like QT is a good idea.
Question 3: What kind of a programmer are you? Do you squirm every time someone talks about pointers? If so C, Objective C, and C++ are probably going to give you head-aches. Java is kinder, but other languages like RealBasic or Apple Script avoid the issue entirely.
Question 4: Are you doing this to entertain yourself? It's great to have hobbies and the best part about hobbies is that you can choose to use whatever strikes your fancy.
Question 5: How much work do you have to do? If you know Java very well, you know swing, and you're using a lot of Java API's it would be a lot more work to learn some other toolkit. Or if you have 5 years of VB experience then RealBasic might be a simple transition.
Question 6: How important is the GUI Part of the user experience? On a commercial app for non-technical users, a crisp GUI that's consistent with the platforms Human Interface standards is vital to the success of the product. In this case native toolkits like Cocoa or Carbon are your best choice. If the user is a sophisticated user that is more concerned about your application correctly doing what it's supposed to do (like amortizing loans) a slower, less native GUI might be ignored in favor of correct program behavior.
I don't think Objective C is especially difficult to learn, although it takes some investment to understand the Cocoa framework. It also takes time to learn the Carbon framework or Java Swing if you don't know it. If you're new to programming I'd suggest you take Real Basic for a spin (it's free to try out).
If you're writing an application for the mac and you don't care about other platforms then use Cocoa. Carbon is a bridge provided so that applications can be moved from Mac OS 7/8/9 to X. Anything you can do in C you can do in Cocoa, if they don't already have an objective C api for it.
If you're writing cross-platform applications I suggest you isolate your application logic in libraries with which you link. They can be in Java or C, and try to make it as independant as possible from the UI code. I haven't seen a lot of Java Applications do all that well in the market place but that may or may not be important. Generally successful, commercial apps use native UI code and platform independant library code.
Leave the gun, take the cannoli -- Clemenza, The Godfather
Very Clear. Thanks. GS
There is a way to combine the three:
Burnt Chocolate Coffee.