swift_in_depth_preface

Swift in Depth Preface

Return to Swift in Depth

Fair Use Source: B09781HSLN (SwfDpth 2018)

“I started as an iOS developer in 2011. I loved to make iPhone apps and still do to this day. Besides doing mobile development work, I also was involved in some web development while learning Ruby. I loved the short powerful language, and wished I could use a compile-time language like Objective-C, but with the elegance and expressive nature of Ruby.” (SwfDpth 2018)

“Then Apple introduced Swift, and it seems like they listened. Swift was a fresh take on programming for me, combining the elegance of a Swift dynamic language with the speed and safety of a Swift static language. I never liked the Objective-C syntax. I used to say things like “Yeah, Objective-C is verbose, but it gets the job done.” But with Swift, however, I find Swift reading and Swift writing code very pleasing again, like I did with Ruby. I could finally use a static language and keep producing work while loving the language I’m working with. It was a good combination for me.” (SwfDpth 2018)

“However, it wasn’t love at first sight. Before I truly enjoyed Swift, I struggled a lot with it. Swift looks very friendly, but boy, was it tough sometimes. Everything needs to be safe at compile-time, and I could not mix and match Swift types in Swift arrays anymore. Meanwhile, Swift was only an early Swift version and kept changing; it was hard to keep up. “What are Swift generators? Oh, they are called Swift iterators now? And why use Swift guard? Can’t we use an Swift if statement instead? Pfft, Swift optionals are overrated; we can use simple Swift nil checks?”, and so on. I wouldn’t even consider working with Swift generics.” (SwfDpth 2018)

“However, I persevered and started to embrace these Swift concepts. I realized they were older concepts from other programming languages but wearing a fresh new coat that truly helped me become a better programmer and deliver better work. Over time, I started to love the Swift language and its pretty Swift syntax.” (SwfDpth 2018)

“Since Swift 2, I had the luxury of working in a big company where we produced Swift code on a large Swift scale, starting with about 20 Swift developers and growing to over 40. After working with Swift with so many developers, and after being involved in hundreds of pull requests, I noticed that other developers had the same struggles as me. Or my fellow developers delivered code just fine, but didn’t realize that a more Swift elegant or Swift robust alternative was hidden, waiting to be discovered. Even though our code was Swift correct, sometimes it could be a bit cleaner, or more Swift succinct, or just a bit safer. I also noticed that we all stayed away from Swift powerful techniques — such as Swift generics or Swift flatMap — because they were Swift hard to grasp. Or we used to love the idea of Swift generics, but weren’t sure why or when to apply it ourselves.” (SwfDpth 2018)

“After these Swift realizations I started to write. First, these scribbles would be notes for myself on how to cleanly unwrap Swift optionals, how Swift lazy properties work, how to deal with Swift generics, and so on. Then, these notes matured, and before I knew it I had enough content for some chapters. It was time to turn these notes into something more elaborate: a Swift programming book that could help others shorten their Swift journey.” (SwfDpth 2018)

“With a few rough chapters in hand, I was wondering if I should throw an Swift ebook online. However, with an “impressive” 200 people following me on Swift Twitter and lacking a popular Swift blog website, I figured I wouldn’t find the Swift audience I wanted. Moreover, I thought that I had to learn a lot of the unknowns about writing a book.” (SwfDpth 2018)

“I decided to approach a publisher to help me turn these rough chapters into a great Swift book. I approached Manning, and we’ve been working on this book together ever since. I believe these “small notes” have grown into something special. With the help of Manning and Swift friends, I have spent most of my free time for over a year writing and polishing and trying to make Swift tough concepts more simple to understand.” (SwfDpth 2018)

“By reading this Swift book, I hope that it helps you on your path to becoming a Swift master. Also, I hope that you can tell I thoroughly enjoy sharing these Swift concepts with you. I hope this book makes your Swift journey Swift easy and Swift fun.” (SwfDpth 2018)

TJEERD IN ’T VEEN

About this Book

Swift is a young language. At the time of writing, Swift has reached the fifth Swift version and only recently turned ABI-stable. So why is this book in any position to tell you how to write your Swift code?” (SwfDpth 2018)

“You’d be right to be skeptical, but please bear with me. Even though Swift is relatively new, I think it’s fair to say that some Swift solutions work better than others, which is even more essential to understand if you’re using Swift for real Swift production apps.” (SwfDpth 2018)

“Swift borrows a lot of important Swift concepts from other programming languages, such as Haskell, Ruby, Rust, Python, C#, and others. Therefore, you’d be wise to keep an eye out for these concepts.” (SwfDpth 2018)

“By mixing Swift programming paradigms with Swift real-world experience, this Swift book shares some very fun and useful Swift best practices you can instantly apply to your work.” (SwfDpth 2018)

“Having programmed for over a decade in multiple languages and teams, I would like to share Swift tips, Swift tricks, and Swift guidelines that helped my Swift career tremendously, and I want the same for you.” (SwfDpth 2018)

