SlideShare a Scribd company logo
1 of 24
Objective-C: Good and Bad
Good
Lighweight
Simply preprocessor and small runtime
Syntax sugar over C, easy to learn
Runtime
Completely dynamic message sending.
 Don't need inheritance to call a method
 with different objects
True introspection. Allows to watch class
  hierarchy, check if an object has a
  particular invariant or implements some
  method, call a method by name
Categories and Proxies
Allows addition of methods to another class
Even a class you don't have source for
Also allows overriding of existing methods
Key Value Coding/Observing
Bind string names with object invariants at
  run-time
Call back when the value of some invariant
 is going to be / was changed
Self-contained objects
Objects tend to be handful and smart
 enough to be used standalone
#import
No include guards or “#pragma once”
 anymore
[NSBundle classNamed]
Create a class by name, which could be
 used later to instantiate objects
Blocks
Closures are awesome
Allows to define a block of code with
  surrounding context and pass it to other
  function
Facilitates concurrency
Bad
Syntax
Lots of square braces. Compare:
  [[[MyClass alloc] init:[foo bar]] autorelease]
  MyClass.alloc.init(foo.bar).autorelease
Keyed parameters: difficult to reorder them
 during refactoring
Lighweight
The same code has to be repeated often
Little language support for anything other
  than message sending
Folks could say “because there's no magic”.
 But more code means more bugs
Without Cocoa this “no magic” would be
 absolutely awful
Memory Management
Half-manual, half-automatic
Raw pointers are evil
No garbage collector
Reference counters overhead
Migration to automatic reference counting
 takes time
Allocation and Initialization
Which are two separated operations
 MyClass *object = [MyClass alloc] init];
Multiple constructors work via designated
 initializers without any language support
self = [super init]; //assignment to self :(
  if (self)
  {
    //init invariants
  }
  return self;
No Stack Objects
Dealloc won't be called automatically
Messaging nil
Does nothing and hides real bugs
Wouldn't be so bad if it were easy to make
 messaging nil scream
Cocoa messages nil as a matter of course
Overriding and Overloading
Categories are broken: overriding a method
 more than once leads to undefined
 behavior
No method overload. Need to mangle
 names manually
No Namespaces
Not a major gripe, but It's real handy
Id should be id *
Not clear:
 NSString *foo = @”foo”;
 id bar = foo;
Better:
 NSString *foo = @”foo”;
 id *bar = foo;
So So
Frameworks
Could be a problem, if Cocoa wasn't the
 best one publicly available
Type Safety
Can't catch lots of errors during the compile
 time
But allows its awesome runtime features
Questions?

More Related Content

What's hot

Glenn Vanderburg — Learning to love JavaScript
Glenn Vanderburg — Learning to love JavaScriptGlenn Vanderburg — Learning to love JavaScript
Glenn Vanderburg — Learning to love JavaScript
atr2006
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
Holger Schill
 
Obj-C and iOS for .NET Developers
Obj-C and iOS for .NET DevelopersObj-C and iOS for .NET Developers
Obj-C and iOS for .NET Developers
escoz
 

What's hot (20)

Metaprogramming with javascript
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascript
 
JavaScript Good Practices
JavaScript Good PracticesJavaScript Good Practices
JavaScript Good Practices
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Glenn Vanderburg — Learning to love JavaScript
Glenn Vanderburg — Learning to love JavaScriptGlenn Vanderburg — Learning to love JavaScript
Glenn Vanderburg — Learning to love JavaScript
 
Scala - the good, the bad and the very ugly
Scala - the good, the bad and the very uglyScala - the good, the bad and the very ugly
Scala - the good, the bad and the very ugly
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
 
Formatting ForThe Masses
Formatting ForThe MassesFormatting ForThe Masses
Formatting ForThe Masses
 
Advanced oops concept using asp
Advanced oops concept using aspAdvanced oops concept using asp
Advanced oops concept using asp
 
scala-intro
scala-introscala-intro
scala-intro
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
 
Continuations in scala (incomplete version)
Continuations in scala (incomplete version)Continuations in scala (incomplete version)
Continuations in scala (incomplete version)
 
Obj-C and iOS for .NET Developers
Obj-C and iOS for .NET DevelopersObj-C and iOS for .NET Developers
Obj-C and iOS for .NET Developers
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Dynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection PromisesDynamically Composing Collection Operations through Collection Promises
Dynamically Composing Collection Operations through Collection Promises
 
Mac/iOS Design Patterns
Mac/iOS Design PatternsMac/iOS Design Patterns
Mac/iOS Design Patterns
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
JavaScript Essentials for Ember development
JavaScript Essentials for Ember developmentJavaScript Essentials for Ember development
JavaScript Essentials for Ember development
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 

Similar to Objective-C: Good and Bad

Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
Daniel Egan
 
Modern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscanaModern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscana
Matteo Baglini
 
Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)
dannygriff1
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
google
 

Similar to Objective-C: Good and Bad (20)

First class Variables in Pharo
First class Variables in PharoFirst class Variables in Pharo
First class Variables in Pharo
 
Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Javasession6
Javasession6Javasession6
Javasession6
 
All of Javascript
All of JavascriptAll of Javascript
All of Javascript
 
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building BlocksOCA Java SE 8 Exam Chapter 1 Java Building Blocks
OCA Java SE 8 Exam Chapter 1 Java Building Blocks
 
Sep 15
Sep 15Sep 15
Sep 15
 
Sep 15
Sep 15Sep 15
Sep 15
 
Core java Basics
Core java BasicsCore java Basics
Core java Basics
 
Complete Java Course
Complete Java CourseComplete Java Course
Complete Java Course
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Modern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscanaModern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscana
 
How Scala promotes TDD
How Scala promotes TDDHow Scala promotes TDD
How Scala promotes TDD
 
Is2215 lecture2 student(2)
Is2215 lecture2 student(2)Is2215 lecture2 student(2)
Is2215 lecture2 student(2)
 
Why using finalizers is a bad idea
Why using finalizers is a bad ideaWhy using finalizers is a bad idea
Why using finalizers is a bad idea
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Core_java_ppt.ppt
Core_java_ppt.pptCore_java_ppt.ppt
Core_java_ppt.ppt
 
C# interview
C# interviewC# interview
C# interview
 
Linq 1224887336792847 9
Linq 1224887336792847 9Linq 1224887336792847 9
Linq 1224887336792847 9
 
Designing Better API
Designing Better APIDesigning Better API
Designing Better API
 

More from Anthony Shoumikhin (10)

iOS History
iOS HistoryiOS History
iOS History
 
Mach-O Internals
Mach-O InternalsMach-O Internals
Mach-O Internals
 
Программирование Linux
Программирование LinuxПрограммирование Linux
Программирование Linux
 
Основы Reverse Engineering
Основы Reverse EngineeringОсновы Reverse Engineering
Основы Reverse Engineering
 
Кратко о Mac OS X
Кратко о Mac OS XКратко о Mac OS X
Кратко о Mac OS X
 
Отладка в GDB
Отладка в GDBОтладка в GDB
Отладка в GDB
 
Программирование Linux
Программирование LinuxПрограммирование Linux
Программирование Linux
 
Кратко о Linux
Кратко о LinuxКратко о Linux
Кратко о Linux
 
Программирование Linux
Программирование LinuxПрограммирование Linux
Программирование Linux
 
Kubuntu
KubuntuKubuntu
Kubuntu
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

Objective-C: Good and Bad