Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Open Source Swift Under the Hood

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/1SJ7PSV.

Alex Blewitt talks about Swift, the open source released in December 2015 and available on Linux as well as OSX and iOS. He looks at the open-source project, how applications and libraries can be built for both platforms, the differences between the different builds and how Swift works under the hood. Filmed at qconlondon.com.

Alex Blewitt has over 20 years of experience in Objective-C and has been using Apple frameworks since NeXTSTEP 3.0. He currently works for a financial company in London and writes for the online technology news site InfoQ, as well as other books for Packt Publishing. He also has a number of apps on the App Store through Bandlem Limited.

3.
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
- practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Presented at QCon London
www.qconlondon.com

7.
@alblueOpen Source Swift 2 Under the Hood
Pre-history
• Story starts in 1983 with Objective-C
• Created as a Smalltalk like runtime on top of C
• NeXT licensed Objective-C in 1988
• NextStep released in 1989 (and NS preﬁx)
• Apple bought NeXT in 1996
• OSX Server in 1999
• OSX 10.0 Beta in 2000, released in 2001

9.
@alblueOpen Source Swift 2 Under the Hood
A lot has changed …
• CPU speed has risen for most of the prior decades
• Plateaued about 3GHz for desktops
• Mobile devices still rising; around 1-2GHz today
• More performance has come from more cores
• Most mobiles have dual-core, some have more
• Mobiles tend to be single-socket/single CPU
• Memory has not increased as fast

48.
@alblueOpen Source Swift 2 Under the Hood
SwiftObject and ObjC
• Swift objects can also be used in Objective-C
• Swift instance in memory has an isa pointer
• Objective-C can call Swift code with no changes
• Swift classes have @objc to use dynamic dispatch
• Reduces optimisations
• Automatically applied when using ObjC
• Protocols, Superclasses

51.
@alblueOpen Source Swift 2 Under the Hood
Is Swift swift yet?
• Is Swift as fast as C?
• Wrong question
• Is Swift as fast, or faster than Objective-C?
• As fast or faster than Objective-C
• Can be faster for data/struct processing
• More optimisation possibilities in future

52.
@alblueOpen Source Swift 2 Under the Hood
Swift
• Being heavily developed – 3 releases in a year
• Provides a transitional mechanism from ObjC
• Existing libraries/frameworks will continue to work
• Can drop down to native calls when necessary
• Used as replacement language in LLDB
• Future of iOS development?
• Future of server-side development?

53.
@alblueOpen Source Swift 2 Under the Hood
Swift 3.0
• Next major release of Swift
• In preparation for late 2016 release
• Aims to provide (forward) binary compatibility
• No more need to share source projects for
modules
• Full generics
• API design guidelines and refactoring

54.
@alblueOpen Source Swift 2 Under the Hood
Swift 3.0
• What it will not have:
• Compatible with C++
• Source compatible with Swift 2.x
• Automated 'ﬁx-ups' available for most features
• Macros
• Signiﬁcantly different libraries in core

57.
@alblueOpen Source Swift 2 Under the Hood
Swift 3.0
• Language is being designed in the open
• Proposals vetted and voted in open
• https://github.com/apple/swift-evolution
• Many community suggested improvements
• Removal of ++ and -- operators, C for loops

58.
@alblueOpen Source Swift 2 Under the Hood
Summary
• Swift has a long history coming from LLVM roots
• Prefers static dispatch but also supports objective-c
• Values can be laid out in memory efﬁciently
• In-lining leads to further optimisations
• Whole-module optimisation will only get better
• Modular compile pipeline allows for optimisations