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.
2. 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
3. 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.
4. 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.
5. PAGE 5
25 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?
6. 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).
7. 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.
8. Basic Ojective C example
#import "MyClass.h"
@implementation MyClass
- (id)initWithString:(NSString *)aName
{
// code goes here
}
+ (MyClass *)myClassWithString:(NSString *)aName
{
// code goes here
}
@end
9. Basic Swift Example
“class SomeSuperType {}
class SomeType: SomeSuperType {}
class SomeChildType: SomeType {}
let s = SomeType()
let x = s as SomeSuperType // known to succeed; type is
SomeSuperType
let y = s as Int // known to fail; compile-time error
let 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
10. 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.
11. Learn More
Swift Scripting language official site
Apple Developer site