[swift-server-dev] [HTTP] Value vs Reference Types
Rick Mann
rmann at latencyzero.com
Wed Nov 23 16:04:48 CST 2016
> On Nov 23, 2016, at 13:15 , Dan Appel via swift-server-dev <swift-server-dev at swift.org> wrote:
>
> >2. If we use concrete types, do we want value or reference semantics?
>
> What I think makes this easier is that the "big four" have each taken a slightly different approach that can be used as a reference.
> Zewo - struct, value semantics
> Vapor - closed class, reference semantics
> Kitura - closed class + has-a pattern, reference semantics
> Perfect - class protocol, reference semantics
Have you looked at Swifter (https://github.com/httpswift/swifter)? It uses value semantics, and interestingly, uses an enum for HttpResponse.
Not sure if it's the best, but I'm using it to embed a server in an iOS app, and it was very easy to integrate. I had to make some modifications to the source to support a few extra response types and behaviors, but that may have been due in part to my own relative lack of expertise in Swift.
My server-side experience is primarily Java, which has no value semantics. I've also written servers in Swift and node.js. So far, I much prefer the Java/Spring environment for writing anything but the most trivial web apps. As long as we can get that level of expressiveness, performance, flexibility, and ease, I'll be happy. Not sure it's possible without a great deal more language support for introspection (@Annotations).
--
Rick Mann
rmann at latencyzero.com
More information about the swift-server-dev
mailing list