Easing friction from collection name conflicts with the standard library #2931
Replies: 3 comments 1 reply
-
As I understand it, Vavr shares a common geniology with Scala collections, and their names are taken from there. However, some collections taken “as-is” are considered obsolete in modern Scala - for example, I think it would be a good idea to bring the Vavr collections in line with the latest Scala collections in terms of names and maybe even features. Partially it would solve this problem - As for |
Beta Was this translation helpful? Give feedback.
-
Yeah, I was aware of Scala having been used as a bit inspiration. Personally, I don't have a strong opinion on either the names, or even if the name approach should be taken. It was just an idea (and the only one that I could think up so far). I am mainly interested in the result, which is that vavr types can live and be used alongside java ones without conflicts. I suppose it would be possible to subclass a bunch of things on the client-side as a poor substitute for type aliasing, but that both feels dirty and might not always play nicely with type inference due to being different types. I am not sure what the best way to achieve this would be, but I would love to be able to use vavr more in my work, and this has been the biggest hurdle towards that in my situation. |
Beta Was this translation helpful? Give feedback.
-
First things first, moving this to Discussions :) Secondly, this is a great point. There are two types of existing data structures:
I like the idea of prefixing existing collection names with |
Beta Was this translation helpful? Give feedback.
-
Currently, there is some noticeable friction with introducing vavr in an existing codebase due to naming conflicts with the standard library for common collections such as
List
,Map
, etc. In my experience, this has been one of the main reasons for pushback when trying to integrate vavr in an existing codebase, and I do agree that it causes issues with:List
,Map
, etc. to refer to the standard versions instead of the vavr ones. This is even more so if different files use different versions, or if one file mixes vavr and non-vavr collections.In my experience, the above makes adoption harder than it needs to be, since people are hesitant to deal with the confusion/inconsistency in an existing code base. In the case of a new project, everyone needs to be on board to essentially replace the standard library with vavr and be vigilant about not mixing them.
I made this issue to have a discussion about easing this friction. In particular, the people that I have talked to feel that it would be a lot easier/less surprising/less error prone if the vavr variants had a slightly different name, and I tend to agree. For example, if the collections were called
VList
,VSet
,VFuture
, etc. it would be clear which one was being used. For values likeOption
,Either
,Try
, etc. that already have different names, this is not an issue, but it might be worth using the same naming convention throughout.Beta Was this translation helpful? Give feedback.
All reactions