Objective-C: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
Nessun oggetto della modifica
Riga 575:
Besides the [[GNU Compiler Collection|GCC]]/[[NeXT]]/[[Apple Computer]] implementation, which added several extensions to the original [[Stepstone]] implementation, there exists another free open-source Objective-C implementation, which implements a slightly different set of extensions: The Portable Object Compiler [http://users.pandora.be/stes/compiler.html] implements, among other things, also [[Smalltalk]]-like blocks for Objective-C.
 
== AnalysisAnalisi ofdel the languagelinguaggio ==
L'implementazione dell'Objective C usa un semplice [[runtime system]] scritto in C che aumenta di poco la dimensione delle applicazioni. Al contrario, la maggior parte dei sistemi object-oriented esistenti quando fu creato (e [[Java (linguaggio)|Java]] tuttora) usava una grossa [[macchina virtuale]] invasiva per l'intero sistema. I programmi scritti in Objective C tendono a non essere troppo più grandi delle dimensioni del loro [[codice oggetto]] e delle librerie (che generalmente non devono essere incluse nel codice distribuito), al contrario ad esempio dei sistemi [[Smalltalk]] dove grandi quantità di memoria sono necessarie semplicemente per aprire una [[finestra]].
Objective-C implementations use a thin [[runtime]] written in C which adds little to the size of the application. In contrast, most OO systems at the time that it was created (and Java even today) used large [[virtual machine|VM]] runtimes which took over the entire system. Programs written in Objective-C tend to be not much larger than the size of their code and that of the libraries (which generally do not need to be included in the [[software distribution]]), in contrast to Smalltalk systems where a large amount of memory was used just to open a window.
 
Likewise, the language can be implemented on top of existing C compilers (in [[GNU Compiler Collection|GCC]], first as a preprocessor, then as a module) rather than as a new compiler. This allows Objective-C to leverage the huge existing collection of C code, libraries, tools, and mindshare. Existing C libraries — even in object code libraries — can be wrapped in Objective-C [[Adapter pattern|wrappers]] to provide an OO-style interface.<br>
Riga 589:
Unlike [[C++]], Objective-C does not support [[operator overloading]]. Also unlike C++, Objective-C allows an object only to directly inherit from one class (forbidding [[multiple inheritance]]). As Java was influenced by the design of Objective-C, the decision to use single inheritance was carried into Java. Categories and protocols may be used as alternative functionality to multiple inheritance; Java however lacks categories.
 
=== PhilosophicalDifferenze differencesfilosofiche betweentra Objective- C ande C++ ===
TheIl designprogetto ande implementationl'implementazione ofdel [[C++]] ande dell'Objective- C representrappresentano differentdue approachesdiversi toapprocci extendingall'estensio del [[linguaccio C]].
 
Oltre alla [[programmazione strutturata]] del C, C++ supporta direttamente la [[programmazione ad oggetti]], la programmazione generica e la [[metaprogrammazione]]. C++ è inoltre corredato di una estesa [[libreria (informatica)|libreria]] standard che include numerose [[ogetto container (informatica)|classi container]]. L'Objective C, invece, aggiunge solo delle caratteristiche [[object-oriented]] al C; esso, nella sua versione più "pura" non offre lo stesso numero di in termini di librerie standard, ma in molti contesti dove viene usato, viene corredato di una libreria sul modello di quella di [[OpenStep]], di [[Cocoa]] o di [[GNUstep]] le quali forniscono funzionalità sinili a quelle offerte dalla libreria standard di C++.
In addition to C’s style of procedural programming, C++ directly supports [[object-oriented programming]], [[generic programming]], and [[metaprogramming]]. C++ also comes with a large standard library which includes several [[Container (data structure)|container classes]]. Objective-C, on the other hand, adds only object-oriented features to C. Objective-C in its purest fashion does not contain the same number of standard library features, but in most places where Objective-C is used, it is used with an [[OpenStep]]-like library such as [[OPENSTEP]], [[Cocoa (API)|Cocoa]], or [[GNUstep]] which provide similar functionality to some of C++’s standard library.
 
One notable difference is that Objective-C provides runtime support for some [[reflection (computer science)|reflective]] features, whereas C++ adds only a small amount of runtime support to C. In Objective-C, an object can be queried about its own properties, for example whether it will respond to a certain message. In C++ this is not possible without the use of external libraries; however, it is possible to query whether two objects are of the same type (including built-in types) and whether an object is an instance of a given class (or [[superclass (computer science)|superclass]]).