Extending Swift Value(s) to the Server

Book description

Swift quickly became the dominant language for iOS app development not long after Apple introduced the language in 2014. When Swift moved to open source, extending this modern language from client to server side became an option, and today, with Swift 3.0, companies can extend the value of Swift end-to-end. With this ebook, you’ll learn how to write your entire application in Swift—from mobile client to the middle tier to server-side database access.

Authors David Ungar and Robert Dickerson take you through Swift’s support for object-oriented, functional, and imperative programming, and then show you how to build a Swifty web service that interfaces with other services and databases. By demonstrating how Swift is related to Java and Javascript, two leading technologies currently used on clients and servers today, this ebook extends your repertoire of skills with one of today's most in-demand languages.

  • Learn how Swift produces clear and concise code, and prevents and detects bugs
  • Produce code for the client and server with a single uniform IDE
  • Reuse Swift abstractions and code on the client, server, and middle tier
  • Dive into asynchronous programming with Swift’s support for monads and futures
  • Use Swift’s optional types and structures to tell the compiler more about your program

Dr. David Ungar holds a research position at IBM in the Ubiquitous Platforms group within Cloud and Mobile Enterprise Research.

Robert F. Dickerson is a software engineer in the Swift@IBM Engineering group.

Publisher resources

View/Submit Errata

Table of contents

  1. Preface: Swift for the Rest of Your Application
    1. Acknowledgments
  2. 1. A Swift Introduction
    1. Types and Type Inference
    2. Syntax
    3. Simple Enumerations
    4. Tuples
    5. Custom Operators
    6. Closures
    7. Object Orientation
    8. Protocols Define Interfaces
      1. Generic Protocols
    9. Extending Classes, Structures, and Enumerations
  3. 2. Optional Types, Structures, & Enumerations
    1. Optional Types Exterminate Nil-Value Bugs
    2. Structures Isolate Mutation
      1. Mutating Methods
      2. Default Implementations with Protocol Extensions
    3. Enumerations with Associated Values
      1. Enumerations as Inside-Out Class Hierarchies
    4. Choosing an Aggregate
      1. Instantiate a Class for a Thing with an Identity
      2. Otherwise, Replace the Class with a Value Type
  4. 3. Swift Promises to Tame Asynchrony
    1. Step 1: Chaining Synchronous Errors
    2. Step 2: Linearizing Nested Callbacks
      1. Composing Asynchronous Operations
      2. Replacing Callbacks
    3. Step 3: Coping with Asynchronous Errors
      1. Promising Either Success or Failure
      2. Promises with Handy Shortcuts for Success Versus Failure
  5. 4. Swift Package Manager
    1. Semantic Versioning
    2. Creating an Application
    3. Importing a Library in Your Project
    4. Developing in Xcode
    5. Creating Your Own Library
      1. Sharing a Library with the Swift Community
    6. Producing More Complex Projects
    7. Using C Dynamic Libraries
  6. 5. Writing a To-Do List with Kitura
    1. Servers and Routers
    2. Creating a Web Service
    3. Deploying Your Application to Bluemix
    4. More Elaborate To-Do Items
      1. Start with a Dictionary
      2. Move to a Structure
    5. Adding Authentication
    6. Setting up the Database
    7. Connecting to the Database
  7. Conclusions

Product information

  • Title: Extending Swift Value(s) to the Server
  • Author(s): David Ungar, Robert Dickerson
  • Release date: February 2017
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491972137