LEIGH WILLIAMSON is a technical leader in the IBM Cloud team who aids clients with cloud computing strategy and execution. JOHN PONZO is an IBM Fellow and the primary technical collaborator between Apple and IBM in refining Swift for both mobile client and cloud services development. PATRICK BOHRER is technical lead for IBM's global efforts around Swift@IBM Engineering. RICARDO OLIVIERI is an expert in the adoption of the Swift language on the server and the IBM cloud. KARL WEINMEISTER helped extend Swift from its mobile roots to become a full-stack language ecosystem. SAMUEL KALLNER is technical lead of the Kitura project at the IBM Research Lab in Haifa, Israel.
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.
IBM, Apple, and Swift
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.
Introduction of Swift
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...