7 ms·
> Swift is starting to look a lot like a friendlier Rust to me. That’s what i thought and rewrote my cli util in swift. Ran great on macOS, tried to build for
by steelbrain 2y ago
> Swift is starting to look a lot like a friendlier Rust to me.
That’s what i thought and rewrote my cli util in swift. Ran great on macOS, tried to build for windows and found out there’s no well maintained, actively developed http server for windows for swift.
Dont let these wooing crowds fool you
- asplake 2y agoHa! That seems to answer my next question: what’s its story for web development? Does it have one?
- myko 2y agoVapor works great on Linux and macOS. Haven't tried Windows (pretty much only run Steam there these days)
- alexashka 2y agoYou can't compile for Linux from XCode (defacto IDE for all things Apple) and all web dev runs on linux. If you like having an IDE instead of scrolling multi-page compiler error dumps in your terminal window - this is a complete non-starter. The leading Swift web framework (Vapor) suggests you use Docker to build for Linux. I gave it an honest try - their empty starter 'hello world' web server takes more than a minute to compile. Ok, but surely it'll be faster after I make a one liner change? No - their docker workflow has 0 compiler caching - you'll be waiting more than a minute every time. Complete non-starter. I ended up installing a VM, installing the swift compiler and that only takes 2-3 seconds to re-compile a 1 liner change (in a print statement, in an empty project, lol). Consider me very deeply unimpressed. By comparison - a visual studio code + docker + python/ruby/javascript setup is a well oiled, working machine.
- JoeMattiello 2y agoYou can install other toolkits for Xcode. There’s even an aws toolkit.
- alexashka 2y agoIs it possible to write code in Xcode, press compile and have the debugger show me where an error is when compiling for linux. If yes, please show me the way because I've failed and I've given it an earnest try.
- saagarjha 2y agoYou can use LSP?
- w10-1 2y ago> story for web development Under the hood, Swift-NIO and async Swift is a pretty powerful basis for writing performant servers. Aside from Vapor, there are other small/fast containers like hummingbird. Not mentioned (surprisingly) is Swift support for wasm/wasi, for deploying code directly in the browser. Also, "some say" that macros could revolutionize both static and dynamic generation by moving a good portion of site generation to compile time. I'm not aware of any libraries realizing that promise yet. Finally, Swift concurrent actors have supported distribution for some time, so you can have all-Swift distributed systems, where the client code works with both local and remote servers.
- Larrikin 2y agoDid you look at Kotlin?
- synergy20 2y agoSwift does not use virtual machine and garbage collection, it competes more to c++ and rust and if Apple is serious about pushing it cross platform that's definitely a welcome move, in fact, I can't wait even though I have never programmed in swift. the main point is that, it's memory safe, and seems much easier to code than rust.
- glhaynes 2y agoMemory safe and, with Swift 6, data race safe.
- timeon 2y ago> Swift does not use virtual machine and garbage collection, it competes more to c++ and rust Doesn't it use ARC by default?
- azinman2 2y agoWhich is reference counting, not garbage collection. Ref counts free when count = 0. Garbage collection scans all object pointers and looks for loops / no missing pointers.
- vor_ 2y agoReference counting is a kind of garbage collection.
- mkl 2y agoThat's tracing garbage collection. Reference counting is another type of garbage collection. https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)#Strategies https://en.wikipedia.org/wiki/Garbage_collection_(computer_s...
- jakey_bakey 2y agoHow hard is it to build an HTTP server? (Yeah, this is a dumb question but I'm asking anyway)
- Eric_WVGG 2y agoDo you mean from first-principles, or letting someone else do the work and use a framework? Apple did the hard work, https://github.com/apple/swift-nio https://github.com/apple/swift-nio. If you just want a big framework to launch an API, that's been around for years: https://vapor.codes https://vapor.codes
- akvadrako 2y agoThat all depends on your requirements. A few hundred lines of code will get you pretty far, but there are about 100 optional features in common use.
- taftster 2y agoSneakily hard, actually. There's different versions of HTTP (of course), so pick your target. But when you hit HTTP/2.0, it's not a simple request/reply model (if HTTP/1.1 can be described as such). The intermixing of various client headers and what they imply to server behavior, handling of the streams and when to open vs. when to close, http/2 multiplexing, etc. Don't forget HTTP/3 which uses the QUIC protocol (UDP based) instead of TCP. Interestingly though, a trivial HTTP server is actually very easy to implement as well. A very crude HTTP/1.0 server (or maybe even a limited scope HTTP/1.1 server) can actually make for a fun afternoon project. Like minimal (or no) concurrency support, all TCP connections closed after the request/response cycle, GET only (or maybe POST only), etc. So it's a mixed bag of what you want and how you define an HTTP server.
- astrange 2y agoI can't think of a good reason to want to implement the complex parts. Write an HTTP service if you must, but make it HTTP/1.0 (or 1.1 for keepalive) and stick it behind nginx to do the newer versions and SSL termination. (I also think all HTTP services should if possible be written in a shared-nothing CGI type language, and not embedded in your random stateful program. This way you can't accidentally leak info across user sessions.)
- neonsunset 2y agoFor fast web servers, you could use .NET, especially if you care about Windows. It gives you good ecosystem and consistent experience across all platforms. Even FreeBSD support has improved considerably as of lately. It is already built on top of what Swift, Java and others call "NIO". In .NET it's just "SocketAsyncEngine" users will never know about unless they look for it :)