Llama Preview: Swift with ASP.NET Core
This preview of Llama is in the form of a little GitHub repo:
It's a simple demo of a web API in ASP.NET Core, written in Swift. It uses
System.Text.Json (requiring .NET 6 preview 4) for serialization of the request and response. The trivial functionality provided is a server that multiplies two integers and returns the product.
I've been exploring Llama for quite a while now, sharing previews and blog articles to show the world what I'm up to. In general, early adopters and nerds (like myself) tell me it's cool.
But sometimes a more pragmatic person encounters Llama and wants to know why I'm doing this. What are the use cases?
(Eric thought balloon: "Humph. I bet people who write Game Boy emulators don't have to endure rude questions about possible use cases.")
The purpose of this particular demo is to show one area where I think Llama might have the potential to be useful.
Swift beyond iOS
The Swift language is an interesting situation. It's quite popular, very well-designed, and a pleasure to use. And with Apple's backing as the primary language for iOS development, it will continue to grow.
But so far, Swift is getting a LOT more traction in iOS development than in other areas. Like server-side. Or cross-platform.
The appeal of Swift on server is clear, especially for the backend of iOS apps, where some developers would like the benefits of using the same language on client and server.
To be clear, there IS activity here:
There is an active community at Swift.org.
Swift has had Linux support for several years.
A Windows port was released with Swift 5.3.
A work group is focused on server-side Swift.
Vapor is cool.
But I (and surely others as well) see potential for other ways that Swift's reach could be extended.
Server-side Swift with ASP.NET ?
Building a complete server-side stack specifically in and for Swift is a fine approach, and no criticism of such efforts is intended here. But another approach would be to make Swift work well with an existing ecosystem.
What if Swift had seamless integration with ASP.NET Core, a mature and high-performance stack for server-side development?
Azure and .NET are very popular in the enterprise world. Enterprises write iOS apps too.
This proof-of-concept demo is a glimpse of some possibilities I like to think about.