Top Banner
[email protected] Toll Free : +1-877-284-1028
31

Shift to SWIFT: An Unusual Journey from Objective C

Jul 02, 2015

Download

Mobile

Jason Kennedy

Shift to SWIFT – The need for something new

In the past, Apple has employed many leading creative designers and innovative coders whose efforts are obvious to us via the implementations of languages such as JavaScript, Python, WebKit and Ruby. Apple has been capable of developing apps using third party systems based on other languages while also being keen to develop the best of tools possible. Apple was expected to benefit by having their own language customized and optimized exclusively for Cocoa Touch and Cocoa development. It was common observation that with bulk modifications and loop configurations there were regular code repetition errors which developers had to face.

Technical Advantages:

SWIFT has been the result of researching programming languages, combining decades of experience. It has certain fabulous features an application developer can actually fall in love with since it makes your code more expressive. Check these out:

1. Clean syntax that makes APIs in SWIFT even easier to read and maintain.
2. Application programming interfaces (APIs) in SWIFT are simple to read.
3. SWIFT manages memory automatically and you are not required to type semicolons.
4. Just like many scripting languages, the compiler in SWIFT gathers the variable type, such is not the case with Objective C which relies on defined pointers.
5. Closures unified with function pointers.
6. Tuples and multiple return values.
7. Fast and concise iteration over a range or collection.
8. Structures that support methods, extensions, protocols.
9. Functional programming patterns Eg. map and filter.

Benefits of SWIFT for Businesses and Developers:

1. Programming: SWIFT is not very much complex therefore does not require much parallel programming. It can run number of programs simultaneously.

2. Swift, smooth and Speedy: Business can be big and big businesses operate around thousands of lines of codes for simplest of functions for state-of-the-art optimizations. You can launch millions of programs together and hundreds of programs per second in SWIFT. You can work on large scale and simple and short scripts. You can run same script on supercomputer, grids, clusters and cloud.

3. Flexibility: It is such a beautiful programming language that its extensive features can be used in varied domains which includes engineering and science, education, physical sciences, biological sciences, humanities and social sciences.
SWIFT coding seems exciting

I suppose my blog would have given you as a blogger, developer, programmer or a researcher sufficient information about the transition from Objective C to SWIFT. The blog suffices the changeover and makeover of programming languages and how SWIFT language is playing a vital role.

All the best with using Swift!
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Page 2: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Apple has launched Swift

as its new programming language after Objective C.

Page 3: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• A question that needs answering:

Why shift to a relatively new language

SWIFT when you were already successful with one of the most powerful, robust and a proven language- Objective C?

Page 4: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

And when things move in the magnanimous empire of Apple,

People observe.

People wonder.

People question.

Apple would not go for such

a change unless it is absolutely necessary

Change happens for

a reason

Page 5: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

On the other hand, SWIFT is not even

complete and is still under ‘construction’

of sorts!

Are there eve really legit reasons to blindside

Objective C for Swift?

Afterall, Objective C

has been really

efficient!

Page 6: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• A quick glance at the content of this blog:

• The advent of Objective C

History

The value of Objective C in mobile application development arena,

How & why SWIFT came into existence,

• The capabilities and benefits of SWIFT

• A quick comparison Objective C vs SWIFT

• Concluding the findings – solving the mystery of shift to SWIFT

Page 7: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Objective-C was created at the Stepstoneby Brad Cox and Tom Love.

It was licensed by NeXT ComputerInc. to develop the NeXTSTEPframeworks that preceded Cocoa.

Page 8: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Mac OS X’s Cocoa was adapted into the iPhone OS

which came into existence from NeXTSTEP’s application frameworks.

• Cocoa Touch emerged from Cocoa later on.

AppleNeXT(OS:NeXTST

EP)

Mac OS X

Page 9: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Steve Jobs incorporated Objective-C which became the backbone of OS X and iOS in years later.

Apple chose Objective-Cas it was already thelanguage of NeXT.

Page 10: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• First, it is an object oriented language. The kind offunctionality which is packaged in Cocoaframeworks can only be delivered through object-oriented techniques which can be incorporatedwith Objective-C.

Page 11: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• As Objective-C incorporates C, you get all thebenefits of C when you work with Objective-C.

Page 12: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Fundamentally simpler. Its syntax is small,unambiguous and easy to learn.

• As steep learning curve for new recruits as itemphasizes on abstract design.

• Well-organized language which result in moreproficient object-oriented programmer.

Page 13: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

“Change is the law of life”- John F. Kennedy

Page 14: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Apple announces SWIFT as it’s new programming language.

Designed to work with Cocoa & Cocoa Touch frameworks

Large body of existing Objective C code

Page 15: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

They say :

• It is fast.

• It is a more ‘modern’ option which takes features from languages like JavaScript and infuses within “power of Objective-C without the C”.

• It will be easy to adopt for new app development experts instead of the veteran developers.

Page 16: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Page 17: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Designed for Ensuring Safety

Variables initialised before use necessarily

Memory is managed automatically

Arrays and integers are checked for overflow

...and more

