
Very basic HTTP implementation in Swift - huydotnet
https://github.com/huytd/swift-http
======
Matthias247
Sorry - but sending a bunch of static bytes through a TCP socket without even
reading something from the input is not even a basic HTTP implementation.

~~~
mpweiher
But, but, but...it's _in Swift_!!!!

It is therefore already vastly superior to any and all full web server and
application server solutions and defines how servers will be written in the
future.

Particularly, all the web server solutions written in Objective-C have ceased
to exist.

------
cdnsteve
I think this opens up the possibilities for Swift to be used as a web
language, not just a iOS language. I have to say, Swift syntax is very similar
to PHP 7. Interesting times for sure. I'll be keeping a close eye on Swift in
terms of its adoption as a web language.

~~~
pbreit
In that sense, would you be comparing Swift to Go, Python/Ruby, JavaScript,
PHP? Is Swift "better" than the others?

~~~
cballard
Swift has a passable type system, support for generics, and doesn't use a VM.

Tooling support isn't there for Linux currently, so the act of _writing_ code
isn't much better than Python (no Xcode-type autocompletion), but once you
want to _run_ it, the compiler will scream at you if you pass ducks where
penguins are expected - while still allowing you to reason about swimming
birds in general.

------
Wonnk13
Why is two thirds of the README dedicated to Docker? must everything be a
Docker container now?

~~~
huydotnet
Basically, you can install Swift directly on your Linux machine, but for Mac
users who not using El Capitan or Windows users, they will need Docker

------
nodesocket
Unrelated, but is this a common practice in Swift?

    
    
        #if os(Linux)
            import Glibc
        #else
            import Darwin.C
        #endif
    

Feels a bit nasty.

~~~
trymas
AFAIK, at least for now it is.

Libraries on Linux and OS X just are different. Maybe when core libraries [0]
will be fully finished we could just use `import Foundation` on both
platforms.

[0] [https://swift.org/core-libraries/](https://swift.org/core-libraries/)

------
nodesocket
Interesting to see if an Express like framework comes about. Does it even make
sense to write a backend http RESTful API in Swift? Wonder what the
performance is vs node.js and go?

~~~
breckinloggins
I made something in the Swift 1.0 days called "swell" that shows how this
might look.

[https://github.com/breckinloggins/Swell](https://github.com/breckinloggins/Swell)

It could be used as an example. In particular, the "builder" syntax that I did
with a terrible TLS context hack could be replaced with autoclosures (I
think).

Edit: more Sinatra-like than Express-like, but the idea still stands.

------
EugeneOZ
I don't think Swift is a very good choice for the web - we already have much
better options. Swift compiler don't care about memory leaks, runtime errors
and race conditions. And it's really easy to get runtime error - just unwrap
optional value without check.

So I think Swift is good for something what can run few minutes and be
restarted easily in case of failure - mobile and desktop apps. Not web server
daemons.

------
pkaler
Aeon is an HTTP server written in Swift that has an API that looks like
Sinatra. [https://github.com/Zewo/Aeon](https://github.com/Zewo/Aeon)

------
srameshc
How mature is Swift for writing backend applications in its current state when
compared to Python or maybe Rust ?

~~~
huydotnet
It's potential :D

------
andoma
Oh, this is so cute...

