There are two schools of thought:
1. Multimethods are the most versatile and work better at the REPL.  Use
protocols only where necessary for performance (and doing so early is
premature optimization).
2. Protocols are the most performant and handle the most common
polymorphism need - single dispatch based on type.  So use protocols unless
you are doing something that can't be done with protocols.

I tend to agree with your coworkers and fall into camp 1, but we are
probably a minority.  Either philosophy is ok if you're working on your
own, but at work you probably need to standardize on whatever the more
experienced coworkers prefer.

On Mon, May 21, 2018 at 10:25 PM, Sam Bartolucci <sambartolucc...@gmail.com>
wrote:

> Hi,
>
> I've been an enthusiastic Clojure tinkerer for a few years now--it's a
> great language!--but only recently began using it professionally, where
> I've stumbled into a strong disagreement over the use of protocols vs.
> multimethods for single dispatch polymorphism. I had always assumed that
> protocols were a normal part of Clojure when polymorphism was called for,
> but a few of my coworkers (often, it seems, those who have experience with
> Lisp prior to Clojure) swear up and down that protocols are only to be used
> as a last resort because they "break the REPL". Apparently they're frowned
> upon because, due to the JVM interop, they don't reload as well as other
> constructs. It has even been suggested a few times that all uses of
> protocols should be refactored to use a multimethod with a "type" as the
> dispatch function. Protocols, in other words, should be considered harmful.
> This seems strange to me considering how many successful and mainstream
> Clojure projects use protocols, but maybe I am missing something, so I
> thought I would ask the list. So what is it? Is there any consensus around
> the assertion that "good, idiomatic Clojure will use multimethods rather
> than protocols for single-dispatch polymorphism"?
>
> Thanks,
> Sam
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to