Fork me on GitHub
#off-topic
<
2019-02-07
>
dpsutton03:02:37

the other day we were talking about Tim Baldridge's video that put forth an argument against Higher Order Functions. The gist is that multiple functions as arguments define an ad-hoc protocol. He prefers to name that set of functions as a protocol and pass something that implements them. Argues that it makes codebase much more tractable when initially reading and clarify what these functions are supposed to do. @borkdude i think we were talking about it recently

eval-on-point03:02:45

I remember that convo

futuro03:02:56

That sounds very interesting, and matches with my experience of HOFs

dpsutton03:02:51

yes. And he has an excellent presentation style. Really enjoy the $4 that i spend there a month

jaide05:02:28

Does that suggest ring middleware would be better off as a protocol then?

Alex Miller (Clojure team)05:02:49

pedestal interceptors (which are kind of like middleware taken apart) are defined with protocols

Mattias07:02:52

Curious if this isn’t, in the general sense, saying that types makes sense for understandability? I haven’t really wrapped my head around the “no types” thing of thinking that all kinds of types are always only bad and that no one should ever know what is expected... so, curious about this take as well 🙂

Lennart Buit07:02:06

What is great in Clojure is spec, it allows you to say what the shape of your data is

gklijs07:02:59

I think types makes a lot of sense but in a typed languages it gives problems because they are so rigid. If you have a 'Employee' types in java, and it has a field 'E-mail' you run into problems when you don't know the e-mail always, and often at some point that is the case. Or you can have an 'Employer' which also has an 'E-mail' field, but without some tricks, you can't use the same method only needing the email both on the 'Employee' and the 'Employer'. And in my current java project there are often several type definitions for the same thing, making the whole puzzle much more complex then needed.

Lennart Buit07:02:52

^ that depends a bit on the type system in place right, this sounds like something that a categorial type system is better at

john14:02:08

I think in this case protocols are probably most useful for exploiting the speed of Java's type system for dispatch. But they could just as easily be maps and the method names could just be keys into the map. And I personally would find that no less understandable.

john14:02:52

If we're using compile time errors as our method of understanding, then sure types can help. But spec can provide that fail fast feedback, if desired.

john14:02:48

And there's really no such thing as "no types." It's just whether you have to annotate the world with "Any" or if that annotation is implied.

john14:02:20

And I don't think the ethic is "no one should ever know what is expected." It's moreso like, "no one can always know what is expected in all places, at all times, for all purposes."

john14:02:11

So do you really want to have to annotate everything with "Any" everywhere, just so you can start exploring how functions behave for any given purpose?

Mattias20:02:37

It’s a fascinating discussion. I have seen at least a couple of Richs talks, and I have done a fair amount of JS, Python and... things. It’s still not clear to me what the one truth is. 😅

Lennart Buit20:02:46

there are never any truths in programming

john20:02:29

Well, I guess type inference obviates the need for specifying Any everywhere, but yeah

Mattias20:02:03

Don’t want to push everyone’s patience, but... one more thing; do you, in your day to day work, typically put type information anywhere at all? External documentation, docstrings, comments, anything?

Lennart Buit20:02:42

Personally I tend to use clojure spec to document args/ret for most functions

Mattias20:02:53

Ie, is the “no types” thing a matter of degrees and the information is still useful at some point, or is type information by way or working actually never interesting.

Mattias20:02:28

Cool, haven’t started on spec but tried to digest some of the reasoning behind it. Looking forward to it.

john20:02:40

not really... But sometimes I'll put extra type-like info in the fn name, like num->str or what have you.

joelsanchez09:02:49

does slack always reply with pong when anyone says ping?

cvic09:02:45

There's a Clojure Slackbot that might be fun to deploy here :D

danielstockton09:02:50

Xi Jinping

😅 20
😆 5