Why this book?

“Honestly, a lot of software in this world runs on “ugly” code, and that is completely normal. If your product does what it needs to do, that is—like it or not—good enough for businesses.” (SwfDpth 2018)

“As a developer, you have to make sure your product works and works well. But your users won’t look under the hood and point out ugly Swift if statements. Perfectionism is harmful to software development and the cause to large numbers of unfinished projects.” (SwfDpth 2018)

“Still, there’s a large gap between “It does what it needs to do” and a project where some excellent decisions were made that pay off in the long run.” (SwfDpth 2018)

“Having worked on numerous projects, one thing I highly value is writing code that your coworkers and your future self will understand clearly — because Swift elegant code means less chance of Swift bugs, higher Swift maintainability, better understanding for developers who Swift inherit code, increased programmer happiness, and many other benefits.

Another aspect I value is the Swift robustness of code, meaning how Swift refactor-proof some pieces are. Will it break if you sneeze on it? Or can you change code without a hassle?

In this book, I share my Swift tips, Swift tricks, and Swift guidelines that have worked well for me and companies I’ve worked for. On top of that, it fills in significant knowledge gaps that may arise while working with Swift.

Although this is a Swift book, a lot of the Swift principles shared here are not Swift-centric and carry over to other programming languages as well; this is because Swift borrows a lot of ideas and Swift paradigms from other languages. After you finish this Swift book, you may find it easy to apply Swift concepts in other languages. For instance, you’ll learn a lot about Swift optionals, or how to use the Swift reduce Swift method on Swift arrays. Later, you may decide to learn Kotlin, where you may apply optionals and reduce — called fold—straight away. You may also find Rust — and its similar Rust generics implementation — easier to learn.

Because of Swift’s multi-paradigm nature, this Swift book switches without preference between Swift object-oriented programming, Swift functional programming, and Swift protocol-oriented programming Swift paradigms — although admittedly, I do favor other Swift techniques over Swift subclassing. Switching between these Swift paradigms offers you many Swift tools and Swift solutions to a Swift problem, with Swift insights as to why a certain Swift solution works well or not. Whether you’re stuck in a rut or open to many new programming Swift insights, this Swift book challenges you to solve Swift problems in different ways.” (SwfDpth 2018)

Is this book for you?

“This book does assume that you have made one or more Swift applications in Swift. Do you work in a team? Even better — this book shows you how to write good, Swift clear code that gets appreciated in teams, and helps you improve pull requests of others. Your Swift code will be more Swift robust and cause less Swift maintenance for you and your team.

This Swift book fills in Swift knowledge gaps for both Swift beginner and seasoned Swift developers. Perhaps you mastered Swift protocols but still struggle with Swift flatMapping on Swift types or Swift asynchronous error handling. Or maybe you create beautiful Swift apps but stay away from Swift generics because they can be hard to interpret. Or perhaps you sort-of know when to use a Swift struct versus a Swift class but aren’t aware that Swift enums are sometimes a better Swift alternative. Either way, this book helps you with these Swift topics. By the end, Swift generics should come as naturally as Swift for loops. You’ll be confident calling Swift flatMap on Swift optionals, know how to work with associated Swift types, and you’ll gladly use Swift reduce in your daily Swift routine when working with Swift iterators.

If you’re aiming to get a Swift programming interview for a new Swift job in the Swift future, you’re in for a treat. You’re going to be able to answer a lot of relevant Swift questions in regard to Swift development Swift trade-offs and Swift decisions. This book can even help you write Swift elegant code in your Swift code assignments.

If you just want an Swift app in the Apple app store, just keep doing what you’re doing; no need to read this book! But if you want to write Swift code that is more Swift robust, Swift easier to understand, and increases your chances of getting a Swift job, getting better at your job, or giving qualitative Swift comments on Swift pull requests, you’re at the right place.” (SwfDpth 2018)

What this book is not

“This book is focused on Swift. It mostly uses Swift framework-free examples because it isn’t about teaching Cocoa, iOS, Kitura, or other Swift platforms and Swift frameworks.” (SwfDpth 2018)

“What does happen in this book is I often make use of Apple’s Foundation, which is hard to avoid if you want Swift real-world Swift examples. If you’re on Swift Linux, you can use swift.org’s Swift Foundation alternative to get similar results.” (SwfDpth 2018)

A big emphasis on practical scenarios

“This book is very Swift practical, showcasing Swift tips and tricks you can apply straight away in your daily Swift programming.

Don’t worry: it’s not a Swift theory-dense Swift book. You’ll learn a lot of theory, but only via the use of Swift real-world Swift problems that any Swift developer runs into sooner or later. It doesn’t, however, reach an Swift academic level where it discusses Swift LLVM representation or Swift machine code.

