News for hackers. Stuff that matters.
Re:Welcome to C# 9.0 by throwaway894345 on Wednesday May 20, 2020 @02:25PM (#23250096)
This made me chuckle.

I think it's broader than C# -> F# though. Java also has closures and higher-order functions, and in many debates on this forum it seems like OOP proponents aren't aware that these features are grafts from functional programming. OOP programmers also seem to have (finally) come around to the consensus that composition is preferable to inheritance.

So if there is a long con, I think it is about turning OOP programmers into ML or functional programmers. :p

Re:Welcome to C# 9.0 by discreteevent on Wednesday May 20, 2020 @03:58PM (#23251057)
> these features are grafts from functional programming

Except that Smalltalk -for which the term "object oriented" was invented - had them.

https://www.infoq.com/presentations/functional-pros-cons/

Re:Welcome to C# 9.0 by thoraway1010 on Wednesday May 20, 2020 @02:59PM (#23250447)
yeah for composition - I ALWAYS liked it much better!
Re:Welcome to C# 9.0 by snuxoll on Wednesday May 20, 2020 @03:09PM (#23250551)
Some languages even have syntax sugar for it built-in, coughKotlincough

    class Foo(b: Bar) : Bar by b
Re:Welcome to C# 9.0 by _old_dude_ on Wednesday May 20, 2020 @03:20PM (#23250654)
This is the most controversial feature of Kotlin.

The delegation is better than inheritance because you don't get all the methods from the base class if you don't need them.

At my company, we have banned it, because if you add a method to Bar the method is automatically added to Foo which makes the delegation as fragile as the inheritance.

Re:Welcome to C# 9.0 by snuxoll on Wednesday May 20, 2020 @03:40PM (#23250872)
> At my company, we have banned it, because if you add a method to Bar the method is automatically added to Foo which makes the delegation as fragile as the inheritance.

Delegation does not remove the need for interfaces.

Re:Welcome to C# 9.0 by throwaway894345 on Wednesday May 20, 2020 @03:38PM (#23250854)
Go has a similar feature, and while I don't know that I would say it's especially controversial or frowned upon, it's good form to only use it sparingly if at all. I still wouldn't say that it is anywhere near as fragile as inheritance; however--I think inheritance's fragility comes from its polymorphism (not sure about Kotlin, but in Go, the wrapper class/struct can't be passed into a function that expects the component's type).