Click here to Skip to main content
15,399,959 members
Articles / Mobile Apps / iOS
Posted 5 Oct 2014


4 bookmarked

"Swift or Objective-C?" that is here the Question!

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
5 Oct 2014CPOL1 min read
Some toughts whether to prefer Objective-C or Swift.


These days in the Apple universe often is asked whether to start in the new language Swift or Objective-C.


I am programming in Objective-C but now diving into Swift and have some experienve and see some pros and cons.

Where is the ";"?

The answer is as expected: 42. These languages arent so different. They are both translated with the LLVM, but Swift has more and better optimization. Also is "bridging" between these languages possible. Swift is in many way a "compressed" version of Objective-C. 
For a starter I would recommand Objective-C because it is the common language and a lot of code is available.

Swift is more modern and very compact, so it need REALLY no semicolon and in few lines of code much stuff is done. For instance it has no header file and declarations also are defining the type and that the value is constant.

let text = "I am a fixed text" // let declares a constant
var number = 10.0 // var declares a variable, the right assigment declares the type double
var state = eStateNormal // a var of my EnumState

Remark: It is also possible to explicitly define the type, but because the needed initialization it is not needed.

var text:String = "I am a normal text" // declares a normal string

Tricky gets Swift at optionals. This are "boxed" types which may or may not hold a value. Because they throw exceptions coders should take care in handling them.

var object? //needs no value now

object = "Hello world" //assigment

if let text = object! { //unwrapping the optional
  println("Value is \(value)")  //how to format a string

Points of Interest

It is my short hand point of view and dont want to make it a battleground. 

For detailed information is the first point the Apple Developer Site. I like the WWDC videos to get started.

Also I recommand to take a look at the website of the famous Ray Wenderlich. For a starter like you is the Video plan an interesting investion.

I would start with Swift only on a new "blank sheet" project, because I dont like switching the languages in one project.


First shot.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
Germany Germany
I am living in germany and now living from programming for some Years. In my spare time I like sports as jogging, playing football (soccer) and basketball.

We must take care for our planet, because we and our family has no other. And everybody has to do something for it.

Comments and Discussions

-- There are no messages in this forum --