Objective-c (a brief introduction)

Source: Internet
Author: User

OBJECTIVE-C Introduction

Usually writing OBJC and less used objective C or OBJ-C, is an object-oriented programming language that expands C. It is mainly used in Mac OS X and GNUstep, which use the OpenStep standard system, and it is the basic language in NeXTSTEP and OpenStep. Objective-c can be written and compiled on GCC and clang operating systems because GCC and clang contain objective-c compilers. At the beginning of the 1980, Brad Cox invented objective-c at his company StepStone. He is very concerned about the real availability of software design and programming. Objective-c's most important description was his 1986 object oriented Programming:an evolutionary approach, which he published. Addison Wesley. ISBN 0-201-54834-8.

language Use editing
objective-c Use: Write an iOS operating system (such as iphone, IPod touch, IPad and other Apple mobile device) applications and Mac OS X operating system applications. Objective-c's popularity was attributed to the success of the iphone because Objective-c was used to write iphone applications. language feature editor Basic FeaturesObjective-c is a very practical language. It is a very small run-time library written in C, which only makes the size of the application small, and most OO systems use great VM execution times instead of the entire system. The program written by Objective-c is usually not much larger than its original code. and its function library (usually not attached to the software release) also and Smalltalk system to use great memory to open a window in the case of the opposite. Therefore, objective-c it is fully compatible with the standard C language (c + + is compatible only with the majority of the syntax, and on the ABI (Application Binary Interface), it is also necessary to use the extern "C" as an explicit declaration to be compatible with the C function) , and the features of object-oriented programming language and the Smalltalk message mechanism are added on this basis. [1] The initial version of OBJECTIVE-C does not support garbage collection. At the time, this was one of the main points of contention, and many people considered that the Smalltalk recovery had a long time to die, leaving the system useless. Objective-c does not have this feature to avoid this problem. Although some third-party versions have joined this feature (especially GNUstep), Apple has not introduced this feature in its Mac OS X 10.3. Although Objective-c is a superset of C, it does not consider the basic type of C as the first-level object. similarities and differences between OBJECTIVE-C and C + +:Unlike C + +, OBJECTIVE-C does not support operator overloading (it does not support Ad-hoc multiple types). is also different from C + +, but as with Java, objective-c only allows objects to inherit one category (without multiple inheritance). Categories and protocols not only provide many benefits of multiple inheritance, but also do not have many drawbacks, such as excessive execution time and binary incompatibility. Objective-c and C + + single inheritance: OBJECTIVE-C does not support multiple inheritance (same as Java and Smalltalk), while the C + + language supports multiple inheritance. Dynamic: Objective-c is dynamic training (Dynamicaly typed) so its class cubby C + + is easy to manipulate. Objective-c can allow access to methods and classes based on string names at run time, and can also dynamically connect and add classes. C + + follows the Simula 67 (an early OO language) school in object-oriented programming, while Objecive-c belongs to the Smalltalk school. In C + +, the static type of an object determines whether you can send a message to it, and for objective-c, it is determined by the dynamic type. The Simula 67 School is more secure because most errors can be detected at compile time. And the Smalltalk school is more flexible, such as some smalltalk seemingly unmistakable procedures to get Simualr67 there can not pass. In many ways, the difference between C + + and objective-c is more about thinking than technically. Do you want to be more secure and abandon flexibility? Supporters of the Simular67 school say that since the program is well-designed, there is no need for flexibility, while the Smalltalk school is called flexibility to tolerate multiple errors in runtime.Pros and consApplein itsMac OS Xgarbage collection is still not introduced in 10.3. However, it is gratifying to say that in Apple's release, XCODE4 has already supported automatic release, and I dare not presume that it is garbage collection, because the mechanism is different, the automatic release in Xcode4, that isARC(Automatic Reference counting) mechanism, is no need for users to manually goReleasean object, but during compilation,Compilerwill automatically help you add the [NSObject release] that you used to write. Another problem is that OBJC does not include the namespace mechanism (namespace mechanism). Instead, programmers must prefix their category names and often cause conflicts. In the 2004, in the Cocoa programming environment, all Mac OS X categories and functions have "ns" as prefixes, such as nsobject or Nsbutton, to make it clear that they belong to Mac OS X core, and that "NS" is due to the names of these categories when NeXTSTEP development. Although Objective-c is a parent set of C, it does not consider the basic type of C as the first-level object. Unlike C + +, OBJECTIVE-C does not support operator multi-load (it does not support Ad-hoc multi-type). is also different from C + +, but as with Java, objective-c only allows objects to inherit one category (without multiple inheritance). Because OBJ-C uses dynamic run-time types, and all methods are function calls (and sometimes even system calls (Syscalls), many common compile-time performance optimization methods cannot be applied to obj-c (for example: inline functions, constant propagation, interactive optimizations, scalar substitution and aggregation, and so on). This makes obj-c performance inferior to similar object abstract languages (such as C + +). But obj-c advocates believe that since the obj-c run is expensive, obj-c should not have been applied to the underlying abstractions common to C + + or java.

Objective-c (a brief introduction)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.