30,99 €
Write and run Swift language programs in the Cloud Written by the team of developers that has helped bring the Swift language to Cloud computing, this is the definitive guide to writing and running Swift language programs for cloud environment. In Swift in the Cloud, you'll find full coverage of all aspects of creating and running Swift language applications in Cloud computing environments, complete with examples of real code that you can start running and experimenting with today. Since Apple introduced the Swift language in 2014, it has become one of the most rapidly adopted computer programming languages in history--and now you too can start benefitting from using the same programming language for all components of a scalable, robust business software solution. * Create server applications using Swift and run them on pay-as-you-go cloud infrastructure * Quickly write and test Swift code snippets in your own cloud sandbox * Use Docker containers to deploy Swift applications into multiple cloud environments without having to change code * Grasp the elements and structure of the Swift.org open technology project * Find out how to avoid the complexities of runtime configuration by using Cloud Foundry buildpacks for Swift * Build high performing web applications and REST APIs with an open source Swift based web server framework * Scale up your cloud services by running Swift modules in an asynchronous, open source, 'serverless' cloud environment Whether you are already using Swift to build mobile applications or a seasoned web developer, Swift in the Cloud will help you leverage server-side Swift to power your next generation of applications.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 326
Veröffentlichungsjahr: 2017
Leigh WilliamsonJohn PonzoPatrick BohrerRicardo OlivieriKarl WeinmeisterSamuel Kallner
Swift™ in the Cloud
Published byJohn Wiley & Sons, Inc.10475 Crosspoint BoulevardIndianapolis, IN 46256 www.wiley.com
Copyright © 2017 by IBM Corporation. All rights reserved.
The following terms are trademarks or registered trademarks of IBM Corporation in the United States, other countries, or both: IBM, the IBM Press logo, DB2, AIX, WebSphere, Rational, IBM MobileFirst, Bluemix, z/OS, z Systems, IBM LinuxONE, CICS, and IMS. Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. Other company, product, or service names may be trademarks or service marks of others. A current list of IBM trademarks is available on the web at “copyright and trademark information” as www.ibm.com/legal/copytrade.shtml.
Published by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-119-31937-5
ISBN: 978-1-119-36853-3 (ebk)
ISBN: 978-1-119-36847-2 (ebk)
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or website may provide or recommendations it may make. Further, readers should be aware that Internet websites listed in this work may have changed or disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2017946220
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Swift is a trademark of Apple, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.
Karl would like to dedicate this book to his supportive wife, Samantha, and their crazy kiddos, who still gave him enough time to write.
Leigh dedicates this book to his wife, Cheryl, always his compass through life, and his daughter, Claire, the light of his life.
Leigh Williamson is an IBM Distinguished Engineer who has been working in the company’s Austin, Texas lab since 1989, contributing to major software projects for IBM, including OS/2, DB2, AIX, Java, WebSphere, Rational, and MobileFirst products. He is currently leading a cross-disciplinary team of IBM Cloud Consultants who assist clients with cloud computing strategy and execution. Leigh is an active mentor and leader in the IBM technical community, working with international mentees; working in the Advanced Technical Eminence program; leading multiple patent brainstorming teams; publishing technical blogs and articles; conducting external broadcast webinars; and speaking at IBM and non-IBM conferences.
This is the fourth IBM Press book on which Leigh has collaborated over the past 15 years, with works covering Java standards, WebSphere Application Server, and enterprise-class mobile application development. He holds a B.S. in Computer Science from Nova University and an M.S. in Computer Engineering from The University of Texas at Austin.
You can follow Leigh on Twitter at @leighawillia. His LinkedIn address is https://www.linkedin .com/in/leigh-williamson-9048654.
John Ponzo is an IBM Fellow and Chief Technology Officer for Mobile who has shaped the future of IBM business in mobile computing and delivered innovative products and services to web browser and server-based standards. He is a pioneer in technology that promotes end-user interaction through mobility, web programming, web application middleware, and software tools. John led the development of key software technologies including HTML/JavaScript runtime libraries, XML middleware, web services runtime libraries, Eclipse Web Integration, and Web 2.0 enterprise collaboration services. He also authored the “Enterprise Mobile” and the “Mobile First” theses that are the cornerstone of mobile strategy and execution at IBM. John also serves as the IBM technology ambassador to Kenya.
John is the primary technical collaborator between Apple and IBM in the effort to define and enhance the Swift programming language for both mobile client development and cloud services development.
Patrick Bohrer is a Distinguished Engineer in the IBM Cloud division. His responsibilities include serving as the technical lead for the company’s global efforts around Swift@IBM (developer.ibm .com/swift). He formerly served as the technical lead of the Mobile Innovation Lab in Austin, Texas. Patrick also helped lead IBM Research’s Mobile Research agenda after co-leading the 2012 Global Technology Outlook topic entitled “Mobile First,” which helped set the technical direction for current mobile and cloud efforts at IBM. Patrick received a B.A in Computer Science from The University of Texas at Austin.
Karl Weinmeister is the Program Director for Swift@IBM Engineering, based in Austin, Texas. He is passionate about improving people’s lives and experiences with technology. In his role, he has helped to enable Swift to extend from its mobile roots to become a full-stack language ecosystem.
Previously, Karl led engineering for the IBM Mobile Innovation Lab. He is a diehard Duke basketball fan and enjoys spending time with his family.
Ricardo Olivieri is a Senior Software Engineer at Swift@IBM Engineering. His areas of expertise include gathering and analyzing business requirements, architecting, designing, and developing software applications. Ricardo has extensive experience in the complete software development cycle and related processes, especially in Agile methodologies.
Ricardo has several years of experience in Java development as well as in Groovy, Perl, and Python development, with a strong background in back-end (server-side, business logic, SQL, and NoSQL databases) and front-end development. Several years ago, Ricardo added Business Process Manager (BPM) design and development to his skill set, which allowed him to assume the role of BPM consultant and developer using IBM Business Process Manager. While working at the Mobile Innovation Lab, Ricardo gained valuable skills and knowledge in the iOS and Android ecosystems.
Ricardo is now mainly focused on the adoption of the Swift language on the server and the IBM cloud, Bluemix. He has a B.S. in Computer Engineering from the University of Puerto Rico, Mayagüez Campus.
Samuel (Shmuel) Kallner is a Senior Technical Staff Member in the Smart Client Platforms group at the IBM Research Lab in Haifa, Israel. He is currently the Technical Lead of the Kitura project. Shmuel has over thirty years of experience at IBM working on a wide variety of projects including mobile apps, web-based end-user application development environments, mobile app developer tools, both sides of client-server–based applications, and more.
Matthew Perrins is a Senior Technical Staff Member working on IBM Cloud Developer Services in Austin, Texas. Matt is one of the architects for the company’s production-ready public Cloud Developer Experience on Bluemix—the IBM cloud platform. He is focused on making it very easy to develop and deploy mobile, web, and digital channel applications with the IBM cloud, and to integrate them with world-class leading runtimes for Swift, Node.js, and Java. Matt has been leading the IBM cloud teams in the evolution to true DevOps continuous delivery with cloud-native architectures, and driving that integration into the IBM Bluemix user experience.
Matt has spent a significant part of his career building systems-of-record and systems-of-engagement solutions using IBM technologies with IBM clients. He understands developers, user experiences, transactions, and cognitive solutions and how to deliver them at scale on the IBM cloud.
Executive Editor
Jim Minatel
Project Editor
Adaobi Obi Tulton
Technical Editor
Matthew Perrins
Production Editor
Dassi Zeidel
Copy Editor
Marylouise Wiack
Production Manager
Katie Wisor
Manager of Content Development and Assembly
Mary Beth Wakefield
Marketing Manager
Christie Hilbrich
Professional Technology & Strategy Director
Barry Pruett
Business Manager
Amy Knies
Project Coordinator, Cover
Brent Savage
Proofreader
Nancy Carrasco
Indexer
Johnna VanHoose Dinse
Cover Designer
Wiley
Cover Image
© fishbones/Getty Images
Many thanks to everyone at Wiley Publishing for their outstanding work on this project: to Jim Minatel for encouraging us to take this book concept forward and for yet again supporting the realization of a book that engages in deeper learning; to Adaobi Obi Tulton, the project editor, for driving this project to completion in the most efficient way possible—it was a real pleasure to work with such an accomplished and adept editor; to Marylouise Wiack, the copy editor, for translating this book into readable prose; and to Dassi Zeidel, the production editor, for bringing everything together to create a final, polished product.
Sincere thanks go to Matthew Perrins, the technical editor, for the incredible amount of work and personal time he selflessly put into ensuring that the content in this book can be utilized seamlessly by readers. Also, thanks to Steven Stansel, who was instrumental in formulating the original concept and proposal for the book. Brian White Eagle provided invaluable assistance with peering over the horizon in Chapter 9. And Shereen Ghobrial contributed the bulk of the mainframe-related content.
The biggest thank-you must, of course, go to our own families. This book was written over six months, predominantly at night and over weekends and holidays. In addition to sharing us with extremely demanding full-time jobs, our families made further sacrifices to enable us to spend time on this project.
About the Authors
About the Technical Editor
Credits
Acknowledgments
Introduction
IBM, Apple, and Swift
Scope of This Book
Chapter 1 Swift.org, the Open Source Project
What’s Included
How to Get Involved
Swift Evolution and Roadmap
Binary Downloads
Summary
Notes
Chapter 2 A Swift Sandbox in the Cloud
The IBM Cloud Platform
Getting Started
IBM Swift Package Catalog and Sandbox
Summary
Chapter 3 A Basic Introduction to Swift
Background
Let’s Get Coding!
The Language Landscape
Language Timeline
Summary
Chapter 4 The IBM Bluemix Buildpack for Swift
Cloud Foundry Buildpacks
Working with the IBM Bluemix Buildpack for Swift
Examples of Using the IBM Bluemix Buildpack for Swift
Using the Latest Code of the IBM Bluemix Buildpack for Swift
Summary
Chapter 5 Using Containers on Bluemix to Run Swift Code
Docker Images for Swift
Installing Docker
Using Docker as a Development Tool
Why Use Containers on Bluemix?
Running Your Docker Image in the Bluemix Cloud
High Availability in Kubernetes Clusters
Binding Bluemix Services to IBM Containers
Summary
Chapter 6 Swift Package Management
Swift Package Manager
Swift Package Catalog
Summary
Chapter 7 Swift and Kitura for Web Applications
Kitura
Kitura and Data Access
Summary
Notes
Chapter 8 Serverless Programming with Swift
Microservices and Serverless Computing
Swift and OpenWhisk
Summary
Chapter 9 Over the Horizon: Where Do We Go from Here?
Bringing Swift to the Server
Expanding the Range of Swift
Swift DevOps
Summary
EULA
Chapter 7
TABLE 7-1
Introduction
Figure 1:
Popularity of the Swift programming language
Figure 2:
Benefits of Swift compared with other languages
Figure 3:
An overview of IBM involvement in major programming language evolution
Figure 4:
Comparison of client and server elements for Swift
Figure 5:
End-to-end Swift development
Chapter 1
Figure 1-1:
One of the Swift.org source repositories
Figure 1-2:
Email list signup page for the Swift General Interest group
Figure 1-3:
Sign-up web page for a Swift JIRA bug-tracking account
Figure 1-4:
Swift.org bug-tracking dashboard and login page
Figure 1-5:
Swift.org bug tracking—what would you like to do now?
Figure 1-6:
Swift.org bug-tracking Projects list
Figure 1-7:
Swift.org bug tracking, showing a list of Kanban boards
Figure 1-8:
Swift.org bug tracking, showing the Kanban board for all projects
Figure 1-9:
Swift Toolchain Installer showing signature detail
Chapter 2
Figure 2-1:
IBM Bluemix cloud platform login page
Figure 2-2:
Typical Bluemix cloud platform user dashboard
Figure 2-3:
IBM Bluemix catalog cloud infrastructure services view
Figure 2-4:
Partial list of boilerplate cloud application templates in Bluemix catalog
Figure 2-5:
List of DevOps development tools available in Bluemix catalog
Figure 2-6:
List of Data and Analytics services available in Bluemix catalog
Figure 2-7:
Watson Cognitive application services shown in Bluemix catalog
Figure 2-8:
Application Services available in the Bluemix catalog
Figure 2-9:
Swift “Hello world!” program shown in the Swift Sandbox
Figure 2-10:
Loading sample Swift code into the Sandbox
Figure 2-11:
Signing in to the Swift Sandbox
Figure 2-12:
Saving your code in the Swift Sandbox
Figure 2-13:
Share your code from the Swift Sandbox
Figure 2-14:
Accessing your saved code from within the Swift Sandbox
Figure 2-15:
Reloading your saved code in the Swift Sandbox
Figure 2-16:
Selecting the version of Swift to use for the Sandbox
Figure 2-17:
Running your Swift Sandbox code on a mainframe computer
Figure 2-18:
Swift Package Catalog page for the HeliumLogger package
Figure 2-19:
Try a Swift package in the Swift Sandbox
Figure 2-20:
Swift package and its sample loaded into the Swift Sandbox
Figure 2-21:
What’s new in the Swift Sandbox
Figure 2-22:
Providing feedback for the Swift Sandbox
Chapter 3
Figure 3-1:
A simple Swift program in the Swift Sandbox environment
Figure 3-2:
Swift code accessing C language libraries in the Swift Sandbox
Figure 3-3:
Swift concurrency demonstration in the Swift Sandbox
Figure 3-4:
Swift memory management example shown in the Swift Sandbox
Figure 3-5:
Swift language performance compared with other languages
Figure 3-6:
Swift memory usage measurement compared with other languages
Figure 3-7:
Swift language memory performance over time compared to other languages
Figure 3-8:
The timeline for Swift language evolution
Chapter 4
Figure 4-1:
GitHub repository for the IBM Bluemix buildpack for Swift
Figure 4-2:
Running Swift HelloWorld on Bluemix
Figure 4-3:
The Deploy to Bluemix button on the Swift HelloWorld application README file
Figure 4-4:
Deploying the Swift HelloWorld app using the Deploy to Bluemix button
Figure 4-5:
Bluemix DevOps Toolchain for the Swift HelloWorld app
Figure 4-6:
Swift HelloWorld app successfully deployed to Bluemix using the Deploy to Bluemix button
Figure 4-7:
Running Kitura Starter on Bluemix
Figure 4-8:
The Deploy to Bluemix button on the Kitura Starter application README file
Figure 4-9:
Deploying Kitura Starter using the Deploy to Bluemix button
Figure 4-10:
List of service offerings in Bluemix
Figure 4-11:
Landing page for the BluePic application
Figure 4-12:
The Deploy to Bluemix button on the BluePic application README file
Figure 4-13:
Deploying BluePic using the Deploy to Bluemix button
Figure 4-14:
Bluemix DevOps Toolchain for BluePic
Chapter 5
Figure 5-1:
Using your browser to access the Kitura Starter application running inside a Docker container
Figure 5-2:
The Kitura Starter application running inside a Kubernetes cluster
Figure 5-3:
Accessing the Kubernetes dashboard through the proxy agent
Figure 5-4:
List of secrets for the Kubernetes cluster, swift-cluster
Figure 5-5:
Secret details for the binding-kitura-object-storage secret
Chapter 6
Figure 6-1:
The Xcode developer tool with a generated Swift project open for editing
Figure 6-2:
The Popular Packages list from the IBM Swift Package Catalog
Figure 6-3:
A view of the JSON category on the IBM Swift Package Catalog
Figure 6-4:
Search Results for Kitura in the IBM Swift Package Catalog
Figure 6-5:
The package details page
Figure 6-6:
The Dependency Visualization view of the IBM Swift Package Catalog
Figure 6-7:
The Try in Sandbox button enables users to try out a package.
Figure 6-8:
Users can select from a variety of samples available.
Figure 6-9:
After selecting a sample, the user can run the code in the IBM Swift Sandbox.
Chapter 7
Figure 7-1:
The Kitura default root page
Figure 7-2:
Library’s main.swift shown in XCode
Figure 7-3:
API documentation for Kitura shown in XCode
Figure 7-4:
Adding a book to the library using curl
Figure 7-5:
Fetching all of the books in the library using curl
Figure 7-6:
Searching for books authored by Tester 2
Figure 7-7:
Retrieving books by id
Figure 7-8:
Retrieving a book with a non-integer id
Figure 7-9:
The library server crashing when an invalid id was sent in a request
Chapter 8
Figure 8-1:
Comparing monolithic application scaling with microservices scaling
Figure 8-2:
The basic OpenWhisk architecture
Figure 8-3:
The OpenWhisk service icon in the IBM Bluemix Catalog page
Figure 8-4:
The home page for the OpenWhisk service in IBM Bluemix
Figure 8-5:
The Develop page for OpenWhisk event-driven programming
Figure 8-6:
Click the Create an Action button to begin the process.
Figure 8-7:
Name your OpenWhisk action and select the Swift v3 execution runtime.
Figure 8-8:
Select the sample action template for your Swift OpenWhisk action.
Figure 8-9:
The OpenWhisk action editor window with Swift v3 source code
Figure 8-10:
The Invoking an Action web page for your Swift v3 OpenWhisk action
Figure 8-11:
The Invocation Console for your example Swift OpenWhisk action
Figure 8-12:
Change the input value to be sent to the action.
Figure 8-13:
Output displayed for another invocation of the Swift action
Figure 8-14:
Add print statements to the action source code.
Figure 8-15:
The Console output window showing debug print log data
Figure 8-16:
The button on the OpenWhisk home page for downloading the CLI
Figure 8-17:
The Bluemix web page to access the OpenWhisk CLI
Figure 8-18:
A graphical representation of the automated OpenWhisk action trigger
Figure 8-19:
Monitoring your OpenWhisk activity in the Bluemix console
Figure 8-20:
The expanded Activity Log view for automated OpenWhisk actions
Figure 8-21:
A graphical representation of the new sequence of multiple actions
Figure 8-22:
The Activity Log showing the echo action in the sequence of automated actions
Chapter 9
Figure 9-1:
The IBM Cloud Tools for Swift web page
Figure 9-2:
The Welcome screen for IBM Cloud Tools for Swift
Figure 9-3:
Switching between different IBM Bluemix organizations in ICT
Figure 9-4:
Selecting a new project in IBM Cloud Tools
Figure 9-5:
ICT view of a project—both client and server components
Figure 9-6:
Viewing the status of cloud deployment from ICT
Figure 9-7:
Monitoring the Swift cloud application from ICT
Figure 9-8:
Running both parts of an application—mobile app and cloud services
Figure 9-9:
Embedding live Swift code into a web page
Figure 9-10:
Architecture for Swift on System z
Cover
Table of Contents
About the Authors
vii
viii
ix
xi
xiii
xxiii
xxiv
xxv
xxvi
xxvii
xxviii
xxix
xxx
xxxi
1
2
3
4
5
6
7
8
9
10
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
31
33
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
70
71
72
73
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
117
119
120
121
122
123
124
125
127
128
129
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
175
176
177
178
179
180
181
182
183
184
185
186
187
189
190
191
192
193
194
195
196
197
198
200
201
203
204
205
206
208
211
212
213
214
215
216
217
218
219
Since Apple introduced the Swift programming language in 2014, it has become one of the most rapidly adopted computer programming languages in history. Programmers love the modern syntax used by Swift and the way it’s fun to develop code, similar to how they felt about Java a generation ago. Programming skills and experience in Swift are in high demand in the industry, with the promise of high salaries for those who invest the time to learn and practice the language.
Apple originally introduced Swift as an alternative language to Objective-C for developing iPhone, iPad, and macOS applications. The company has now expanded Swift into the realm of solutions for the Internet of Things, with support for tvOS (Apple TV) and watchOS (Apple Watch wearable devices). As illustrated in Figure 1, Swift is now one of the most popular open source projects and Swift frameworks such as Kitura are gaining ground quickly.
Figure 1: Popularity of the Swift programming language
At about the same time that Swift was first introduced, Apple and IBM formed a strategic partnership to produce innovative, industry-specific mobile applications for the Apple iOS ecosystem. IBM proceeded to embrace the Swift programming language and implemented over 100 mobile apps as part of this partnership. IBM engineers saw the value of Swift firsthand in these applications. The open source release of the Swift language in late 2014 began another chapter in the partnership, as IBM chose to invest in and support the cause of bringing the Swift language to the cloud as a result of the focus on server-side Swift environments.
Development of these applications highlights the critical, expanding role of server-side logic in powering these new experiences that users now take for granted. From syncing data across devices; to connecting people with friends and co-workers; to monitoring news and alerting us about new events based on our interests and activities; to providing cognitive insights into our applications; server-side logic is critical to creating truly brilliant apps. Now the ability to develop, debug, and deploy this logic in the same language used to create mobile experiences is a game changer for the development community.
This book, written by members of the development team at IBM who helped bring Swift to the cloud, covers everything you need to know about how to develop Swift programs that run in cloud environments. It combines technical information with the concepts that originally led to the development of the technology. This book provides plenty of examples of Swift language code, as well as a living website where a community consisting of the authors and other passionate Swift experts continues to discuss Swift and its future directions.
On July 15, 2014, IBM and Apple announced what was at the time a very surprising partnership, with the goal of transforming business applications by building mobile enterprise and industry-specific solutions for the Apple platform. This partnership was unexpected by most industry watchers and radically altered the enterprise mobile computing landscape.
The IBM offering that resulted from the Apple partnership is called MobileFirst for iOS. It focuses on enterprise and industry transformation by providing users with the latest features of the Apple platform and user design, coupled with the back-end data center integration required to reinvent the next generation of enterprise applications.
Key features of the IBM offering include large-enterprise–class robustness and scalability; back-end enterprise data center integration; big data and analytics integration; and a highly polished mobile front-end user interface experience.
The user interface experience was codesigned by Apple and IBM to significantly upgrade the standards for usability, elegance, and user satisfaction beyond typical enterprise software. Since 2012, IBM has been making massive investments in IBM Design Thinking philosophy and techniques, building up several large design studios in an effort to apply good design to business software. This software design emphasis by IBM was one of the natural collaboration areas of the partnership, with the strong Apple design culture being applied to all of their own products.
As IBM MobileFirst for iOS was being developed, a choice was made to use the latest iOS platform APIs for iPhone and iPad business applications. The scope was later extended to include Apple Watch. IBM leveraged many of the extended development kits provided by Apple, such as HomeKit, CloudKit, and the connected car capabilities in various new and innovative business solutions. As of December 2015, IBM had created over 100 industry-specific mobile apps for the IBM MobileFirst for iOS collection.
While Apple has pioneered the transformation of the consumer mobile app experience, IBM and Apple consider business mobile app transformation to be an underserved market and a really great design opportunity that they can uniquely address together.
Apple introduced the Swift language at the Apple World Wide Developers Conference (WWDC) in 2014, and IBM decided to begin using the language to build the first wave of IBM MobileFirst for iOS mobile applications. IBM assembled a team of developers with expertise in building mobile solutions. Their previous programming language skills included Java, JavaScript, and Objective-C. This team of IBM programmers quickly learned Swift and began using it to implement the mobile apps in the IBM MobileFirst for iOS collection.
Working with Apple, we at IBM learned a lot about what it takes to build amazing mobile business applications. IBM also discovered the value of Swift.
Swift was designed by Apple to be a safe, interactive, and high-performance systems language. It also blends the ease of scripting language syntax with the performance of a systems language. The IBM team found that in comparison to mobile apps developed in Java for the Android mobile platform and Objective-C for iOS, Swift apps required less code.
The IBM team appreciated everything about Swift, from its type safety—which empowered them to be agile and evolve the applications quickly while knowing that the compiler would catch any errors—to its performance and memory advantages, which are critical for application responsiveness. The concise syntax of the language also led to great developer productivity.
The IBM teams also learned to understand what is necessary to develop application-specific web services to power these business mobile applications. It significantly enhanced the overall productivity of the team to not have to switch languages away from what was used for the mobile front end (Swift) to work on the back-end services.
The developers found the Swift code easier to read, share, and evolve. What the Swift language did for legibility of the application code represented a large increase in productivity for the development team. Other languages used for mobile apps were generally more verbose. It also significantly increased code quality with Swift-based type checking. The importance of a strongly typed language in the productivity of the development team can hardly be overstated. Most of the more than 100 applications developed by IBM for various business solutions could be produced by a handful of programmers working in small teams.
Figure 2 shows a comparison of Swift with other programming languages and illustrates how Swift enables inherent application performance and developer productivity benefits through its attributes such as:
Modern programming language constructs
Error detection at compile time, not runtime
Code reengineering
Built-in performance features such as an optimized search algorithm that is up to 2.6 times faster than Objective-C and 8.4 times faster than Python 2.7
A compiled language with the benefits of an interpreted language
Figure 2: Benefits of Swift compared with other languages
These same benefits around ease of programming, type safety, and compiled performance are also desired on the server side of the applications. Until the release of Swift 3.0, Swift developers were forced to abandon their favorite language if they wanted to develop application logic that ran on the server. When Swift was made open source in 2015, IBM recognized the developer and business value that could be unlocked by bringing this language to the server and, by extension, to the cloud computing environment.
Swift is not just a programming language syntax, but also includes a robust compiler back-end infrastructure, based on the LLVM (originally named Low Level Virtual Machine) machine-independent intermediate code optimization. The compiler architecture includes debugging capability, read- eval-print loop (REPL) language statement interpretation, and distinct layers for binary code generation. This design of the language infrastructure is forward-looking and lends itself to flexible reuse of the basic language constructs. Swift is an up-to-date, modern programming language with support for closures, tuples, extensions, generics, type inference, custom operators, enumerations, and option types. Also, Swift execution performance is on par with modern native programming languages (that is, very fast).
Chapter 3 of this book covers the key aspects of the language in more detail, as well as information about performance and memory attributes that we found to be especially attractive relative to other languages.
The IBM team continued to be impressed with Swift as new and innovative ways to leverage it were discovered. IBM has a history of investing in programming languages for both the open technology community and enterprise business uses. We’ve learned that the wide adoption and enthusiastic embracing of a programming language by the open source community yields usage and success in greater orders of magnitude for a well-designed language whose time in the market is right.
The year 2015 seemed to be the right time for Swift, and the Swift programming language was released as open source in December 2015, where it continues to grow with the open source community through the Swift evolution process (https://swift.org/contributing/#participating-in-the-swift-evolution-process). By opening up the language to wider community support and development, Apple has ensured that Swift will enjoy robust language evolution with backwards compatibility.
With the open source release of Swift, IBM was inspired by past experiences to embrace the opportunity to bring this language to the cloud. IBM has a history of helping language communities to bring their languages to the business world. Figure 3 shows example timelines of IBM and open source community investment and evolution of the Java programming language and the Node.js JavaScript ecosystem.
Figure 3: An overview of IBM involvement in major programming language evolution
The open source community that supports and evolves Swift is named Swift.org (http://swift.org). This organization is supported by a broad range of contributors from dozens of major technology companies—including Apple, IBM, PayPal, and Dropbox—and educational institutions. The stated goal for Swift.org is to “develop the language in the open” with “public conversations … encouraged.” As in other open community projects, this transparent approach to managed technological evolution will produce much faster enhancements and a wider range of innovation than any one company can possibly deliver, no matter how large and wealthy.
Swift.org includes all the foundational components for the language, including the Swift compiler, standard library, package manager, core libraries, REPL, and debugger.
IBM is excited to be a part of the global Swift community and to bring our company’s expertise to the effort to take Swift to the cloud. Since the first day that Swift was available on the Swift.org community web pages, IBM has been releasing assets to support it. These have included the IBM Swift Sandbox, the Kitura web framework, the IBM Swift Package Catalog, IBM Cloud Tools for Swift, and over 85 new open source projects on GitHub. In this way, IBM has been working with the community to make Swift on the cloud possible on the server. This book provides an overview of these offerings and how they can be used to create amazing applications. Chapter 1 of this book provides greater details about Swift.org and the open source process that guides the development of the Swift programming language.
The release of Swift as an open source project provided developers with the possibility to run Swift code on “back-end” server machines. These are environments that IBM has focused on over many decades, and the company immediately began working on the development of the Swift ecosystem components that are necessary to support robust server-side applications.
Because Swift started as a client-side programming language, developers familiar with this language are already accustomed to the ecosystem of tools and libraries that surround Swift.
An underlying goal of supporting a programming language across both client and server environments is to enable developer mobility and productivity. Towards this end, we felt that the Swift ecosystem should be as common as possible across client and server. The Swift.org project has been supporting this goal of a common development ecosystem with the release of core libraries on Linux to match those found in Apple client environments. IBM has invested in the development of these libraries on Linux to help provide this consistent developer experience between the client and the cloud. Language support, along with availability of these core libraries, is important, but more is needed to fully leverage Swift on the cloud.
Client-side Swift developers are typically working on applications that include rich user interfaces, application data models, and network communication logic for a variety of cloud services. These client-side developers can rely on the base platform provided by Apple, along with a number of client-side packages that make it easy to do things like interacting with users, accessing local sensors and devices, client-side networking, and much more.
Likewise, server-side developers typically write applications called web services that interact with other back-end services or data sources on a network. Web service developers are typically writing code to listen for incoming network requests (from the client) and routing these requests to the appropriate back-end logic. This logic, in turn, might end up calling other network services, and finally the logic will respond to the incoming network request with a status code and optional payload. These server-side developers also require a base platform along with a rich set of packages. IBM has joined the greater Swift community to help build the server-side base platform as well as the surrounding packages needed to deploy Swift-based web services.
IBM is leading a new open source project called Kitura, which is a web application framework for Swift. Kitura leverages the core libraries of Foundation and libdispatch to provide a consistent development environment for client code programmers as well as cloud application developers. Kitura also includes a number of additional libraries needed on the server to deliver networking, security, and HTTP processing support. The Kitura platform also leverages many packages from the wider community to handle other server-side functions dealing with credentials, sessions, database communication, and much more.
With all of this included, web service developers can focus on writing great services knowing they can leverage Swift safety, performance, and tools that they learned and love from the client development ecosystem.
Figure 4 illustrates the Swift language client environment compared to the Swift environment for server and cloud hosted code. You can see from this illustration the drive towards a consistent Swift developer experience across both client and server environments.
Figure 4: Comparison of client and server elements for Swift
For developers to be successful and productive, they need to be empowered through a rich language ecosystem that can include open source projects as well as tools and platform capabilities that support and augment their workflow.
As the Swift ecosystem continues to grow, so too does the opportunity for an even more encompassing developer experience. A developer’s workflow includes performing local development of both client and server code; testing code snippets and asking questions about this code with the community; discovering and pulling in packages from the community; linking applications to dependent cloud services; and, finally, deploying and monitoring server code running in the cloud.
The Swift@IBM team has been working on tools to augment this developer workflow. These tools will be covered in more detail in this book. Figure 5 shows how a use case driven design ensured simplicity in the combined, integrated end-to-end developer experience.
Figure 5: End-to-end Swift development
