• Complain

Chris Eidhof - Advanced Swift

Here you can read online Chris Eidhof - Advanced Swift full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2017, publisher: objc.io, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Chris Eidhof Advanced Swift

Advanced Swift: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Advanced Swift" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

In this book, we write about advanced concepts in Swift programming. If you have read the Swift Programming Guide, and want to explore more, this book is for you. Swift is a great language for systems programming, but also lends itself for very high-level programming. Well explore both high-level topics (for example, programming with generics and protocols), as well as low-level topics (for example, wrapping a C library and string internals). Updated for Swift 4

Chris Eidhof: author's other books


Who wrote Advanced Swift? Find out the surname, the name of the author of the book and a list of all author's works by series.

Advanced Swift — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Advanced Swift" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Advanced Swift
Advanced Swift Chris Eidhof Ole Begemann Airspeed Velocity objcio 2017 Kugler - photo 1
Advanced Swift

Chris Eidhof

Ole Begemann

Airspeed Velocity

objc.io

2017 Kugler und Eidhof GbR
Introduction

Advanced Swift is quite a bold title for a book, so perhaps we should start with what we mean by it.

When we began writing the first edition of this book, Swift was barely a year old. We did so before the beta of 2.0 was released albeit tentatively, because we suspected the language would continue to evolve as it entered its second year. Few languages perhaps no other language have been adopted so rapidly by so many developers.

But that left people with unanswered questions. How do you write idiomatic Swift? Is there a correct way to do certain things? The standard library provided some clues, but even that has changed over time, dropping some conventions and adopting others. Over the past three years, Swift has evolved at a high pace, and it has become clearer what idiomatic Swift is.

To someone coming from another language, Swift can resemble everything you like about your language of choice. Low-level bit twiddling can look very similar to (and can be as performant as) C, but without many of the undefined behavior gotchas. The lightweight trailing closure syntax of map or filter will be familiar to Rubyists. Swift generics are similar to C++ templates, but with type constraints to ensure generic functions are correct at the time of definition rather than at the time of use. The flexibility of higher-order functions and operator overloading means you can write code thats similar in style to Haskell or F#. And the @objc and dynamic keywords allow you to use selectors and runtime dynamism in ways you would in Objective-C.

Given these resemblances, its tempting to adopt the idioms of other languages. Case in point: Objective-C example projects can almost be mechanically ported to Swift. The same is true for Java or C# design patterns. And monad tutorials appeared to be everyones favorite blog post topic in the first few months after Swifts introduction.

But then comes the frustration. Why cant we use protocol extensions with associated types like interfaces in Java? Why are arrays not covariant in the way we expect? Why cant we write functor? Sometimes the answer is because the part of Swift in question isnt yet implemented. But more often, its either because theres a different Swift-like way to do what you want to do, or because the Swift feature you thought was like the equivalent in some other language is not quite what you think.

Swift is a complex language most programming languages are. But it hides that complexity well. You can get up and running developing apps in Swift without needing to know about generics or overloading or the difference between static and dynamic dispatch. You may never need to call into a C library or write your own collection type, but after a while, we think youll find it necessary to know about these things either to improve your codes performance, to make it more elegant or expressive, or just to get certain things done.

Learning more about these features is what this book is about. We intend to answer many of the How do I do this? or Why does Swift behave like that? questions weve seen come up on various forums. Hopefully, once youve read our book, youll have gone from being aware of the basics of the language to knowing about many advanced features and having a much better understanding of how Swift works. Being familiar with the material presented is probably necessary, if not sufficient, for calling yourself an advanced Swift programmer.

Who Is This Book For?

This book targets experienced (though not necessarily expert) programmers such as existing Apple-platform developers, or those coming from other languages such as Java or C++ who want to bring their knowledge of Swift to the same level as that of Objective-C or some other language. Its also suitable for new programmers who started on Swift, have grown familiar with the basics, and are looking to take things to the next level.

The book isnt meant to be an introduction to Swift; it assumes youre familiar with the syntax and structure of the language. If you want some good, compact coverage of the basics of Swift, the best source is the official Apple Swift book (available on iBooks or on Apples website). If youre already a confident programmer, you could try reading our book and the Apple Swift book in parallel.

This is also not a book about programming for macOS or iOS devices. Of course, since Swift is currently mainly used on Apple platforms, weve tried to include examples of practical use, but we hope this book will be useful for non-Apple-platform programmers as well. The vast majority of the examples in the book should run unchanged on other operating systems. The ones that dont are either fundamentally tied to Apples platforms (because they use iOS frameworks or rely on the Objective-C runtime) or only require minimal changes, such as replacing the BSD-specific function we use to generate random numbers with a Linux equivalent.

Themes

Weve organized the book under the heading of basic concepts. There are in-depth chapters on some fundamental basic concepts like optionals or strings, and some deeper dives into topics like C interoperability. But throughout the book, hopefully a few themes regarding Swift emerge:

Swift is both a high- and low-level language. Swift allows you to write code similarly to Ruby and Python, with map and reduce, and to write your own higher-order functions easily. Swift also allows you to write fast code that compiles directly to native binaries with performance similar to code written in C.

Whats exciting to us, and whats possibly the aspect of Swift we most admire, is that youre able to do both these things at the same time. Mapping a closure expression over an array compiles to the same assembly code as looping over a contiguous block of memory does.

However, there are some things you need to know about to make the most of this feature. For example, it will benefit you to have a strong grasp on how structs and classes differ, or an understanding of the difference between dynamic and static method dispatch. Well cover topics such as these in more depth later on.

Swift is a multi-paradigm language. You can use it to write object-oriented code or pure functional code using immutable values, or you can write imperative C-like code using pointer arithmetic.

This is both a blessing and a curse. Its great, in that you have a lot of tools available to you, and you arent forced into writing code one way. But it also exposes you to the risk of writing Java or C or Objective-C in Swift.

Swift still has access to most of the capabilities of Objective-C, including message sending, runtime type identification, and key-value observation. But Swift introduces many capabilities not available in Objective-C.

Erik Meijer, a well-known programming language expert, tweeted the following in October 2015:

At this point, @SwiftLang is probably a better, and more valuable, vehicle for learning functional programming than Haskell.

Swift is a good introduction to a more functional style through its use of generics, protocols, value types, and closures. Its even possible to write operators that compose functions together. The early months of Swift brought many functional programming blog posts into the world. But since the release of Swift 2.0 and the introduction of protocol extensions, this trend has shifted.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Advanced Swift»

Look at similar books to Advanced Swift. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Advanced Swift»

Discussion, reviews of the book Advanced Swift and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.