Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not too often, yet. But it could potentially become a more user-friendly alternative to Rust.


Swift seems to be evolving towards something which lives between Rust and Python.


I'd say more like something between Rust and Scala, or Rust and Java. That's not a bad thing. I really like Swift.


Me too. I think "higher level rust" is a very good and useful niche. Sometimes convenience is more important than performance.


What rust features does it have?


To name a few: generics, pattern matching, memory safety by default (though not concurrent yet), no untyped-nil, the capability for C-like performance, deterministic memory management. Protocols are pretty similar to traits as well.

Though the way all of those work is substantially different. Swift doesn't monomorphize generics like Rust does[0], for example.

Swift doesn't have a concurrency story yet, so it is possible to have data races if you share data between threads. An ownership system[1] is in the works, but it is not complete yet.

[0]https://www.reddit.com/r/rust/comments/7gkiie/implementing_s... [1]https://github.com/apple/swift/blob/master/docs/OwnershipMan...


Good summary. Also algebraic data types, although that typically accompanies the pattern matching you mentioned.

Protocols are fairly close to traits, and I much prefer that approach (and Scala's traits), to traditional OOP.


> Swift doesn't monomorphize generics like Rust does[0], for example.

Swift can monomorphize generics, but it doesn't do so by default. Normally this is left up to the compiler, but it's possible to force monomorphization using inlining attributes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: