Introduction to Swift

Swift is a programming language developed by Apple and designed by Chris Lattner, who has recently left Apple to join Tesla as the Vice President of Autopilot Software and lead Tesla’s autopilot engineering team.

Swift 1.1 was released on October 22, 2014.

Swift 1.2 was released on April 8, 2015.

Swift 2.0 was released on September 21, 2015.

Swift 3.0 was released on September 13, 2016.

Even though Swift was released less than 3 years, Swift has become some of the fastest growing programming language currently ranked 12 by TIOBE

However Swift is only limited to Apple Operating System meaning you could only run Swift on Apple desktop/laptop. Xcode is an integrated development environment (IDE) developed by Apple to run Objective-C and Swift. And Xcode is only compatible with Mac at this time.

Some of the features that I personally favor is the ability to edit the code and build the interface at the same time just like the picture shown above. Xcode is definitely faster in compiling codes producing apps on the simulator.

What makes Swift different from others? 

Apple proudly claim that Swift is safe, modern and powerful. By being safe, Apple has bring Swift to a level where you could be less frustrating writing your code by showing us what we’re doing wrong preventing mistakes or errors from rising. One of the modern aspect of Swift is that it is a lot easier to read and write than Objective-C. Swift doesn’t require you to use semi colon at the end of each code as compared to many other programming languages.

Examples of Swift codes

Understand the differences between var and let which is the basic of Swift

var is a mutable variable, meaning you could change the value in it. Right now the value is “Hello, my value can be changed”. Later down, the line, I could change the value to a different value.

let is an immutable variable, meaning you couldn’t change the value in it. The value contained in it cannot be replaced with any other value. This is sometimes referred as constant in different programming languages.

Instead of declaring the datatype such as int, double or float for each of the variable, I could easily store the number in each of the variable which is a simple process.

Now we could easily typecast (convert the data type to a different data type) some of the variables to a different datatype. We know that zeroPointOneOneOneOne is a float data type that contains 0.1111, and if used around with Int, we would then get an Int data type which is 0 instead of showing 0.1111 which is the float type. Remember that int only reads in the whole number without decimal number. Float reads in number with decimal number.

I hope this could give you at least some brief idea of Swift.

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *