I’m new to iOS development. Should I start learning Swift or Objective-C?

- 7 mins

TL;DR Start with Swift, if necessary learn Objective-C later.

Intro

These days we have some programming language dualism when it comes to iOS development. For years, iOS apps were created using Objective-C. In the middle of 2014, Apple announced Swift – new programming language, and within two years, this young cub, became heavy-hitter and a real game changer. Before we determine if it is better to start learning iOS development with Swift or Objective-C, lets review how it started, what was the reason behind Swift genesis, and what is the current status?

Long long time ago…

Everything begins in the early ’70s, when C language was developed and used to rewrite the Unix operating system. What are C features? C is procedural (there is one main program, and many procedures that can be called and executed from the main program), imperative (you write a program like you are writing sentence in imperative mood – “do something… then do something else… then if something happens do something”) and low-level (it basically means that however program is fast and efficient, development process is time-consuming, error prone, unpleasant and developer needs to know a thing or two about hardware and memory). C became one of the most popular programming languages of all time, with compilers available for the majority of existing computer architectures and operating systems. C is still in use, for example, when it comes to programming microcontrollers. You can even sometimes find code written in this language in iOS projects, especially when it comes to low-level stuff, where memory matters.

In the ‘80s another programming language was developed – Smalltalk. Contrary to C, Smalltalk was object oriented. What are objects? It’s a conception of a thing which may contain data (“attributes”, which means “how object looks”) and code (“methods”, which means “what object can do”). Objects are created when program runs and they can interact between themselves (please pardon this loose, intuitive definition).

But hey, what does C and Smalltalk have in common with iOS development?

Two people – Brad Cox and Tom Love, inspired by Smalltalk features, started working at their company Stepstone on the implementation of an object-oriented extension to C. In 1988, a book titled “Object-Oriented Programming, An Evolutionary Approach” was published, which contains the description of Objective-C. In the same year, NeXT licensed Objective-C from StepStone. NeXT developed two important frameworks that have strong influence on current iOS development: AppKit and FoundationKit.

A few years later, in 1996, Apple acquired NeXT. This is how Objective-C landed in the company which manufactures iPhone in the future and that is the reason why Objective-C is so popular when it comes to iOS apps development.

As we can see, Objective-C is quite old. This is probably why Apple started working in 2010 on their new programming language – Swift. Four years later Swift was publicly released. Language was constantly evolving, and in 2015 it became open source. Evolution is not finished – Apple encourages people to share ideas how Swift can be improved. Proposals about Swift Evolution are collected and reviewed in Swift Programming Language Evolution public repository on Github.

How does Swift differ from Objective-C?

First of all, it doesn’t hold C and Smalltalk heritage. Syntax is cleaner and has better readability. It supports type inference, which results in cleaner and less prone to error code. What’s more, Swift has all these nice features that modern programming language should have: generics, fast and concise iteration over collections, tuples, multiple return values, native error handling and functional programming patterns.

So should I start learning Swift or Objective-C?

Objective-C has existed for years. A lot of projects are written in this language. There are thousands of tutorials, video tutorials, GitHub repos, books and Stack Overflow questions and answers. If you look through job offers, this programming language is still demanded. So maybe starting learning Objective-C before Swift is good idea? I believe it’s not.

Why learning Swift before Objective-C seems more rational?

So… is Objective-C useless?

No. There are still many companies that hold and maintain projects with thousands lines of Objective-C code. There are still many great frameworks, written in this language. It is well known, tested over years and still popular. And there are many iOS developer job offers that requires it. Objective-C is still in the game, but it’s definitely harder and more unpleasant to learn.

Summing up

When you start learning iOS development, the most important things are concepts, patterns and knowledge of popular frameworks. In my opinion, programming language is secondary. There are two main reasons why Swift is better to putting first steps in iOS development:

I believe that the rational strategy is to start with Swift, get familiar with Xcode, frameworks, design patterns and all iOS stuff, and later, if there will be a necessity, learn Objective-C. And I really envy people who have possibility to start learning programming with Swift, instead of ugly, old child of C and Smalltalk.

Aleksander Popko

Aleksander Popko

iOS & macOS Software Engineer

comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora