Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by seanalltogether on Wednesday January 11, 2023 @04:58PM
(#34345570)
I think the fact that Rust won't provide inheritance based OOP workflows means that something like swift will always be valuable, especially for application development.
[ Parent
| on HN ]
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by Gigachad on Wednesday January 11, 2023 @05:05PM
(#34345657)
What is the value provided by inheritance? It was my understanding that this was deliberately excluded from Rust as it's now seen as a bit of an anti pattern mostly inferior to traits.
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by sacnoradhq on Wednesday January 11, 2023 @05:19PM
(#34345856)
None. It's code organizational syntactic sugar and abstraction that incurs a runtime penalty (vtables).
Go ditched OO for similar reasons.
Haskell, Erlang, and more get along fine without OO.
(OO crested with Smalltalk, Java, Ruby, Python, and JS (more prototypal though). Let's not talk about C++98)
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by metaltyphoon on Thursday January 12, 2023 @11:33AM
(#34356137)
Don’t trait objects work the same way as vtables (fat pointer)?
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by Gigachad on Thursday January 12, 2023 @08:23PM
(#34362787)
Monomorphisation solves this. The compiler duplicates functions for every type you use them with in the finished binary.
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by seanalltogether on Wednesday January 11, 2023 @07:10PM
(#34347069)
Inheritance is about providing business logic in all downstream inheritors through a super() chain. If you want shared logic in Rust between several implementors of a trait you will probably end up with duplicate code. There are drawbacks to both.
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by Gigachad on Wednesday January 11, 2023 @08:20PM
(#34347779)
You can solve duplication with macros to implement traits. The Rust way seems to provide the same convenience without the runtime costs.
Re:Apple Announces Full Swift Rewrite of the Foundation Fram...
by seanalltogether on Thursday January 12, 2023 @04:42AM
(#34351239)
Macros provide code injection, that's not the same thing. Inheritance allows for overrides so you can have [default super logic]+[custom child logic]. That's only possible in rust with a lot of copy and paste, which can be fragile to maintain long term. Most UI frameworks are built around inheritance to guarantee logic provided by the base view or view group, while allowing for inheritors to mix in custom logic as well