5 ms·
I want Swift-on-server to be a thing because context switching from UI to backend development is taxing enough, at least the language and some of the tooling co
by mrtksn 6y ago
I want Swift-on-server to be a thing because context switching from UI to backend development is taxing enough, at least the language and some of the tooling could remain the same.
Maybe you can do that with JS+HTML+CSS on the front end and NodeJS on the backend but Swift is such a nice language to work with.
Here is Vapor, a web framework made with Swift: https://vapor.codes https://vapor.codes
- aplummer 6y agoIts really fun to work with a shared foundation project containing all your Codable objects across the app and backend, then serialize / deserialize between the same actual class - with the transport being nice readable json.
- bartvk 6y agoWhat's your experience with Vapor? Suppose I've got a Linux box with a MySQL database, setup with a couple of tables. Maybe like a messageboard with Users, Posts and Comments. How many days would it take to implement a REST API for that? And a couple of simple web admin screens?
- mrtksn 6y agoNot much, unfortunately. Some of the integrations that I need, like firebase, don't have official frameworks for Swift beyond iOS. For example, I need to be able connect to Firestore and listen continuously for new data and changes so I can fetch them, do some calculations and put the results back on Firestore. I am doing it with NodeJS because of the official support but I have to tell you that it melts my brain when I have to switch to NodeJS way of thinking and back again. If I could have used Vapor, I would have been able to just use some the already implemented algorithms in the user facing App instead of re-implementing everything in again but this time in a NodeJS way.
- alexashka 6y agoIt's a joke compared to the ruby on rails or node ecosystem. It is about ecosystems, not languages. Swift's ecosystem is Apple products. If you're not doing that, don't use Swift. You will have to learn and use multiple languages and multiple ecosystems regardless because each ecosystem insists on using its own language and tools. So just use the most popular one for each - it will be the most polished with the fewest number of gotchas. At this point, the clear winners for each ecosystem are Kotlin, Swift, Typescript, C# and C++ if you're doing games. If you write a todo app on each platform, you'll realize you're using the same set of language features with different syntax - that should lessen the anxiety of learning a new language. Once you're free and nimble, you'd have to be nuts to choose anything but the right tool for the job or when in doubt, the most popular.
- deleted 6y ago[deleted]
- bartvk 6y agoWhy do you say it's a joke? Is it because of your experience with it, did you compare features, etc., what is the reason?
- pjbster 6y agoI am in the process of learning Vapor. You need to be comfortable with Swift closures as Vapor uses them everywhere. The SwiftNIO EventLoopFuture is prevalent too and there's a rich API over that which I'm still getting to grips with. To my mind, the best learning resource is Tim Condon et. al.'s Server-Side Swift with Vapor (Ray Wenderlich publishing) but this book needs to be updated. Vapor 4 was released in April but the ORM (Fluent) and template engine (Leaf) weren't upgraded at the same time (June and November, respectively). The first half of the book was updated in September but everything else has been on hold waiting for the Leaf release. My progress through latter part of the book has been slow whilst I translate the examples and wrestle with the compiler errors brought on by my unamiliarity with the above concepts. Tim C. is on the case and is very active and helpful on the forums so I expect the new version of his book will be finished quickly. Anyway, to answer the question: Vapor should be nearly as productive as Rails once you become familiar with it. There's an offically supported MySQL driver for Fluent but no admin screen builder like you might find on Django, for example, so you'd have to put those together yourself.
- oarsinsync 6y ago> context switching from UI to backend development is taxing enough, at least the language and some of the tooling could remain the same. I wish I had understood this sooner. Thank you for your comment!
- rnikander 6y agoI'd use Swift-on-server for web apps if there were a way to compile Swift to JS, like you can with Kotlin. As far as I know, there is not a good way to do this.
- Asmod4n 6y agoGave SwiftWasm a try yet?