Hi there! I would like to start a discussion about the current state of Swift for Server. The real "for server" - No Darwin.
Why is it advertised as a language for servers if it barely has any tooling for actual server development? Let me show you the main issues.
-
Swift IDEs for Linux is a piece of work.
There aren't any Swift IDEs for Linux, so you have to use plugins. CLion, a very good IDE that works on Linux has a Swift plugin. The problem? It's not very good. A project of mine didn't even load at all, not even syntax highlighting. SourceKit-LSP is a thing, but it's still a WIP. There's no highlighting, no formatting. If you need any of those things, you'll have to download even more stuff (if it's available for platforms other than Darwin). -
Swift depends way too much on XCode.
Most Swift examples and packages depend on XCode. There's no XCode for Linux. This means that if you want to learn Swift and you don't own a device running iPadOS or macOS, you'll need to figure out everything by yourself. Reading tons of docs and code, even though you haven't ever used Swift before. -
There's no consistency with dependencies across platforms.
If you need a crypto module you can just useimport CryptoKit
on Darwin. However, if you're using Linux, you'll have to addapple/swift-crypto
to your dependencies and import it as Crypto. That's not very "wow", but if at some point you add support for both Darwin and Linux without compromising speed, you'll probably have to do something like this:
#if os(Linux)
import Crypto
import Glibc
#else
import CryptoKit
import Darwin
#endif
That's not very good.
Those issues (and others that I didn't talk about) prevent Swift's ecosystem from actually growing and they also break one of the basic purposes of the language. Let's take a look at Swift.org - About Swift.
Swift is a general-purpose programming language built using a modern approach to safety, performance, and software design patterns.
...
Fast. Swift is intended as a replacement for C-based languages (C, C++, and Objective-C).
I know it is supposed to be an alternative to C-based languages but that's not possible, not while these issues are a thing. Swift is supposed to be modern, but this isn't modern at all. You can use C just fine on both Linux and Darwin. This shouldn't be an exception for Swift.
I hope this topic finally starts a discussion about bringing Swift frameworks and tools that are currently only available for Apple platforms to Linux. Swift is such an amazing language, beautiful and fast, but you can't use it for server-side programming if you're a Linux user. Period.
(also, I'm sorry if I sound offensive. It truly isn't my intention. English is not my first language and Grammarly's tone detector says it sounds just fine LOL )