The Rise & Rise of Swift Programming Language

The Rise & Rise of Swift Programming Language

Swift, as we know it, is a general-purpose, multi-paradigm, compiled programming language that came out of Apple Inc’s headquarters for iOS, iPadOS, macOS, watchOS, tvOS, Linux, and z/OS. The language has been designed to work with Apple's Cocoa...

Swift, as we know it, is a general-purpose, multi-paradigm, compiled programming language that came out of Apple Inc’s headquarters for iOS, iPadOS, macOS, watchOS, tvOS, Linux, and z/OS. The language has been designed to work with Apple's Cocoa and Cocoa Touch frameworks and the large body of existing Objective-C code written for Apple products.

Technically, it is built with the open source LLVM compiler framework and has been included in Xcode since version 6 which was first released in 2014. On Apple platforms, it uses the Objective-C runtime library which allows C, Objective-C, C++ and Swift code to run within one program.

Apple intended Swift to support many core concepts associated with Objective-C, significantly dynamic dispatch, widespread late binding, extensible programming and similar features, but in a "safer" way, making it easier to catch software bugs; Swift has features addressing a few common programming errors like null pointer dereferencing and provides syntactic sugar to help avoid the pyramid of doom.

The first launch of Swift was at Apple's 2014 Worldwide Developers Conference (WWDC). After that it went under an upgrade to version 1.2 during 2014 and an another major upgrade to Swift 2 at WWDC 2015. During the infant stages, a proprietary language, version 2.2 was made open-source software under the Apache License 2.0 on December 3, 2015, for Apple's platforms and Linux.

The History
As per the history of this programming language, the early development of Swift began in July 2010 by Chris Lattner, with the gradual collaboration of different other programmers at Apple. The core of Swift took language ideas from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list.

On June 2, 2014, the Apple Worldwide Developers Conference (WWDC) application became the first publicly released app written with Swift. A beta version of the programming language was released to a select few registered Apple developers at the conference, but the company did not promise that the final version of Swift would be source code compatible with the test version. The company did plan to make source code converters available if needed for the full release during that time.

The Swift Programming Language, a free 500-page manual, was also released at WWDC, and is available on the iBooks Store and the official website.

  • Soon after the launch, Swift reached the 1.0 milestone on September 9, 2014, with the Gold Master of Xcode 6.0 for iOS.
  • Swift 1.1 was released on October 22, 2014, with the simultaneous launch of Xcode 6.1.
  • Swift 1.2 was released on April 8, 2015, along with Xcode 6.3.
  • Swift 2.0 was announced at WWDC 2015, and was made available for publishing apps in the App Store on September 21, 2015.
  • Swift 3.0 was released on September 13, 2016.
  • Swift 4.0 was released on September 19, 2017.
  • Swift 4.1 was released on March 29, 2018.

A worthy thing to note here is that Swift won first place for Most Loved Programming Language in the Stack Overflow Developer Survey 2015 and second place in 2016.

Cone December 3, 2015, the Swift language, supporting libraries, debugger, and package manager were open-sourced under the Apache 2.0 license with a Runtime Library Exception, and Swift.org was created to host the project. You can find the source code hosted on GitHub, making it easy for anyone to get the code, build it themselves, and even create pull requests to contribute code back to the project.

Let’s check the version history of Swift

Source:- Wikipedia

Conclusion
Since the language is open-source, there are prospects of it being ported to the web. Some web frameworks have already been developed, such as IBM's Kitura, Perfect and Vapor.

A second free implementation of Swift that targets Cocoa, Microsoft's Common Language Infrastructure (.NET), and the Java and Android platform exists as part of the Elements Compiler from RemObjects Software. Everything combined together makes Swift a superior language to work with, be for a Swift app development company or a standalone Swift developer.

A Comparision Of Swift and Kotlin Language

Swift and Kotlin are two great languages for iOS and Android development respectively. Both these languages have their own pros and cons, here in this blog we have mentioned all these differences and benefits.

Accessing Swift protocol property implemented in an Obj-C class from another Swift class

I've seen lots of questions regarding implementing Obj-C protocols in Swift, but not so much the other way around, and I haven't seen this specifically.

I've seen lots of questions regarding implementing Obj-C protocols in Swift, but not so much the other way around, and I haven't seen this specifically.

I am using a mixed Obj-C / Swift codebase. I have a Swift protocol defined as follows:

NamedItem.swift

@objc protocol NamedItem {
    var name: String { get }
}

I have an existing Objective-C class that currently has its own name property:

MyObjcClass.h

@interface MyObjcClass : NSObject
@property (nonatomic, strong, readonly) NSString* name;
@end

I have a couple other classes that have a name property, so obviously I'd like to associate them all with a protocol instead of typecasting to a bunch of different types. Now, if I try to switch my Obj-C class from having its own property to implementing the Swift protocol:

MyObjcClass.h

@protocol MyObjcProtocol
@property (nonatomic, strong, readonly) NSString* place;
@end

@interface MyObjcClass : NSObject
@end

MyObjcClass.m

@interface MyObjcClass () <NamedItem>
@end

@implementation MyObjcClass
@synthesize name = _name;
@synthesize place = _place;
@end

This works great, in my other Objective-C classes, but if I try to access the name property from a Swift class:

SomeSwiftClass.swift

let myObj = MyObjcClass()
myObj.name // error
myObj.place // no problem

I get the following error:

Value of type 'MyObjcClass' has no member 'name'

If I don't remove the existing @property declaration from MyObjcClass.h and omit the @synthesizestatement everything builds correctly. Which seems weird and wrong - If you adopt a Objc-C protocol from an Obj-C class you don't have to re-define the property, just the @synthesize statement is sufficient.

I've tried defining the Swift protocol about every way I could think of and have been able to find suggestions about, but I haven't been able to get around this.

So, what is the correct way to implement a Swift protocol property (maybe specifically a read-only property?) in an Objective-C class such that another Swift class can access it? Do I really have to re-declare the property in the Obj-C header? I know I could always give it up and just define the protocol in Objective-C, but... Swift is the future! (or something like that...)