Top Banner
All content contained herein is property of Deep Focus. ©2012 All Rights Reserved. JUNE 11, 2014 TECH BREAKFAST #18 SWIFT James Leone Web Developer
13

Tech breakfast 18

May 10, 2015

Download

Education

James Leone

The Basic Over of Swift as a new programming language.
This presentation is general look at Swift, please disregard the fact and references to the Swift scripting language which at the time thought to similar or same.
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: Tech breakfast 18

All content contained herein is property of Deep Focus. ©2012 All Rights Reserved.

JUNE 11, 2014

TECH BREAKFAST #18SWIFT

James LeoneWeb Developer

Page 2: Tech breakfast 18

AGENDA

1. What is Swift?

2. Why Swift?

3. Why Apple chose Swift?

4. 3 things I like ?

5. 3 things I am skeptical?

6. Finally

7. Resources and References

Page 3: Tech breakfast 18

What Is Swift? Swift is parallel: It runs multiple programs concurrently reducing the need for complex parallel

programming.

Short simple scripts can be scaled for large projects.

Swift is fast .

Currently Swift is being used in many fields of science, engineering, and business. Recently Apple announced that Swift will be their new component for app development.

Page 4: Tech breakfast 18

Why Swift? Simple Scripting Language

– Swift is a simple scripting language for executing many instances of ordinary application programs on distributed parallel resources. Swift scripts run many copies of ordinary programs concurrently.

– Swift acts like a structured "shell" language. It runs programs concurrently as soon as their inputs are available, reducing the need for complex parallel programming. Swift expresses your workflow in a portable fashion: The same script runs on multicore computers, clusters, clouds, grids, and supercomputers

Runs Ordinary Applications– Swift scripts run ordinary applications, just like shell scripts do. Swift makes it easy to run these

applications on parallel and remote computers (from laptops to supercomputers). If you can ssh to the system, Swift can likely run applications there.

– The Swift language has 5 main data types: boolean, int, string, float, and file. Collections of these are dynamic, sparse arrays of arbitrary dimension and structures of scalars and/or arrays defined by the type declaration.

Page 5: Tech breakfast 18

PAGE 525 JANUARY 2012

According to Apple: “Swift is a new programming language for iOS and OS X apps that builds on the best of C and Objective-C, without the constraints of C compatibility. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun. Swift’s clean slate, backed by the mature and much-loved Cocoa and Cocoa Touch frameworks, is an opportunity to reimagine how software development works.”

Excerpt From: Inc, Apple. “The Swift Programming Language.” Apple Inc., 2014-05-27T07:00:00Z. iBooks.

Why Apple Chose Swift?

Page 6: Tech breakfast 18

3 Things I like ? The syntax Objective-C’s syntax mainly because of the named parameters in methods. While Java gives you

foo(true, false, 0, 1, null), calls to objC methods are much clearer. So are the ones in Swift. I also like much of the other syntactic things for announcing return types, tuples, the clean closure syntax as well as the ? and ! Notation Relational databases are usually table- based, much like what you see in a spreadsheet.

Handling of nil (null): Its fundamental that the language requires you to address nil explicitly and that nil is not a pointer to nothing but a invalid value. The way you can handle values that might be nil using ? (question mark), which even can be chained.On the other hand, NoSQL databases are more flexible.

Strictness: This is probably (what isn’t?) a matter of taste, but I like it when the compiler tells me right away that I have done something which I should not have. This usually does not happen in script languages (unless you are using a really good IDE).

Page 7: Tech breakfast 18

3 Things I am skeptical about Any and AnyObject: When using the Cocoa API, which still relies on Objective-C and C you sometimes get return

values of AnyObject. AnyObject! (note the !). This can actually hide an objC nil value. I guess usage of these will be reduced in later API releases.Relational databases are usually table- based, much like what you see in a spreadsheet.

Extensions: I heard of the “patching“ of classes in Ruby. Now you can bring your own methods and even initializers to existing classes in Swift, as well. I could not find documentation on about how conflicts are resolved when two extensions try to provide the same methods.On the other hand, NoSQL databases are more flexible.

Stuff that seems to be missing: First and foremost: No access control? Seems a bit odd to me. Also I could not find out how to make properties read-only from outside the class scope, also exceptions and errors are not really covered. The docs say something about errors at runtime that might happen but not how (or even if) you can react.

Page 8: Tech breakfast 18

Basic Ojective C example #import "MyClass.h"@implementation MyClass - (id)initWithString:(NSString *)aName{ // code goes here} + (MyClass *)myClassWithString:(NSString *)aName{ // code goes here}@end

Page 9: Tech breakfast 18

Basic Swift Example  

“class SomeSuperType {}class SomeType: SomeSuperType {}class SomeChildType: SomeType {}let s = SomeType() let x = s as SomeSuperType // known to succeed; type is SomeSuperTypelet y = s as Int // known to fail; compile-time errorlet z = s as SomeChildType // might fail at runtime; type is SomeChildType?”

Excerpt From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/us/jEUH0.l

Page 10: Tech breakfast 18

Finally I think this could be a big learning curve for developers, I personally would like to work with it to see if it

will be new scripting language for Apple.

If Swift is a success and allows faster time for building applications, we should as department think very strongly at building apps, games, etc. If only the task of developing in Swift seems to effortless.

Page 11: Tech breakfast 18

Learn More

Swift Scripting language official site

Apple Developer site

Page 12: Tech breakfast 18

References

http://swift-lang.org/main/

https://developer.apple.com/swift/

“The Swift Programming Language.” Apple Inc., 2014-05-27T07:00:00Z. iBooks

Page 13: Tech breakfast 18

THANKS!