Swift High Performance
图书信息
| 作者 | Kostiantyn Koval |
| 出版社 | Packt Publishing |
| ISBN | 9781785284960 |
| 出版时间 | 2015-11-01 |
| 字数 | 153.3万 |
| 分类 | 进口书,外文原版书,其他 |
读书简介
Leverage Swift and enhance your code to take your applications to the next levelAbout This BookBuild solid, high performance applications in SwiftIncrease your efficiency by getting to grips with concurrency and parallel programmingUse Swift to design performance-oriented solutionsWho This Book Is ForThis book is aimed at experienced Swift developers wanting to optimize their programs on Apple platforms to optimize application performance.What You Will LearnBuild solid, stable, and reliable applications using SwiftUse REPL and Pl to manage and configure relational databasesExplore Swift's features including its static type system, value objects, and functional programming Design reusable code for high performance in SwiftUse to Xcode LLBD and REPL to debug commandsAvoid sharing resources by using concurrency and parallel programmingUnderstand the lazy loading pattern, lazy sequences, and lazy evolution.In DetailSwift is one of the most popular and powerful programming languages for building iOS and Mac OS applications, and continues to evolve with new features and capabilities. Swift is considered a replacement to Objective-C and has performance advantages over Objective-C and Python. Swift adopts safe programming patterns and adds modern features to make programming easier, more flexible, and more fun.Develop Swift and discover best practices that allow you to build solid applications and optimize their performance.First, a few of performance characteristics of Swift will be explained. You will implement new tools available in Swift, including Playgrounds and REPL. These will improve your code efficiency, enable you to analyse Swift code, and enhance performance. Next, the importance of building solid applications using multithreading concurrency and multi-core device architecture is covered, before moving on to best practices and techniques that you should utilize when building high performance applications, such as concurrency and lazy-loading. Finally, you will explore the underlying structure of Swift further, and learn how to disassemble and compile Swift code.Style and approachThis is a comprehensive guide to enhancing Swift programming techniques and methodology to enable faster application development.
目录
Swift High Performance
Table of Contents
Swift High Performance
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Exploring Swift's Power and Performance
Swift speed
Welcome to Swift
Why should I learn Swift?
Swift's features and benefits
Clean and beautiful
No semicolons
Type inference
Other clean code Swift features
A clean code summary
Safe
Optionals
Error handling
Rich type system
Powerful value types
A multiparadigm language
Object oriented
Protocol oriented
Functional
Generic purpose
Fast
Swift interoperability
Using Objective-C in Swift
Setup
The application target
The framework target
Calling Objective-C code
Using Swift in Objective-C
Features of Swift that are not available in Objective-C
Performance – meaning and key metrics
Everyday code performance
The importance of performance
The key metrics
Summary
2. Making a Good Application Architecture in Swift
Making a Swift application
The differences between variables and constants
Immutability
Multithreading
Value types and immutability
Reference types
Value types
The power of structures
Representing the state with classes
Representing the absence of values with optionals
Optional and non-optional types
Safe nil handling
Using optionals
Wrapping up on optionals
Functional programming
Function types
Splitting the code
The closure expression
Type inference
Implicit return type
Shorthand argument names
Trailing closure syntax
The standard library
The map method
map for optionals
The reduce method
The filter method
Generics
Generic functions
Type constraints
The generic type and collections
Safety
Dangerous operations
Summary
3. Testing and Identifying Slow Code with the Swift Toolkit
REPL
Playgrounds
Interactive documentation
The folder structure
The source folder
Resources
Pages
XCPlayground
LLDB
REPL in Xcode
Console logs
Performance measuring in unit tests
Instruments
A reminder
Summary
4. Improving Code Performance
Understanding performance optimization
Explicit
Implicit
Optimization checklist
Swift code compilation
Constants and variables
Method calls
Functions and methods
Global functions
Type methods
Static methods
Instance methods
Comparing function speed
Functions and methods usage summary
Intelligent code
Dangerous functions
Console print
Removing print logs
Comment out
Using build configurations
Using nonoptimizable constants
Improving speed
Final
Inline functions
Value objects and reference objects
Memory allocation
Swift arrays and unsafe C arrays
Function parameters
Creating a pointer to an existing variable
Allocating memory for the pointer
Comparing Swift arrays with unsafe C arrays
A summary of working with pointers
Avoiding Objective-C
Avoiding exposing Swift to Objective-C
Dynamic
A summary of avoiding Objective-C
Summary
5. Choosing the Correct Data Structure
An overview of data structures
Collection types
Swift standard library collections
Arrays
Using arrays
Fast operations
Slower operations
Search
Sort
Sets
Using sets
Set operations
Dictionaries
Collection memory allocation
Empty
Reserve capacity
Default values
The CollectionType protocol methods
Protocol extensions
Accelerate and Surge
Other collections
Summary
6. Architecting Applications for High Performance
Achieving high performance
Device architecture
Concurrency overview
Threads
Thread complexity
Solution for threads
GCD
Queues
Main queues
Concurrent queues
Own queues
Tasks
Adding tasks to the queue
Synchronous dispatch
Asynchronous dispatch
Operation queues
Designing asynchronous code
Avoiding state
Capture list
Immutable state
Divide and conquer
Controlling the lifetime
Applying the @autoclosure and @noescape attributes
@autoclosure
@noescape
@autoclosure (escaping)
Summary
7. The Importance of Being Lazy
The lazy mindset
Separation
Do work on demand
Approximate results
Lazy loading
Global constants and variables
Type properties
Lazy properties
Computed properties
Lazy collections and evaluation
Sequences and collections
Sequences
Collections
Implementing our own sequence and collection
Using lazy
Using the lazy sequence
Using a lazy collection
Summary
8. Discovering All the Underlying Swift Power
How Swift is so fast
Swift command line tools
xcrun
The Swift compiler
swift
swiftc
The Swift compilation process and swiftc
Swift AST
SIL
LLVM IR
Other swiftc options
Analyzing executable files
Summary
Final thoughts
Index
- 中国资本市场:重塑生态链(吴晓求 等)
- 不要在草台班子里拼命努力(HCJ)
- 人机对话系统(曹均阔,陈国莲)
- 未解之谜(下)(百读)
- 2020年江西省军转干部安置考试《法律基础知识》考点手册(圣才电子书)
- 永无止尽的狂热:三岛由纪夫(杨照)
- 五灯会元校注(第二册)(曾琦云 校注)
- 葛冰动物童话·飞熊“佐罗”(葛冰)
