Vanta Logo
SPONSOR
Automate SOC 2 & ISO 27001 compliance with Vanta. Get $1,000 off.
Published
6 min read
Up to date

Trevor I. Lasn

Staff Software Engineer, Engineering Manager

Objective-C Is a Total Abomination (opinion)

Objective-C is, without a doubt, one of the ugliest programming languages out there

Objective-C is mainly used for developing software on Apple’s platforms, like macOS and iOS. Its syntax is notoriously difficult, combining elements of C with Smalltalk-style messaging. On paper, that sounds innovative. In reality, it’s a mess.

Concatenate two strings in Objective-C

NSString *string1 = @"Hello";
NSString *string2 = @"World";
NSString *combinedString = [NSString stringWithFormat:@"%@ %@", string1, string2];

This is unnecessarily verbose. Compare it to Swift.

let string1 = "Hello"
let string2 = "World"
let combinedString = "\(string1) \(string2)"

Swift is concise and clear. Objective-C, on the other hand, feels like you’re fighting with the language to do something simple.

Method Calls

Method calls in Objective-C are like reading a ransom note.

[myObject doSomethingWithParam1:param1 param2:param2 param3:param3];

Look at all those brackets and colons. It’s hard to read, and it’s easy to make mistakes. In contrast, Swift is straightforward.

myObject.doSomething(param1: param1, param2: param2, param3: param3)

Notice how much cleaner that looks. Swift’s syntax is modern, clear, and more like what you’d find in other languages. Objective-C feels like it was designed by someone who wanted to be different just for the sake of being different.

Memory Management: A Relic of the Past

Objective-C’s memory management used to be manual. You had to manage memory with retain, release, and autorelease.

MyClass *object = [[MyClass alloc] init];
[object retain];
// Do something with the object
[object release];

It’s clunky and prone to errors. Forgetting to release an object results in memory leaks. Retaining it too much causes crashes. This is a relic of a time before modern memory management.

Thankfully, Automatic Reference Counting (ARC) was introduced. But even with ARC, the language still shows its age. Compare this to Swift, where ARC is integrated seamlessly.

let object = MyClass()
// Use the object without worrying about memory management

Inconsistent Naming Conventions

Objective-C’s naming conventions are all over the place. Method names are long, descriptive, and sometimes too verbose.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;

There’s nothing wrong with being descriptive, but Objective-C takes it too far.

The result is code that’s difficult to read and maintain. Swift, by contrast, uses shorter, more consistent naming:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

Swift’s method names are clear but concise, making the code easier to read.

Lack of Modern Features

Objective-C lacks many of the modern features found in newer languages. For instance, it doesn’t have proper support for:

  • Generics: Handling collections of a specific type is awkward.
  • Optionals: Dealing with null values is painful.
  • Type Inference: You have to declare types everywhere.

Here’s how you’d declare a generic array in Objective-C:

NSArray<NSString *> *array = @[@"Hello", @"World"];

And here’s how you’d do it in Swift.

let array: [String] = ["Hello", "World"]

In Swift, the syntax is cleaner, and you can often omit the type declaration because Swift infers it for you.

Working with Collections: A Tedious Affair

Working with collections in Objective-C is tedious. Let’s say you want to iterate over an array of strings.

NSArray *array = @[@"Hello", @"World"];
for (NSString *str in array) {
NSLog(@"%@", str);
}

It’s not terrible, but it’s not great either. Now, look at the Swift version.

let array = ["Hello", "World"]
for str in array {
print(str)
}

Swift’s version is not only cleaner, but it also benefits from type inference, making the code less verbose. You don’t have to declare the type of str explicitly; Swift figures it out for you.

Working with Blocks: A Confusing Endeavor

Blocks (closures) in Objective-C are another area where the language shows its age. Here’s an example of a block that adds two numbers.

int (^add)(int, int) = ^(int a, int b) {
return a + b;
};
NSLog(@"Sum: %d", add(3, 4));

Compare that to the equivalent Swift closure:

let add = { (a: Int, b: Int) -> Int in
return a + b
}
print("Sum: \(add(3, 4))")

Swift’s closure syntax is more intuitive and less cluttered. The Objective-C version is hard to read, and the syntax feels bolted on rather than integral to the language.

The Ugly Legacy: Header and Implementation Files

Objective-C splits code across header (.h) and implementation (.m) files. This is a relic from C, and it’s an outdated practice that clutters the codebase.

Header File (MyClass.h):

#import <Foundation/Foundation.h>
@interface MyClass : NSObject
@property (nonatomic, strong) NSString *name;
- (void)printName;
@end

Implementation File (MyClass.m):

#import "MyClass.h"
@implementation MyClass
- (void)printName {
NSLog(@"%@", self.name);
}
@end

