Introduction to Swift

Introduction to Swift

Official Page: Swift Language

Apple released Swift in mid 2014 and the aim was to ease the development process by introducing a language which is more readable, compiles faster and fun to work with. Some of its advantages are

Readable and Concise

  • In the web world Javascript is eating all other languages and so Apple guys made swift look more like Javascript.
  • Readable code is easier to scan and comprehend. So in Swift
    • Cleaner sytax for defining variables and blocks.
    • Header files were removed and modules were introduced.
    • Message passing syntax was removed.
    • Type guessing was introduced. Objects now were able to guess their type when first initialised.
    • Modules were auto imported.

Language Features

  • Better type safety.
  • Better Memory Management.
  • New types like tuples.
  • New functional paradigms like extensions.

Interoperability

  • Swift introduced Bridging headers which lets you include Objective C header files.
  • Now you can use the Objective C libraries without waiting it to get rewritten in Swift.
  • Converting large apps written in Objective C to Swift becomes smooth. You can iteratively convert your app to Swift.

Performance

  • Apple boasts about Swift performance in terms of compile and run times.

Opensource

  • Swift project is now open source. This ensures that the language will evolve in a best possible way.

Playgrounds

  • Playgrounds were introduced by Apple which are self contained sandbox apps. You can test your code in a playgroud file and view the output on the fly without compiling the whole thing.
  • As they are interactive, people have written books and tutorials on Swift using a single playground file.
  • You can write your interactive app documentation there.

Cons

Cons are generally bugs which will get fixed over a period of time.

  • Sometimes Xcode displays misleading errors and warnings.
  • Third party apps need to support Swift.

Related Posts

Leave a comment

Hey, so you decided to leave a comment! That's great. Just fill in the required fields and hit submit. Note that your comment will need to be reviewed before its published.