3 ms·
> The other part is: Records are no substitute for objects. Not even close. Those are just quite primitive structs. (To learn how unpractical is it to try to bu
by lolinder 4y ago
> The other part is: Records are no substitute for objects. Not even close. Those are just quite primitive structs. (To learn how unpractical is it to try to build objects from structs without proper language support just ask someone who was forced to use C after coming from a more complete OO language).
I agree with you about C and Haskell's records, but I'm curious if you'd say the same about Rust's struct + impl system? Are there problems that can only be solved with real, Smalltalk-inspired objects, or can lightweight structs do the job if supported by enough syntactic sugar?
- still_grokking 4y agoThe answer lies in the answer to why Rust added `dyn traits`… Indeed Rust striked some kind of sweet spot because it got the defaults right. Syntactic it mimics mostly the OOP approach, but without the conceptional burdens behind it. Still Rust could not do without dynamic dispatch (which is the—wrong—default in OOP). In the (admittedly) seldom cases where you need dynamic dispatch & runtime polymorphism you just need them. You could build this stuff by hand (and people did in the past in languages without this features built-in) but having dedicated language level support for that makes it much more bearable. Structs + the impl system is static dispatch. This just can't replace dynamic dispatch. If it could nobody would have ever invented v-tables…