Hacker News new | ask | show | jobs
by sgt 2819 days ago
I think optionals are my favorite feature. That may be due to me coming from a Java background (which also has optionals since 8, but I feel it's rather clumsy compared to Swift and other modern native languages).

By doing optional chaining you can do something like: if let name = result.person?.firstName { ... } which only evaluates firstName if person is not nil, and then stores the result in name which is immutable.

It's easier to avoid mutable code in Swift than in many other languages. For this reason I would love to start working with Swift on the backend at some point in the future.

I like extensions, being able to extend any class I want by just typing it into any file I want. This helps with iterative development and trying something out.

Speaking of iteratively, if I want to try something quick, I can also drop down to a shell and start the Swift REPL to experiment.

I like how built-in functions like zip and mapValues are available, so it in some ways has a Pythonic feel. I like the syntax of building strings by just taking a variable name and going let s = "Hi there \(name)!".

There are lots of other things I enjoy, such as subscripts (see why here: https://docs.swift.org/swift-book/LanguageGuide/Subscripts.h...) and

Some things I would like to see improved is Xcode itself and also Swift's capabilities in the backend.

3 comments

Thanks for the answer!

I've been waiting impatiently for a better Swift backend ecosystem, because I'd love to use it for web development as well.

I’m having a great time in Vapor 3.
Vapor is pretty amazing. Super fast and pretty fun to work with; also a very friendly community. Ray Wenderlich’s team as well as Paul Hudson also have some great books on server-side Swift for those looking to learn this stuff.
As a mainly C# developer, it seems we have a lot of features in common!
yeah, string interpolation is such a killer feature. I love using it in Python 3.6.