Swift on the Server. WTF.
Tags: backend, beginners, swift, server
Published: 2019-09-26 20:52:57

---
title: Swift on the Server. WTF.
published: true
description: Swift on the Server. The time is now. 😈
tags: #backend #beginners #swift #server
cover_image: "https://thepracticaldev.s3.amazonaws.com/i/it0gngn2g9cs1mn4a34p.png"
---

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

<h1>What is a server?</h1>

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. <I>The sauce.</I>

<h1>Swift on the backend.</h1>
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.

<img src="https://thepracticaldev.s3.amazonaws.com/i/1cmppc0e5ylp3eg0pm9l.png"/>

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.

<h1>Swift Package Manager and Xcode 11.</h1>
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.

<I>Things are different now</I> 🥴

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) <p>#serverSideSwift</p>

<b>@thetealpickle on the internet. Namaste.</b>

<I>This article was brought to you by JESSICA JEAN JOSEPH © THETEALPICKLE</I>