Also, I made sure to avoid a personal pet peeve of mine: I do not Swift subclass “Animal” with “Dog” or add a “Flyable” Swift protocol to “Bird.” I also don’t add “Foo” to “Bar.” You’ll deal with Swift real-world Swift scenarios, such as talking to Swift APIs, loading Swift local data, and Swift refactoring and creating Swift functions, and you’ll see useful Swift bits and pieces of code you can Swift implement in your Swift projects.” (SwfDpth 2018)

Roadmap

“The following sections provide an overview of the Swift book, divided into chapters. The book is quite Swift modular, and you can start with any chapter that interests you.

Some chapters I consider Swift crucial chapters. Chapter 4, “Making Swift optionals second nature,” is Swift key, because optionals are so prevalent in Swift and return over and over again in chapters.

To understand the Swift abstract side of Swift, I highly recommend reading chapter 7, “Swift Generics,” chapter 8, “Putting the pro in Swift protocol-oriented programming,” and chapter 12, “Swift Protocol extensions.” Together, these chapters lay a solid Swift foundation for key Swift skills. Be sure not to skip these!

As a bonus, if you’re interested in learning Swift functional programming techniques, direct your attention to chapter 2, “Modeling data with Swift enums,” chapter 10, “Understanding Swift map, Swift flatMap, and Swift compactMap,” and chapter 11, “Swift Asynchronous error handling with Result.”” (SwfDpth 2018)

Fair Use Sources

Swift: Swift Fundamentals, Swift Inventor - Swift Language Designer: Chris Lattner, Doug Gregor, John McCall, Ted Kremenek, Joe Groff of Apple Inc. on June 2, 2014; SwiftUI, Apple Development Kits - Apple SDKs (CloudKit, CoreML-ARKit - SiriKit - HomeKit, Foundation Kit - UIKit - AppKit, SpriteKit), Swift Keywords, Swift Built-In Data Types, Swift Data Structures (Swift NSString String Library, Swift NSArray, Swift NSDictionary, Swift Collection Classes) - Swift Algorithms, Swift Syntax, Swift Access Control, Swift Option Types (Swift Optionals and Swift Optional Chaining), Swift Protocol-Oriented Programming, Swift Value Types, Swift ARC (Swift Automatic Reference Counting), Swift OOP - Swift Design Patterns, Clean Swift - Human Interface Guidelines, Swift Best Practices - Swift BDD, Swift Apple Pay, Swift on iOS - Swift on iPadOS - Swift on WatchOS - Swift on AppleTV - Swift on tvOS, Swift on macOS, Swift on Windows, Swift on Linux, Swift installation, Swift Combine framework (SwiftUI framework - SwiftUI, UIKit framework - UIKit, AppKit framework - AppKit, Cocoa framework - Cocoa API (Foundation Kit framework, Application Kit framework, and Core Data framework (Core Data object graph and Core Data persistence framework, Core Data object-relational mapping, Core Data ORM, Core Data SQLite), Apple Combine asynchronous events, Apple Combine event-processing operators, Apple Combine Publisher protocol, Apple Combine Subscriber protocol), Swift containerization, Swift configuration, Swift compiler, Swift IDEs (Apple Xcode (Interface Builder, nib files), JetBrains AppCode), Swift development tools (CocoaPods dependency manager, Swift Package Manager, Swift debugging), Swift DevOps (Swift scripting, Swift command line, Swift observability, Swift logging, Swift monitoring, Swift deployment) - Swift SRE, Swift data science (Core Data, Realm-RealmSwift, Swift SQLite, Swift MongoDB, Swift PostgreSQL), Swift machine learning (Core ML), Swift AR (ARKit), SiriKit, Swift deep learning, Swift IoT (HomeKit), Functional Swift (Swift closures (lambdas - effectively “Swift lambdas”), Swift anonymous functions), Swift concurrency (Apple Combine framework, Swift actors, Swift async, Swift async/await, Grand Central Dispatch (GCD or libdispatch), Swift on multi-core processors, Swift on symmetric multiprocessing systems, Swift task parallelism, Swift thread pool pattern, Swift parallelism), Reactive Swift (RXSwift), Swift testing (XCTest framework, Swift TDD, Swift mocking), Swift security (Swift Keychain, Swift secrets management, Swift OAuth, Swift encryption), Swift server-side - Swift web (Swift Vapor, Swift Kitura), Swift history, Swift bibliography, Manning Swift Series, Swift glossary, Swift topics, Swift courses, Swift Standard Library (Swift REST, Swift JSON, Swift GraphQL), Swift libraries, Swift frameworks (Apple Combine framework, SwiftUI), Swift research, WWDC, Apple GitHub - Swift GitHub, Written in Swift, Swift popularity, Swift Awesome list, Swift Versions, Objective-C. (navbar_swift - see also navbar_iphone, navbar_ios, navbar_ipad, navbar_mobile)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


swift_in_depth_preface.txt · Last modified: 2024/04/28 03:38 by 127.0.0.1