3 ms·
>It's missing its biggest features. Like what? Please do enlighten us.
by JeffKilborn 11y ago
>It's missing its biggest features.
Like what? Please do enlighten us.
- Manishearth 11y agoZero cost abstractions. Memory safety without overhead. Etc etc.
- Jweb_Guru 11y agoSafe lightweight references. Arc is garbage collection, and Swift is totally garbage collected. Rust is not. It's a rather important distinction. Because allocations must be thread safe, Swift references are also all atomic. If you do choose to use reference counting in Rust (it is nearly always avoidable), bumping a reference count with Rc is very cheap. It also means that, like other managed languages, Swift objects that have references taken to them (classes) must in general be allocated on the heap. This means that, unlike Rust but like many higher-level languages, controlling allocations can be difficult and heavily dependent on the whims of the optimizer. Some of Swift's implementation decisions (like copy on write arrays) also suffer. The inability to avoid allocations, combined with much less efficient allocations than are possible with tracing GC, are among the reasons that reference counting is uncommon in production languages (though the Immix collector does very well). You can certainly write code in the unsafe dialect of Swift that is just as fast as Rust, C, or any other language. But like unsafe mode in Rust, this won't be the common mode of use in Swift.