Hacker News new | ask | show | jobs
by darby_nine 638 days ago
Curious! In what ways do you do you see swift as friendlier than Rust? I perceived it as functionally equivalent, although Swift had a lot more "magic" involved and it was less clear how things might work memory-wise.
2 comments

To me, Swift has better ergonomics for most people.

Ref counting by default makes most programs easier to deal with.

Guard let (though recently somewhat introduced in rust) are much more friendly ways to unwrap optionals.

Being able to provide parameter defaults and aliases.

Easy passing in of callbacks. Easier async.

Null chains with the Question mark operator.

I really like rust, but it’s much faster to get to a working program in Swift.

And with the new CXX interop, I now reach for Swift by default since I have to deal with a lot of C++ libraries.

> Easier async.

I was on board until this one. Async is a rough spot for rust, but I find the async strategy swift went with absolutely baffling and difficult to reason about.

I’m curious, what puts you off of them? Actors are pretty standard ways to do it, and I feel like most of the successful rust implementations are actor based as well.
More magic (thus less required explicitness) and less involvement with memory management are typically considered as friendly traits in programming languages.
> More magic (thus less required explicitness) and less involvement with memory management are typically considered as friendly traits in programming languages.

Really depends on the context. I really, really, really hated this instinct in the ruby on rails community when I was still doing that. Magic is nice until it doesn't work the way you expect, which is when it becomes an active liability.

I really don't spend much time thinking about memory management in Rust, but I can certainly understand why one might be happy to not have to design around ownership and lifetimes. I really like the explicit nature of it, though, makes it super easy to read and reason about code you've never seen before.