In Swift, this would be combined into a single file:

class MyClass {
var name: String
init(name: String) {
self.name = name
}
func printName() {
print(name)
}
}

Swift reduces boilerplate and keeps everything in one place, making your code easier to navigate and maintain.

Here’s a classic Objective-C class that illustrates the verbosity and complexity of Objective-C syntax, especially when compared to modern languages like Swift.

Person.h (Header File)

#import <Foundation/Foundation.h>
@interface Person : NSObject
@property (nonatomic, strong) NSString *firstName;
@property (nonatomic, strong) NSString *lastName;
@property (nonatomic, assign) NSInteger age;
- (instancetype)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName age:(NSInteger)age;
- (void)displayPersonDetails;
@end

Person.m (Implementation File)

#import "Person.h"
@implementation Person
- (instancetype)initWithFirstName:(NSString *)firstName lastName:(NSString *)lastName age:(NSInteger)age {
self = [super init];
if (self) {
_firstName = firstName;
_lastName = lastName;
_age = age;
}
return self;
}
- (void)displayPersonDetails {
NSLog(@"Person Details: %@ %@, Age: %ld", self.firstName, self.lastName, (long)self.age);
}
@end

Contrast with Swift

In Swift, the same functionality can be achieved with much less code, in a single file, and with a clearer, more modern syntax.

class Person {
var firstName: String
var lastName: String
var age: Int
init(firstName: String, lastName: String, age: Int) {
self.firstName = firstName
self.lastName = lastName
self.age = age
}
func displayPersonDetails() {
print("Person Details: \(firstName) \(lastName), Age: \(age)")
}
}

Why We Should Move On

Objective-C was revolutionary in its time. It brought object-oriented programming to Apple’s platforms and powered apps for decades. But today, it’s an abomination. It’s ugly, clunky, and difficult to work with.

Swift is the future. It’s modern, clean, and designed with today’s developer in mind. It’s time to leave Objective-C in the past where it belongs.

If you’re still using Objective-C, consider switching to Swift. Your eyes and your sanity will thank you.

If you found this article helpful, you might enjoy my free newsletter. I share developer tips and insights to help you grow your skills and career.


More Articles You Might Enjoy

If you enjoyed this article, you might find these related pieces interesting as well. If you like what I have to say, please check out the sponsors who are supporting me. Much appreciated!

Tech
3 min read

You Don't Own Your Social Media Accounts

Social platforms promise exposure but quietly hold your audience hostage

Nov 28, 2024
Read article
Tech
3 min read

Why Anthropic (Claude AI) Uses 'Member of Technical Staff' for All Engineers (Including Co-founders)

Inside Anthropic's unique approach to preventing talent poaching and maintaining organizational equality

Oct 23, 2024
Read article
Tech
11 min read

Google's Journey: From Search Engine to Tech Giant

Exploring the key innovations and strategies that transformed Google into a global technology leader

Oct 1, 2024
Read article
Tech
10 min read

Amazon's Rise to Tech Titan: A Story of Relentless Innovation

How Jeff Bezos' 'Day 1' philosophy turned an online bookstore into a global powerhouse

Sep 30, 2024
Read article
Tech
3 min read

Open-source is where dreams go to die

Work for free and in return watch your passion get crushed by entitled users who are never satisfied

Feb 26, 2025
Read article
Tech
3 min read

LinkedIn is Drowning in AI Generated Content Slop

One-line paragraphs, LinkedIn broetry, and the inevitable 'Agree?' - welcome to your AI-generated feed

Dec 11, 2024
Read article
Tech
3 min read

Introducing the Legendary Programmer Hall of Fame

Meet the innovators who laid the foundation for modern computing. Their contributions span decades, creating the tools and concepts developers use every day.

Oct 29, 2024
Read article
Tech
4 min read

Chrome Is Beta Testing Built-In AI. Could This Kill a Lot of Startups?

The Power Play: Gemini Nano in Chrome

Aug 31, 2024
Read article
Tech
5 min read

Is Age Really a Factor in Tech?

Silicon Valley has a reputation for youth worship. The 'move fast and break things' mentality often translates to a preference for younger, supposedly more adaptable workers.

Oct 8, 2024
Read article

Become a better engineer

Here are engineering resources I've personally vetted and use. They focus on skills you'll actually need to build and scale real projects - the kind of experience that gets you hired or promoted.

Many companies have a fixed annual stipend per engineer (e.g. $2,000) for use towards learning resources. If your company offers this stipend, you can forward them your invoices directly for reimbursement. By using my affiliate links, you support my work and get a discount at the same!


This article was originally published on https://www.trevorlasn.com/blog/objective-c-is-the-ugliest-programming-language-and-a-total-abomination. It was written by a human and polished using grammar tools for clarity.