News for hackers. Stuff that matters.
Re:Value-Oriented Programming by nine_k on Friday August 31, 2018 @12:17PM (#17886746)
The idea proposed: use protocols and value types. This avoids the problems with subclasses and with mutability (concurrent modification). Enums are also used as a controllable way to have different kinds of related objects and use a switch statement to distinguish them.

It is fun to see how the benefits of immutability, typeclasses, and (sort of) ADTs / pattern matching are being discovered independently.

Re:Value-Oriented Programming by hinkley on Friday August 31, 2018 @01:21PM (#17887286)
It’s a compromise between structural and nominal typing to boost code reuse without locking yourself prematurely into structural typing. It’s been tried before and has been given different names.

Personally I’m fond of it. It’s one of several ways to blur the line between “is a” and “has a” relationships. We used to go out of our way to distinguish the two (eg in UML) but it has fallen out of favor.

A coworker long ago convinced me that improvements to delegation would be coming soon to new languages and unfortunately this is one of the first times I’ve seen it happen close to the way he hoped.

Re:Value-Oriented Programming by pjmlp on Friday August 31, 2018 @04:48PM (#17888542)
Kotlin and Groovy are two languages where you get direct support for delegation.
Re:Value-Oriented Programming by sitkack on Friday August 31, 2018 @03:51PM (#17888225)
Delegation is extremely powerful, but it is easily implementable in most OO and Functional languages, no?
Re:Value-Oriented Programming by lmm on Friday August 31, 2018 @04:33PM (#17888459)
If you have to implement it by hand you end up not doing it, especially in languages where "extends" is right there.
Re:Value-Oriented Programming by didibus on Saturday September 01, 2018 @04:18AM (#17890884)
What do you mean by delegation?
Re:Value-Oriented Programming by beders on Friday August 31, 2018 @12:35PM (#17886928)
Was about to comment in a similar fashion. One more example of a language who has embraced this: Clojure Protocols, polymorphism, dynamic dispatch (i.e. multi-methods) and immutability baked in.
Re:Value-Oriented Programming by lmm on Friday August 31, 2018 @04:33PM (#17888455)
It's fun, but it's frustrating as well. Haskell had this stuff 20 years ago, but wasn't able to convey how valuable it was to most people.
Re:Value-Oriented Programming by zeckalpha on Saturday September 01, 2018 @02:09AM (#17890515)
Swift specifically took these ideas from Haskell, Haskell was even mentioned in comments in Swift source code for a time.
Re:Value-Oriented Programming by AstralStorm on Friday August 31, 2018 @12:59PM (#17887116)
Obviously then keep the specification, preferably testable, formal and verifiable of the protocol.

Without this part, you end up with a real big mess similar to 90s internet.