Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "Modern Objective-C" really a new version, i.e. Objective-C 2.1?

In WWDC 2012 Apple introduced new syntax for NSNumber literals and Collection literals, in talk 405 named "Modern Objective-C". I have learned Objective-C from the book on Objective-C 2.0 by Stephen G. Kochan.

Is "Modern Objective-C" going to be Objective-C 2.1, or should the new syntax of Apple be considered as an alternative, Apple-specific syntax (shorthand) for existing constructs that are processed by the compiler?

(I did some research online, but found the terms "modern" and "legacy" only in the context of the Objective-C RunTime. I would like to understand what exactly is in the language, what are preprocessor instructions, and what are compiler directives.)

like image 621
Jan Kroon Avatar asked Sep 27 '12 08:09

Jan Kroon


1 Answers

Objective-C is defined as an extension of C. Preprocessor instructions and compiler directives are exactly what they are for C.

There is no "formal" definition of the Objective-C language (no standard). Apple publishes a document that, more or less, explains it. There's also no real "version number" of the language. Apple sometimes adds a new feature and that's it. At a certain point Apple decided to promote a certain set of features as "Objective-C 2.0", but this does not mean that all previous versions had the same feature set nor it means that all subsequent versions will have the same feature set. The most recent moniker Apple has been using is "modern Objective-C" and refers to a language that supports all the currently defined features.

Note that some features are defined at the compiler level, others are defined at the library level, and others are a mix of both. If you use a feature that is completely implemented at the compiler level (like the new literals syntax), it will work for any program you write and compile with that compiler. But if you use a feature that is defined at the library level or that requires both compiler and library support, it will only work for programs that run on systems where a recent library is available (Apple does not let you statically link the language libraries). Examples are things like GC, ARC and the zeroing semantics attached to weak.

Therefore: yes, "modern Objective-C" is different enough from earlier Objective-C that you should consider it a new version, however no, there's no version number attached to it and it's perfectly possible that Apple will add new features to the language and still call it "modern Objective-C". Besides exactly what features are part of the language not only depends on the compiler but also on the target system you are compiling for. Therefore a "modern Objective-C" program targeting iOS 4 will be able to use a different set of features than a "modern Objective-C" program targeting OsX 10.8.

like image 144
Analog File Avatar answered Sep 30 '22 13:09

Analog File