DEV Community

Cover image for Swift on the Server. WTF.
✨ thetealpickle 📱
✨ thetealpickle 📱

Posted on

Swift on the Server. WTF.

Swift is an insidious fart that is slowly taking over the world and resistance is futile.

What is a server?

Server or Backend, two names for the same entity. Servers handle the interaction between an application and a database. The database stores the data. App platforms are designed to be able to communicate directly with databases. In many cases, i.e. an informational/read-only application, speaking directly to the database suffices. For other apps, a backend comes in clutch.

Having a backend insures your data goes through the same flow for all of your platforms (iOS, Android, Web, etc). Shifting the data processing to the backend allows the front end applications to be more lightweight and nimble. A backend can also centralize analytics across platforms, making data syncing more attainable while reducing duplicating/duplicate checking.

Cool, so we know what a server is and why it's pretty useful in most cases to create one. The sauce.

Swift on the backend.

As server languages stand the most popular options are Javascript and Python. For many web developers who are already using Javascript on the front-end leveraging their Javascript knowledge on the backend with node.js saves time. For cleaner coding practices and front-end platform uses beyond web, Python and its frameworks - typically Flask or Django, make it a more suitable option.

Server side Swift bring compiled language performance to a space which typically works with runtime languages. If close to native speed is needed, server side swift should be a consideration.

Swift as a language is elegant and nicely balances type safety and high level programming capabilities with approachability. If Swift is already being used on front-end applications, that Swift knowledge can be leveraged and applied to the backend side as well.

There are three main Server side Swift frameworks, Vapor, Kitura, and Perfect.

Swift Package Manager and Xcode 11.

The 2019 update of Xcode, Xcode 11, integrates Swift Package Manager within Xcode. Pre-Xcode 11, Cocoapods was the defacto dependency manager for Swift/Objc projects. The integration of a native swift package manager into Xcode increased my allure for Swift on the Server.

Things are different now 🥴

Often times models used within the Swift Server are copied from the iOS project. A swift package can be created with all 'central' models and entities and shared between the app and server. The added benefit of the package manager being integrated into Xcode assures that packages can be automatically configured to upgrade to the latest version, bug fix versions, or not upgrade at all, staying fixed on that one version.

Turn up the coding sun, things just became more D.R.Y (Don't Repeat Yourself)

#serverSideSwift

@thetealpickle on the internet. Namaste.

This article was brought to you by JESSICA JEAN JOSEPH © THETEALPICKLE

Top comments (0)