Do you know the full name of mac? Macintosh, The translated name is Macintosh.

The first version of Apple Computer was released in 1984, which was named Macintosh System 1 until the ninth version (version 9.0 was launched in 1999). These systems are collectively called Classic Mac OS. While Classic Mac OS initially used Pascal as the primary development language, by 1990, most of the mac software and libraries were developed using c++.

In 1985, Jobs left Apple and founded NEXT independently. He launched NeXTSTEP operating system, which is based on Mach and BSD, Based on object-c complete one The last version 3.3 was released in 1995. NEXT company later cooperated with SUN company to rename NEXTSTEP operating system as OpenStep.
In 1996, Jobs returned to Apple. two

Apple subsequently acquired NEXT and developed a new operating system Rhapsody based on OPENSTEP. In order to be compatible with the previous Classic Mac OS, the system uses a new strategy: it retains most of the OPENSTEP object libraries, migrates most of the OPENSTREP GUI apis, and is named "Yellow Box". A simulator named "Blue Box" running existing Mac OS software has been added. Run the old software in this simulator. (Because most of the past software is c++, while openstep is written based on object-c)

It can be seen that Rhapsody is a direct inheritance of openStep, but an emulator is added to be compatible with the software in the past system. That is, Rhapsody=yellow box+blue box. The yellow box is basically a reorganization of openstep code.

This change was announced at the WWDC conference in 1997. Many developers were dissatisfied. They didn't want their software to run in a "Blue Box" simulator that might not be updated. They even affectionately called the blue box "punishment box".

It is precisely this problem that Jobs announced at the WWDC conference in 1998 that Apple would release a modern version that is well compatible with the past systems.

This is the origin of the carbon library. The carbon library is written based on c. The carbon framework is also a strategy for Apple to bring Mac OSX into the market.

In order to launch carbon, Apple has modified the entire system of Rhapsody. The Rhapsody model is actually an OpenStep with an emulator. In the new system, Apple used pure c to rewrite many of the underlying code in openStep called Foundation, and named it core foundation (so core foundation is based on c and is part of the carbon framework). The code in yellowbox has gradually evolved into the cocoa framework.

In addition, carbon and cocoa share common code as much as possible. Therefore, some function mapping will be carried out between carbon and cocoa on the code in the foundation module. For example, in the foundation kit module of cocoa, you can see similar typedef CGPoint NSPoint; The data structure and api of NS are converted into CF by mapping the data structure and function of NS.

Although this has some performance impact on the project of cocoa, some functions calling cocoa also need to convert object methods to c. But according to Apple, the use of the technology of toll free bridging has reduced this impact.

Carbon was released in 2000. In 2001, Apple released the first version of Mac OSX, which means 10. Since then, almost all software has used carbon, as has Apple's official applications, such as finder.

In the new system, carbon and cocoa are peer relationships. Rhapsody evolved into macosx, while yellowbox evolved into cocoa.

The good times are not long. In 2007, Apple released Mac OS X 10.5. From this version, Apple began to transition to 64 bit applications. meanwhile, Apple announced that the 64 bit C programming environment no longer provides api compatibility related to the interface interaction of carbon. Introduction to 64-Bit Guide for Carbon Developers The home page of Apple developers of the year introduced the changes in 10.5 as follows:

Most APIs in Mac OS X v10.5 are available to both 32-bit and 64-bit applications, but some APIs commonly used by Carbon applications are not. In particular, the APIs used to implement a Carbon user interface are generally available only to 32-bit applications. If you want to create a 64-bit application for Mac OS X, you need to use Cocoa to implement its user interface.

That is, the api related to interface interaction can only be applied to 32-bit programs, otherwise you need to use cocoa to create applications.

In 2012, Apple released OS X 10.8. At this time, most of the apis of carbon have been deprecated, but they can still be used. Apple has announced that it will not update the framework content of carbon. In October 13, 2017, Apple announced that the subsequent version of Mac OS would no longer support 32-bit applications, and this decision officially took effect on Mac OS 10.15.

In the naming prefix rules, from the beginning of Mac OS X to 10.8 released in 2012, the naming prefix was changed to OS X 10.8. Until the release of 10.12 and later versions in 2016, the prefix was changed to Mac OS.


That's the end of history. Carbon has completed the mission of Mac OSX - to release a modern operating system that is compatible with old system programs. However, with the popularity of 64 bit applications, the mac no longer recommends using carbon. However, if you do not use the API related to the interface library, the carbon library can still be used in 64 bit applications.

The following is a brief introduction to the contents contained in the cocoa and carbon frameworks:
carbon #Architecture) Macintosh Toolbox , Toolbox is a library in Classic Mac OS, which is composed of many managers. It implements many advanced functions, such as drawing graphics, menu manager, memory management, and so on.

Carbon originally came from the reorganization of toolbox, so carbon is also composed of multiple managers. Most of the code added later is based on core foundation.

The core foundation includes the following modules:


cocoa )Contains

  • Foundation Kit As the legacy of openstep, its class prefix is NS, which is a general object-oriented library, providing string and value operations, containers and iterations, distributed computing, event loops (running loops), and other functions not directly bound to the graphical user interface. The owned classes are

    • 1.1 NSObject
    • one point two NSString and NSMutableString
    • one point three NSValue and NSNumber
    • one point four NSArray and NSMutableArray
    • one point five NSDictionary and NSMutableDictionary
    • one point six NSSet and NSMutableSet
    • one point seven NSData and NSMutableData
    • one point eight NSDate, NSTimeZone and NSCalendar
  • AppKit It is also the heritage of openstep. Its classes and variables are prefixed with NS, which contains code programs that can be used to create and interact with graphical user interfaces. The owned classes are:

    • NSApplication, Get the object of an application
    • NSWindow: Get the object of the window
    • NSView
    • NSResponder
    • NSDocument
    • NSController
  • core data It is part of the core foundation and is also included in the cocoa.

It can be seen that although cocoa and carbon were parallel in early times, in fact, their interface libraries related to drawing windows are not the same, and the display effects of interfaces are also different. One is from toolbox and the other is from openstep.


In a nutshell

  • Cocoa=Most object libraries in openstep -->foundation+UI library in openstep -->Appkit+core data
  • Carbon=core foundation+toolbox interface library reorganized

The foundation kit has many mappings with the core foundation function, so foundation. h also contains many header files in the core foundation module.

reference material

macOS
Classic Mac OS
cocoa )
Carbon (API) )
What is Cocoa
OpenStep

The overall architecture of the mac system is complex and has a long history. If there are any intellectual mistakes, you are welcome to point them out.

Last modification: August 31, 2020
Do you like my article?
Don't forget to praise or appreciate, let me know that you accompany me on the way of creation.