In a significant development for the Swift server-side development community, Vapor, the popular framework, is gearing up for a major update with the upcoming release of Vapor 5. Scheduled to coincide with the official launch of Swift 6, Vapor 5 aims to harness the full potential of Swift 6’s concurrency capabilities and pave the way for a more structured and efficient framework. This news comes from InfoQ, with insights provided by Sergio De Simone, translated by Pingchuan, and curated by Ding Xiaoyun.
Since the release of its current version over four years ago, the team behind Vapor has been diligently working on laying the groundwork for Vapor 5, ensuring it can fully leverage Swift 6’s features. The primary objective of Vapor 5 is to support native APIs that are fully structured for concurrency, adopting more modern packages within the Swift ecosystem, and completely rewriting the WebSocket and MultipartKit APIs. This marks a significant departure from the EventLoopFuture model introduced in Vapor 3, which served as the foundation for the async/await API in Vapor 4. Instead, Vapor 5 will embrace structured concurrency from the get-go, completely phasing out EventLoopFuture. This move simplifies code reasoning and enhances Xcode’s advanced structured concurrency diagnostics.
Vapor 5 will also integrate popular third-party libraries that have gained traction in recent years. Among these are Swift Service Lifecycle, a library for managing service startup and shutdown; Swift HTTP Types, which provides a common representation for HTTP requests and responses; and a new HTTP server based on Hummingbird, supporting gRPC, asynchronous request/response body streaming, and Server-Sent Events (SSE). Furthermore, Vapor 5 will transition to Swift Foundation, a lightweight foundational layer that replaces the Foundation API available on iOS and macOS. This ensures consistent behavior across all platforms and minimizes confusion for multi-platform developers.
A notable aspect of Vapor 5 is the introduction of new WebSocket and MultipartKit API implementations. The current MultipartKit implementation has a significant limitation in that it does not support streaming of multipart request/response bodies, making it challenging to handle large files or APIs like NIOFileSystem. The new implementation in Vapor 5 will address this issue. Similarly, the current WebSocket API has been difficult to use in the async-await domain, and the updated version will provide a more user-friendly API.
Vapor comprises four main components: a core package for handling routing, JSON encoding/decoding, and managing HTTP requests; Fluent, which enables developers to create data models using noSQL databases; JWT, for creating and verifying JSON Web Tokens in Swift; and Leaf, a template engine that generates HTML from a simple syntax. With over 24k stars on GitHub and nearly 250 contributors, Vapor stands out as the go-to option for building HTTP web applications or APIs in Swift.
The early release of Vapor 5 will align with the launch of Swift 6, primarily focusing on delivering a pure asynchronous stack and removing all EventLoopFuture APIs. This move towards structured concurrency and modernization is anticipated to enhance the developer experience and further solidify Vapor’s position as a leading framework for Swift server-side development.
For more information and updates on Vapor 5, readers are encouraged to visit the original InfoQ article at https://www.infoq.com/news/2024/09/swift-vapor-5-roadmap/. This article has been translated by InfoQ, and readers are reminded that reproduction without permission is prohibited. Stay tuned for further developments in the world of Swift server-side development.
Views: 0