Objective-C
description
Transcript of Objective-C
Objective-CDrew ChengCS420
OverviewTrue superset of ANSI CObject-Oriented methods from SmallTalkThere is no formal written standard for the language
Relies on outside libraries
Iterative/ImperativeFlexibility, most things are done at runtime
Dynamic TypingDynamic BindingDynamic LinkingMessage Passing
HistoryCreated by Brad Cox and Tom Love at their company StepstoneBoth were introduced to SmallTalk while working at ITTCox was interested in the problems of true reusability in software design and programmingModified C compiler and created a Object-Oriented extension of C called OOPCTom Love added more to OOPC from SmallTalk creating Objective-C
1986 – Stepstone releases Objective-C1988 – Steve Jobs acquires Objective-C license for NeXTNeXT releases their own Objective-C compiler and libraries used in NeXTstep Operating System and OpenStep API1993 – GNU Objective-C runtime, currently in use, created by Kresten Thorup1996 – Apple Inc. acquires NeXT and uses OpenStep in new Mac OS XApple combines Objective-C and NeXT’s Objective-C, creates Cocoa API, most significant environment
UniquenessMessaging/Forwarding
Does not call method, sends messageTarget of message is resolved at runtimeMessage passing has no type checkingReceiver not guaranteed to respond. No response either return null pointer or “forward” to an object that will respondInitial interpretation of message in Objc-C 3x longer than C++ virtual method call. Messages are cached and subsequent calls 50% faster than C++ method call.
Categories/Protocols
PrimitivesInt, float, double, charUnsigned, signed, short, long, long longid – Generic object type
Can be used to store any object Essential to Objective-C’s dynamic binding
If/Else Statements, For/While/Do LoopsCombine features by nesting, “and/or” conditionalsAbstraction – variables, functions, classes
Functions
Variable PassingDefault method is pass-by-value for primitive data typesObjects use pass-by-referenceImpossible to use pass-by-value for ObjectsDoes not pass by result, value-result, name, or need
Type CheckingDynamic type checkingConsidered weak typed languageLanguage supports coercion
When adding float and int, one is changed
Does not support type inference
Object-OrientedDoes not support multiple inheritanceClass must inherit from Object/NSObject classVariable inheritance is dynamicMethod inheritance is dynamicThe super-method invocation uses method from class that super is called in (dynamic)No operation and method overloading
ConclusionVery easy to learnSimple way of handling classes and objectsDynamism allows flexibility in codeErrors may are not found until runtimeNot a very used language outside Apple