News for hackers. Stuff that matters.
Re:Clojure Design Patterns by catnaroek on Friday November 24, 2017 @03:46PM (#15772927)
This is a restatement of the well-known equivalence between so-called “objects” and “functions”. Both are idiosyncratic names for the same thing: procedural values.

The condescending tone of the post is completely unwarranted, especially since it glosses over the real limitations of procedural values as abstraction building blocks, which don't magically go away when you rename them from “objects” to “functions”. In no particular order:

(0) There is no modular way to distinguish procedures that meet a nontrivial specification from all other procedures. Guaranteeing that a procedural argument never takes a silly value requires whole-program analysis, which doesn't scale.

(1) There is no modular way to communicate the fact that two or more procedures manipulate similar or related data structures. Try implementing abstract data types with binary operations (e.g. mergeable heaps) as objects.

(2) There is no modular way to control which procedures exchange information with one another. Say Foo is designed to communicate with Bar. I can replace Bar with a type-compatible but ill-behaved impostor Qux. As far as Foo can tell: https://az616578.vo.msecnd.net/files/2016/09/26/636105299923...

The cure for this illness is using abstract data types, not objects.

Re:Clojure Design Patterns by sooheon on Friday November 24, 2017 @08:33PM (#15773954)
Can you enlighten me as to how ADTs differ from specified contracts like spec [1]?

[1]: https://clojure.org/about/spec

Re:Clojure Design Patterns by catnaroek on Friday November 24, 2017 @08:37PM (#15773970)
Abstract data types guarantee that nobody besides the implementor can violate the contract. They compartmentalize what you have to verify.

Without abstraction enforcement mechanisms, an abstraction you have correctly implemented can still misbehave, because someone else has tampered with its internal representation.

Re:Clojure Design Patterns by hellofunk on Saturday November 25, 2017 @03:04AM (#15774965)
And here I thought ADT almost always meant "algebraic data type."

Regardless, Rich Hickey's last talk (last month at Clojure Conj) offered a counter argument, why ADTs are usually not the best way to organize software (as part of his larger discussion against static typing).

Re:Clojure Design Patterns by catnaroek on Saturday November 25, 2017 @06:05AM (#15775481)
> And here I thought ADT almost always meant "algebraic data type."

It depends on context

> why ADTs are usually not the best way to organize software

He clearly hasn't proven anything about his code.

Re:Clojure Design Patterns by mike706574 on Saturday November 25, 2017 @03:11PM (#15777736)
> He clearly hasn't proven anything about his code.

Is that a bad thing? It seems like many people are able to write software that works well and gets the job done without "proving anything" about their code in the way you're describing. Personally, I'm fine with not proving anything if I can deliver quickly and everything works, but I'd like to be convinced otherwise if there's real value there.

Re:Clojure Design Patterns by lprefontaine on Sunday November 26, 2017 @10:15AM (#15781201)
Formal verification of code has been the elusive Graal seeked by many for now a few decades.

It’s a mirage to which many have succumb but like in the desert most died of thirst trying to catch it.

Re:Clojure Design Patterns by catnaroek on Saturday November 25, 2017 @08:41PM (#15779021)
For basic infrastructure such as compilers and standard libraries (at least of data structures and algorithms), not providing proofs of correctness is outright criminal.
Re:Clojure Design Patterns by blain_the_train on Sunday November 26, 2017 @07:41AM (#15780660)
It's not though is it... You know, because there aren't actual laws about it.

Let's try not to make inflammatory statements.