Page 18: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Intuitive and Interactive Playgrounds

Quick visual of how an algorithm works, Playgrounds make writing a SWIFT code simple and fun.

Result appears immediately. You can watch the progress of your code in the timeline assistant.

Watch the display variables in the graph, keep drawing while composing

You can experiment new APIs which can hone your SWIFT coding skills.

Verify your new tests before actually promoting into your test suite

Page 19: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Fast and Robust

Syntax and standard library

Since it is the successor of C and Objective-C languages it includes primitives such as types, flow-control, operators and fosters object-oriented features such as classes, generics, protocols therefore, giving Cocoa, Cocoa Touch developers the power the demand.

Page 20: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Objective C and SWIFT areinteroperable and applicationdevelopers can develop apps inSWIFT using third party libraries tobuild software for iOS7 and iOS8

Page 21: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

In the short run, it seems they will be usedinterchangeably but in the longer run, I don’t see areason why they should co-exist. Bye Bye Objective Cindeed but not just yet. Not yet.

But in the longer run, I don’t see a reason why they should co-exist. Bye Bye Objective C

indeed but not just yet. Not yet.

Page 22: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Sno. SWIFT Programming Language Objective C

1

The syntax in SWIFT is clear and concise therefore makes APIs in SWIFT easier to read and maintain.

Objective-C is based on C language, which is difficult to master on its own.

2 SWIFT takes features from various other programming languages like JavaScript and also infuses the power Objective-C.

The approach that Objective C takes to passing messages between applications or within an application is difficult to learn.

3

SWIFT is great programming language for people interested in developing for iOS/OS X. It is inspired with the likes of languages like Python, Ruby, and Rust.

Objective-C is a notoriously difficult language since its syntax is unlike that of any other major programming language. Still some unambiguous syntax as compared to other programming language.

4 SWIFT allows you to develop your app interactively.

Objective C does not allow you to develop your app interactively.

vs

Page 23: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Sno. SWIFT Programming Language Objective C

5 SWIFT has type inference.Objective C does not have type

inferences.

6 SWIFT has generics. Objective C does not have generics.

7SWIFT is incredibly expressive programming

language.Objective C is not as intuitive and expressive as that of SWIFT.

8SWIFT brings within itself better type safety,

better memory management, multiple return values, and a bunch of functional paradigms.

Programming language Objective C is not as safe as that of SWIFT.

vs

Page 24: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Sno. SWIFT Programming Language Objective C

9

Command-click a Swift class name to see its generated header.

No such feature in Objective C

10Option-click a symbol to see implicit

information about it, like its type, attributes, and documentation comments.

No such feature in Objective C

11it's not necessary to end statements with a

semicolon in Swift,In Objective-C, it's necessary to put

a semicolon at the end of a statement..

12

switch statements must include a default statement, programmers must include brace brackets to open and close "If" statements, which prevents bugs such as the SSL "goto fail" error

No such precautionary warning logic is available in Objective C and the code has to be manually confirmed to avoid such issues

vs

Page 25: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Sno. SWIFT Programming Language Objective C

13

SWIFT language that is available today isn't the finished product. Apple is still working on it, and it's highly likely that new features will be added over the coming months.

Objective C is established

14

PLAYGROUNDS - This tool lets you see the effects of changes or additions to code as you type, without going through the time-consuming rigmarole of running the code through the compiler and executing it.

No such tool in Objective C for visualization

15You can concatenate strings easily using "+="

and compare strings using "==" instead of the more cumbersome "isEqualToString:"

Same features available here as well but not as simple as in SWIFT. Eg:-"isEqualToString:" is used for “==”

16A tuple lets you group multiple elements into a

single compound variable.There are no tuples in Objective C

vs

Page 26: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• SWIFT as I understand is anothercheck-point in this story ofevolution of functionalprogramming languages.

• It is the first of the pseudo-functional programminglanguages which is lining up tobecome industry standards.

• SWIFT is definitely a big leapwhich I think can positivelyreplace Objective C absolutely.But ....

• There was one question whichtriggered this completeresearch- Why did they shift toSWIFT when Objective C wasserving Apple well?

Page 27: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• Perhaps Apple was desperate to not miss an opportunity.

• Perhaps Apple was tired of being too cautious.

• Perhaps the competition in the market made it a necessity to up the interest in their technologies.

Page 28: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

• The answer to the same now seems rather simple-

It is good to have something which is productive but the search for the best should never cease. And when you sniff at something creative, you should go- rather leap for it. Innovate till you live…

Page 29: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Sounds almost like a life lesson…

... But then, is that not all what Steve Jobs was about?

Page 30: Shift to SWIFT: An Unusual Journey from Objective C

[email protected] Toll Free : +1-877-284-1028

Page 31: Shift to SWIFT: An Unusual Journey from Objective C

support@algoworks.

comToll Free : +1-877-284-1028

THANK YOU

Learn about how Algoworks can help your business!

Call us at: +1-877-284-1028

Mail us at: [email protected],[email protected]

Official Blog LinkAlgoworks

[email protected] Toll Free : +1-877-284-1028