It's pretty hard in clojure to keep track of a data structure and ensure
some function introduced later in the middle of a data path doesn't seq it
along the way.  You get some discipline around this, but it adds to the
learning curve.

I wouldn't say polymorphism is better or easier than being stricter with
types in a core library, especially when it comes to modifications, but
it's super useful on reads (iterators, seqs, slurp).  I will say that this
is like a 2008-era debate whose ship has sailed in clojure.

On Tue, Jul 17, 2018 at 11:34 AM Alex Miller <a...@puredanger.com> wrote:

> I think you're no longer teaching Clojure then. The values embedded in
> this design choice are important and erasing them does a disservice to
> learners.
>
> I think by fighting this, you're actually making Clojure harder than it is.
>
>
> On Tuesday, July 17, 2018 at 9:49:33 AM UTC-5, Christian Seberino wrote:
>>
>> Alex
>>
>> Thanks for all the replies.  It is clear there are 2 values in language
>> design...*simplicity* and *efficiency*.  Sometimes they conflict
>> unfortunately.
>> Clojure sacrificed a tiny amount of simplicity for a huge gain in
>> efficiency with the design of conj and friends.
>>
>> Imagine someone wanted to have Clojure compete with Python and Scheme for
>> introductory programming classes. In that space
>> simplicity is everything.  Maybe it would make sense there to teach using
>> "prepend" and "append" functions to keep things as simple as possible.
>> Then, later when they were more confident and ready, efficiency
>> considerations and conj could be explained.
>>
>> Would that give the best of both worlds?  Everyone could have what they
>> want when they want it.
>>
>> cs
>>
>>
>>
>>
>> On Monday, July 16, 2018 at 4:30:51 PM UTC-5, Alex Miller wrote:
>>>
>>>
>>>
>>> On Monday, July 16, 2018 at 4:08:47 PM UTC-5, solussd wrote:
>>>>
>>>> Another way to think about it is lists and vectors are different and
>>>> the idiomatic way to add items to them is different.
>>>>
>>>
>>> I would say different data structures have different ways to
>>> *efficiently* add items to them, and conj is an operation to add items
>>> efficiently (meaning, sub-linear time). So when you see conj, you know it
>>> is always a "fast" operation.
>>>
>>>
>>>> A (singly-linked) list is usually prepended to (otherwise you have to
>>>> walk the entire list to find the end). A vector is usually added to at it’s
>>>> n+1 index, where n is the size of the vector. The conj function is
>>>> polymorphic.
>>>>
>>>> cons takes a seq and returns a seq. It only cares that it can get a seq
>>>> on whatever collection you give it and will always prepend to that seq.
>>>>
>>>
>>> Slight modification - I would say cons takes a *seqable* and returns a
>>> seq. For example, a vector is seqable, but not a seq.
>>>
>> --
> 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