Hacker News new | ask | show | jobs
by oseph 2093 days ago
I really like Swift. Recently I've been using it as my "main" language in developing a macOS user interface for my MSc research project, and it has literally made developing fun!

Great to see it getting more support outside of the Apple domain.

1 comments

I wrote some swift maybe 4 or 5 years ago when I was doing mobile app stuff and had access to a Mac. I remember finding the language pretty enjoyable, but considered its xplat potential questionable. At the time, I believe it did run on linux and people were touting it as a solid platform for building server side applications. I dont think that was ever realized though.
Swift on a server is a think: https://vapor.codes
The docs are very incomplete and common third party dependencies are missing. I know it’s a chicken and egg type situation but vapor is not an appealing option for backend unless you really want/need to use Swift.
I was going use it only if there there was an official Firebase support to do things the way they are done on iOS. What I want is to have a server app that communicates with with Firebase services to do certain tasks.

Doing this in Javascript(Node) instead, is very cognitively taxing for me. Mental models are different, so I need to “cool down” and start thinking in the other language when switching between app dev / back end.

Swift is so nice That i would rather do everything in it anyway but not having to switch mental models is the real reason.

I find swift to be the most enjoyable and productive language I’ve used so can relate to you there, for me personally vapor seemed a long way off though. Maybe you could try Go? Kotlin is also very nice.
I am curious, what did you find missing or unachievable using Vapor?
Swift has no concept of fault tolerance. If you by mistake make an illegal array access, multiply two numbers that are too big or overflow your stack (which is limited to ridiculous 512KB on secondary threads), your app crashes and that's that. Apart from a horrible user experience (you don't even get a "nice" customised 500 error page, just a "Gateway timeout" or similar), your app is now offline for everyone.

What other backend language doesn't allow you to recover from errors? It is my understanding that even Haskell allows you to catch "error".

I developed a Swift server-side app (not with Vapor, but with Kitura - but the point still stands) for two years and this was one of the biggest issues, and despite ongoing discussions, it just has never been fixed.

Community and ecosystem mostly. Maybe it's changed a lot since version 3 but I don't see much uptake. I had enough issues that a rewrite of my API in Typescript was faster than upgrading to 4 when it came out.

Edit: looking at the docs again theres an official upgrade guide now so thats a step int he right direction, I'll take a closer look when I get a chance.

I’m betting once async/await lands in Swift it’s usefulness as a server-side language will greatly increase. You can check on GitHub the work on a async/await by people like Doug Gregor has begun. Very exciting.
The docs are incomplete because they just recently released version 4. Version 3's docs are much more fleshed out– v4's will get better now that the changes have actually landed.