Swift Pros over Obj-C
5 (1)

Click to rate this post!
[Total: 1 Average: 5]

Obj-C development dates back to 1980s, Swift came with a lot of significant improvements in clarity, performance, safety, and more.

1- Swift is easier to read and maintain

Swift drops legacy conventions, using semicolons to end lines are not needed, also parenthesis are not needed around (conditional expressions), no bracket hell needed for method calls, two-file requirement is dropped by swift, the LLVM compiler can figure out dependencies automatically…

for example, swift adopts modern programming language features like concatenation of two strings together with a “+” operator, along with string interpolation which makes things easier and safer, instead of memorizing special tokens  (%s%d%@), that can be a source of crashes!

2- Swift is more safe, and have better memory management

in Obj-C nothing happens if you call a method with a nil pointer variable, not crashing may look like a benefit, but actually this is a source of bugs and unexpected behavior, optional types in swift solves this problem, this means any bug will be fixed sooner or avoided at all in swift code.

In contrast to swift, in Objective-C, ARC is not available for procedural C and other APIs like CoreGraphcis, swift saves the developer brain power for better things, like writing the app’s main logic, instead of handling memory management.

3- Swift is faster, and is less prone to name collisions

A lot of people made benchmarks, concluding swift being faster and more performant than Obj-C.

a benchmark made by apple.

Obj-C lacked name-spacing, to overcome this issue, a common practice was using a few letters as a prefix, for example NSArray (after NextStep, a company by Steve Jobs), or NSString, … etc.

In swift, namespaces are based on the target that a file relies in, for example, both apple frameworks and google frameworks can have a file called Authentication.swift

4- Swift Supports Dynamic libraries

Obj-C only support static libraries, this is a big downside, swift support dynamic libraries, that can be loaded into the app’s memory directly, this reduces the app total size, and reduces the load time of (on demand) new content.

5- Swift is open-source and has bigger community
Swift has a big community that are actively contributing, hence open-source, it started running in other environments like linux. for example of swift outside of the apple ecosystem, see vapor,  a web framework for Swift.

The Swift language is developed in the open, and all technical or administrative topics about the language or community processes should be directed to the Swift public forums. Public conversations are encouraged, and active developers of the Swift language should monitor the relevant forum categories.


What is Swift Programming Language?
5 (2)

Click to rate this post!
[Total: 2 Average: 5]

Swift is apple’s new open source programming language, that was introduced at Apple’s 2014 Worldwide Developers Conference (WWDC), it’s used to develop for iOS, macOS, watchOS and tvOS, mainly to work with Apple’s Cocoa and Cocoa Touch frameworks, it quickly became one of the fastest growing languages nowadays, hence open source under the Apache 2.0 license, other uses appeared including writing backend server side code using vapor framework.

Swift Programming Language

The main focus with swift is to be concise, more expressive, fast and less prone to error (safer) than Objective-C, with modern features language.

The man behind swift is Chris Lattner, who worked at Apple Inc. as Director of the Developer Tools department, leading the XCode, Instruments, and compiler teams, and the main author of LLVM (low level virtual machine), and CLang (replaces the full GNU Compiler Collection and intended to work atop LLVM).

To make onboarding easier for new comers, swift can run in playground, or a web-based REPL like this.
REPL stands for “Read Eval Print Loop”, it’s a command-line environment with experience similar to interpreted languages.

Chris Lattner (twitter @clattner_llvm)

Swift is a type-safe general-purpose & multi-paradigm language, the design goal of such languages is to allow programmers to use the most suitable programming style and associated language constructs for a given job, considering that no single paradigm solves all problems in the easiest or most efficient way, swift provides its own version of C/Obj-C types, along with powerful versions of the three primary collection types, Array, Set, and Dictionary, one other type it offers is tuple, so you can pass groups of vales, which is not available in Obj-C.

Language paradigms are a lot like musical genres, they’re messy things and we can argue about where to draw the lines, Sometimes swift is object-oriented, other times is functional. And it shines when generic.

The main Swift programming language consists of different projects, they are mentioned as below in swift.org site.

1- The Swift compiler command line tool
2- The standard library bundled as part of the language
3- Core libraries that provide higher-level functionality
4- The LLDB debugger which includes the Swift REPL
5- The Swift package manager for distributing and building Swift source code
6- Xcode playground support to enable playgrounds in Xcode.