Freitag, 25. Mai 2012 |
| |
A few reasons exist as to why SWT on Mac is built on Carbon instead of Cocoa. Cocoa it seems looks like a SWT peer and it would be difficult to port SWT to it, because of event loop issues and other random problems that arise during porting. Cocoa is easier to work with on Mac, but it does try to do things in different ways than Carbon. Even though Cocoa applications have good features, it would take quite an effort to convert them to carbon, as the widget hierarchy is completely different and wouldn't necessarily fit in with how SWT works. Secondly, most UI development under Cocoa is done under Interface Builder rather than programmatically. Carbon could have had a better .app launcher under Mac OS X, as it launches a separate VM, but this is more of an eclipse-imposed restriction.
The Carbon environment runs all Mac OS 8 and OS 9 applications whose code has been optimized for Mac OS X. The Carbon environment features a set of programming interfaces derived from earlier versions of the Mac OS. By converting their code to use the Carbon application programming interfaces (APIs), developers ensure that their products take advantage of protected memory and preemptive multitasking. The Carbon APIs have been modified to work with the foundation of the operating system, the kernel environment. Carbon carries forward most of the existing Mac OS managers and APIs.
Carbon keeps about 70 percent of the total functions and 95 percent of the functions used by typical applications. It also includes additional APIs and services specifically developed for Mac OS X. While Carbon is the means by which most Mac developers will get their apps up to speed for Mac OS X, it is recommended to use Cocoa for creating application for the future, as the Cocoa environment provides an advanced, object-oriented programming environment.
Cocoa is a set of frameworks with programming interfaces in both Java and Objective-C.The thing about Cocoa is that developers can use it to write code in terms of objects that let them reuse their code for future work. Functions published in the operating system can be accessed as a "service" by other Cocoa applications. For instance, a grammar checker in a word processing application could be offered as a "service" and used by other programs However a bug (https://bugs.eclipse.org/bugs/show_bug.cgi?id=67384)with the SWT on the mac prevents developers from creating RCP apps that needs embedding of AWT/Swing components.