Objective-c for Java programmer Part 1Java is mostly inspired by Objective-C, but many people find it difficult to learn Objective-C after learning Java. In the first two-part ChisnallCocoa programming development manual,
Author DavidThis paper analyzes and studies the semantic similarity and differences between the two languages.
Objective-C was created in 1986, but it is a very efficient language. The impact of the NeXT company, which has only 50000 computers in total in the past decade, has greatly restricted the development of language. When Apple bought NeXT, this situation began to improve. Objective-C has developed into a major language on Mac, and occupies about 5-10% of the market share of desktop application development. No OS in Objective-C
Although only supported development languages on X, they are familiar with things used by many developers. In contrast, iPhone does not support any third-party development except Objective-C.
If you are from a Java background platform, you may find that the change is arduous. Objective-C looks very different from Java. Fortunately, once you pass the syntax, the language is very similar and you will find that the transition is not difficult.
Some Java designers have to use Objective-C experience, including some previous OPENSTEP specifications "next step. Many ideas in Java's Objective-C are directly canceled, or taken from Smalltalk, which inspires two languages. This does not mean that everything is the same in Objective-C. There are some important differences, which I will discuss in the next article.
Language Philosophy
The Design of Objective-C brings the C language encapsulation support in Smalltalk. One of its designers, as a mixed language, describes it as an indicator of the transition from C code to the square brackets syntax, object land. "
Java aims to make the average programmer a language available. This combination of Smalltalk-like semantics and C ++ syntax. The latter determines more reasons for marketing than technology. C ++ has a large market share (which still exists for some strange reasons). It enables developers to switch to a language and it is easier to look at different similarities.
Unfortunately, this is why some people exchange major issues or develop from Java. Java looks like C ++, but there are many Objective-C behaviors. Java and Objective-C have semantics like Smalltalk, while C ++ adds semantics similar to Simula C. java and C + involve switching between the semantics of Smalltalk and Simula, without any corresponding changes in the syntax.
The ongoing C ++ and Objective-C between them are easy to change in syntax, with semantic changes. Between Objective-C and Java is a bit confusing. There is a major change in syntax, but only in small semantic changes.
In a few places, the difference in goals is obvious. The goal of Java is to become something vaguely similar to C and easy to learn for C or C ++ programmers, but it is not ideal to do things in C mode if you don't mind breaking things. Objective-C is a super set of pure C. Every valid C program is a valid Objective-C program. One of the main design goals of Objective-C is to build reusable components in a language that easily parceling the C library.
Objective-C did not initially come up with a standard library. You are expected to use the C library. Currently, as a standard Objective-C library, the OPENSTEP specification is commonly used and executed by Sun and NeXT, such as Coco or GNUstep on most platforms. Java does not have the ability to easily reuse existing code, so it needs a comprehensive standard library from the very beginning.