objective-c drew cheng cs420. overview true superset of ansi c object-oriented methods from...

13
Objective-C Drew Cheng CS420

Upload: clemence-bryant

Post on 17-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Objective-CDrew ChengCS420

Page 2: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Overview

True superset of ANSI C

Object-Oriented methods from SmallTalk

There is no formal written standard for the language

Relies on outside libraries

Iterative/Imperative

Flexibility, most things are done at runtimeDynamic Typing

Dynamic Binding

Dynamic Linking

Message Passing

Page 3: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

History

Created by Brad Cox and Tom Love at their company Stepstone

Both were introduced to SmallTalk while working at ITT

Cox was interested in the problems of true reusability in software design and programming

Modified C compiler and created a Object-Oriented extension of C called OOPC

Tom Love added more to OOPC from SmallTalk creating Objective-C

Page 4: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

1986 – Stepstone releases Objective-C

1988 – Steve Jobs acquires Objective-C license for NeXT

NeXT releases their own Objective-C compiler and libraries used in NeXTstep Operating System and OpenStep API

1993 – GNU Objective-C runtime, currently in use, created by Kresten Thorup

1996 – Apple Inc. acquires NeXT and uses OpenStep in new Mac OS X

Apple combines Objective-C and NeXT’s Objective-C, creates Cocoa API, most significant environment

Page 5: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Uniqueness

Messaging/ForwardingDoes not call method, sends message

Target of message is resolved at runtime

Message passing has no type checking

Receiver not guaranteed to respond. No response either return null pointer or “forward” to an object that will respond

Initial 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

Page 6: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

PrimitivesInt, float, double, char

Unsigned, signed, short, long, long long

id – Generic object typeCan be used to store any object

Essential to Objective-C’s dynamic binding

If/Else Statements, For/While/Do Loops

Combine features by nesting, “and/or” conditionals

Abstraction – variables, functions, classes

Page 7: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Functions

Page 8: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Variable Passing

Default method is pass-by-value for primitive data types

Objects use pass-by-reference

Impossible to use pass-by-value for Objects

Does not pass by result, value-result, name, or need

Page 9: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Type Checking

Dynamic type checking

Considered weak typed language

Language supports coercionWhen adding float and int, one is changed

Does not support type inference

Page 10: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Object-Oriented

Does not support multiple inheritance

Class must inherit from Object/NSObject class

Variable inheritance is dynamic

Method inheritance is dynamic

The super-method invocation uses method from class that super is called in (dynamic)

No operation and method overloading

Page 11: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language
Page 12: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language
Page 13: Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language

Conclusion

Very easy to learn

Simple way of handling classes and objects

Dynamism allows flexibility in code

Errors may are not found until runtime

Not a very used language outside Apple