Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Paul Hudson

Learn to make web apps with real-world Swift projects

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
# Server-Side Swift (Paul Hudson) - Reading Guide ## 【One-Line Pitch】 A hands-on, project-driven introduction to building web applications with Swift using the Kitura framework, perfect for iOS developers who want to apply their Swift skills to server-side development. ## 【Book Arc】 - **Opening (~0%–10%)**: Environment setup and Swift fundamentals. The author establishes a "learn by doing" philosophy, walks through installing Swift on Ubuntu, macOS, or Docker, and provides a quick primer on Docker containers for consistent development environments. - **Early (~10%–23%)**: Core Swift language essentials. Covers variables, type safety, strings, conditionals, loops, optionals, enums, and classes—the building blocks needed before touching any server code. - **Early (~23%–32%)**: First Kitura web server. Introduces routing, HTTP handlers, and the request-response cycle, then moves into Stencil templating for dynamic HTML pages with conditions and filters. - **Middle (~39%–48%)**: JSON APIs and CouchDB integration. Shifts from server-rendered templates to JSON-based APIs, teaching NoSQL database operations (CRUD) via both curl commands and Swift code, plus URL parameter handling. - **Late (~48%+)**: Advanced API patterns and homework. Covers URL encoding issues, response formatting, and provides practice exercises for building delete endpoints, alternative voting routes, and web front-ends. ## 【Key Takeaways】 - **Learn by building, not just reading** (Opening): The author's core philosophy is that real skill comes from typing code yourself, not passive study—each project is designed to be completed with minimal friction while teaching specific concepts. - **Type safety prevents entire classes of bugs** (Early): Swift's strict typing catches errors at compile time rather than runtime, which is especially valuable in server code where failures affect all users, not just one app session. - **Optionals force explicit handling of missing values** (Early): Swift's optional system eliminates the "magic number" problem (like -1 for "not found") by making the absence of a value explicit and requiring unwrapping before use. - **Kitura's run() blocks until server termination** (Early): Understanding that the server runs indefinitely is crucial—your app appears to "do nothing" but is actually listening for requests, which is the expected behavior for web servers. - **Routing maps URLs to code cleanly** (Early): Kitura's router pattern with get() and post() methods makes URL handling readable and maintainable, with parameters like :name enabling dynamic routes. - **Stencil templates separate logic from presentation** (Early): Template tags ({% %}) and value printing ({{ }}) let you build dynamic HTML without embedding Swift code in views, with built-in filters for common transformations. - **CouchDB skills transfer across platforms** (Middle): Learning NoSQL via curl commands first builds understanding that applies beyond Swift—the same database skills work with PHP, React, Rails, or any other web stack. - **URL encoding requires manual handling** (Middle): Kitura doesn't automatically decode plus signs in URL parameters, so you need custom cleanup functions—a common real-world gotcha in API development. ## 【Reading Tips】 - **Skim the Swift fundamentals if you're experienced** (Early): Chapters on variables, loops, and classes are standard Swift material—skip ahead if you've built iOS apps, but don't skip the optionals section if you're rusty. - **Deep-read the Kitura setup sections** (Early): The Docker configuration and first server setup are the most error-prone parts—follow these carefully to avoid port conflicts and environment issues. - **Do the CouchDB exercises with curl first** (Middle): The author deliberately teaches database operations outside Swift to build mental models—actually running these commands makes the later Swift integration much clearer. - **Watch for the "REALLY BIG WARNING"** (Early): Running Docker and Xcode simultaneously causes port conflicts—this practical advice saves debugging time. - **Complete the homework projects** (Late): The wrap-up exercises (delete endpoint, alternative voting, web front-end) consolidate everything into a cohesive skill set. ## 【Coverage Limits】 This guide covers the sampled portions (approximately the first half of the book). Later chapters on advanced topics, additional frameworks, or production deployment are not represented in the available excerpts. ##
Page 8
le. The best way to get in touch is on Twitter @twostraws, but you can also email paul@hackingwithswift.com. Xcode, Swift and Kitura I'm not going to talk mu...
View in text
Excerpt 2
"check for touches, animate robots, draw screen, check for touches…" and so on, until eventually the user taps a button to exit the game and go back to the m...
View in text
Excerpt 3
come to Kitura”. www.hackingwithswift.com 111 import Kitura import HeliumLogger import LoggerAPI HeliumLogger.use() let router = Router() router.get("/") { r...
View in text
Excerpt 4
t json = JSON(result) response.status(.OK).send(json: json) Build and run the server, then try visiting http://localhost:8090/polls/list in your web browser...
View in text
Excerpt 5
ed value containing the keys you want returned. Cunningly, the definition of the array inside .keys is different on macOS on Linux, and the only way to make...
View in text
Excerpt 6
ngwithswift.com 236 2. /path/to/world.jpg 3. /path/to/swift.png After running the map() code above, the stringArray result would contain the following three...
View in text
Excerpt 7
json = JSON(result) do { try response.status(.OK).send(json: json).end() } catch { Log.warning("Failed to send /post for \(username): \ (error.localizedDescr...
View in text
Excerpt 8
three groups. First, “/” is available to everyone, whether or not they have authenticated. Second, “/signup” is available to users who have authenticated usi...
View in text
Tags
AI categories
ProgrammingswiftBackend
Publish Year: 2018
Language: English
Pages: 434
File Format: PDF
File Size: 10.9 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…