Some basic features of objective-c language

Source: Internet
Author: User

OC and C + +, Java and other object-oriented languages have a lot of similarities, but in many ways is also different. If you use an object-oriented language, it is easy to understand the paradigms and templates used by the OC language. But the use of grammar may seem strange. Because the OC language uses "Messaging Structure (message structure)" rather than "function calling". The basic format for message and function calls is as follows (in the case of the Student Class):

Messaging (OC)

Student *stu=[student New];

[Stu Setname:name1 and Setage:age1];

Function Calling (C + +)

Student *stu= New Student;

Stu->set (NAME1,AGE1);

The key difference is that the language in which the message structure is used is determined by the running environment, while the language used by the function call is determined by the compiler. If the function called in the sample code is polymorphic, then at runtime it is necessary to find out which function implementation should be performed by using virtual table (virtual table). The language in which the message structure is used, regardless of polymorphism, is always run to find the method to be executed. In fact, the compiler doesn't even care what type of object the message is being accepted for. An object problem that receives a message is also handled at run time, and its process is called dynamic binding.

The important work of OC language is done by "Runtime component (runtime component)" rather than the compiler. All data structures and functions required for object-oriented use of OC are in the run-time component. For example, the run-time component contains all the memory management methods. A run-time component is essentially a "dynamic library" that is linked to a developer's code, which can glue all the programs that developers write. In this way, you can improve application performance by updating the run-time components only. While many of the languages that work at compile time are compiled, you will need to recompile the application code if you want to achieve a similar performance boost.

OC is the superset of C, so all functions of C are still applicable when writing OC code. Therefore, the core concepts of both C and OC must be mastered in order to write efficient OC code. It is important to understand the memory model of C, which helps to understand how the OC's memory model and its "reference counting (reference count)" mechanism work. To understand the memory model, you need to understand that the pointer in the OC language is used to indicate the object.

Some basic features of objective-c language

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.