Atom key'd maps #11
Atom key'd maps #11
Comments
I am not a fan of the I'd like to ping @josevalim as well on this just to hear his opinion, but I lean on |
I'm aware of the phoenix use case, but outside of web interactions, I can't justify prioritizing string-key maps: Structs must have atom keys, and the map syntax itself is slanted toward atoms, as it provides the shorthand notation In grepping one codebase of mine (~18k loc), I found 8 of my ~1800 maps have a string literal key. Perhaps my use isn't particularly normal, so I grepped a few others: Ecto: (v1.0.6) 8 string literal keys, 865 maps This selection is just what I happened to have on hand, from a seriously out-of-date Like I said before, I can respect that it's your project, and you can do what you want; however, the Methodology for counting:
|
This issue is pretty important to me, so at this juncture, I think my only tenable choice is to publish another hex package that provides the short atom maps. I said it before, but just so I'm clear: I'm super impressed with your code, I'm just not willing to sacrifice readability for abstract semantics that I personally think are incorrect. |
@meyercm this being open source, you're absolutely free to do whatever you want. This code's license is UNLICENSE so you can even copy this whole repo an not point to the original one/mention me as the original author, and it would be perfectly fine However, for the sake of discussion, I would argue that for the benefit of our community, one single package that does this would be likely better than more than one. For example, we could all focus our design and development efforts into making short_maps the de facto library for Again, I find it hard to wrap my head around the fact that a single
Is it really a "sacrifice"? For example, say I hipotetically would prefer The last thing I want is to sound condescending/lectury/annoying with this comment; again, all I care about is the well-being of our community. :) I will say this again, you're absolutely free to do whatever you want with the code in this package and to release anything you want on Hex (provided it follows Hex's guidelines, of course |
So really, above all, thanks for being reasonable about this discussion, even when 'some guy on the internet' is being whiny about an issue that's been raised and closed over and over. The last thing I want to do is waste time maintaining a support library that is literally a duplicate of someone else's: I have many better things to spend my time on (I don't have any Hex packages precisely because I haven't found an unfilled need), and fracturing the user-base is the opposite of what I want- as much as I hate writing I think part of the disconnect between our viewpoints is that you see Here's my perspective: Elixir is my language of choice, and as a professional developer, I write Elixir for 8 hours in the office, then come home and goof around for longer on my personal code. After I was exposed to ES6 map syntax, I had the same sort of revelation that came with grokking Erlang pattern matches... I really want When it comes to this subject, Frankly, I spend all day in Elixir, so quality of life improvements are important to me. This article from Joel on Software is a classic, but the point is right on, and the part about the bakery is where I'm coming from. When I get to replace a map pattern match with 4 or 5 variables, cutting a multi-line statement down to one: that's a small victory. Thats why my codebases all have I don't want to belabor the point any further, but I do want a unified solution, not a fragmented one, and I want to be able to proselytize about this library. I hope something I've said changes your mind. Again, thanks for being reasonable and open to discourse. |
Discussing is always a pleasure, no worries. Yes, definitely the core idea where we don't agree is seeing Thanks for the discussion, don't hesitate to open such "inflammatory" issues again as far as I'm concerned because often they lead to interesting talks :) |
Commas in the sigil would be nice, just like ice cream and warm cherry pie- it's the trailing To clarify one point, my goal isn't to emulate ES6 syntax, but rather to emulate Elixir map syntax, while retaining the benefit of the ES6 syntax, namely the redundancy elimination. Right now, I'm wrestling with the right way to move forward; I have another library meyercm/flub that depends on the |
@meyercm nope, I have no better idea for that. You definitely shouldn't publish a package that depends on GH repos (I suspect you actually can't do that at all), but I see your point in publishing shorter_maps and then being unable to take it down. I have no good suggestion |
It's really unfortunate that the split happened. Elixir has far fewer libs than the nodejs ecosystem, but the advantage is suppose to be that they are of higher quality, with significantly less fragmentation. I know this is quite retrospective, but the lack of compromise here has diminished this advantage. Hopefully in the future, the community will strive towards unity over fragmentation. |
@sjmueller I agree wholeheartedly with that. I really really want to try and have one good library for many use cases rather than many libraries for few use cases. In this case, shorter_maps has been published so the division happened in a basically irreversible way. Compromise was hard for me here because I strongly disagree with the syntax used in shorter_maps: as I expressed above, I really really feel that there's no point in making things look like ES6 in a whole different language. So sadly I don't see how else this could have ended up; I hoped that one of the two packages would become predominant but right now they have the same order of magnitude of downloads on Hex so community is not expressing a clear preference. |
might be overstating things a bit. ~M{var var2 var3} === ~m(var var2 var3)a my freedom to improve ~M{old_map|key, _other_key, third_key: third_key_actual_variable} At the end of the day,
I can think of two great reasons: a) making it easy for other developers to participate in your community, and b) reusing someone else's good ideas to make your language better. Look at how many languages stole syntax from C: curly braces, parenthesized Novel syntax constructions are rare, but for example: Elixir took Erlang's multi-head function definition not because it had to, but because it is awesome syntax. What would Elixir be without it? How often do you wish I find it quite pleasant to use ES6 map syntax - it makes me smile to eliminate repetitive code, and for me, that alone is enough reason to emulate it. I'm still super grateful for the |
I get that it doesn't seem like a big deal, but if everyone strongly disagreed over these types of matters, then a much needed advantage becomes lost over other larger communities who have more momentum. For the record, I chose shorter_maps over short_maps for the better syntax and v2 features, so I am grateful that you were able to express yourself and take things forward. I just wish it was in one lib, for the sake of the community. Hopefully other lib authors with disagreements can learn from what happened here. |
I have to say, even though it's clear there are strong disagreements in this thread. I am very impressed at the civil tone. I also need to add that I just grepped through our code and saw that we use atoms 100% of the time. We also limit our usage to passing params into our unit tests from the That said, I prefer atoms as the default as well. I think it's because we use it with atoms so consistently that when when ExUnit initially won't even run my test, it's almost always because I forgot to include the training I'd love to see a code-breaking v2.0 of this that would do the following:
|
I've seen the discussion on why
ShortMaps
defaults to string keys, and while I personally am not swayed, I can respect that it isn't my project. Frankly though, I use atom key'd maps and structs all the time -- and because this macro is brilliant, I've just copy-pasted the code and changed@default_modifier
in basically all of my apps, rather than using the Hex package and adding the trailinga
.Referencing discussion in the mailing list, irc, and issue #10 as evidence for how badly some folks (including me) despise the
a
, how do you feel about using~m
for string keys and~M
for atom keys? While the consistency with~w
/~W
is slightly diminished, I think it's a decent compromise position. Additionally, this macro doesn't support interpolation, so the consistency with~w
is already sort of broken.e.g.:
The text was updated successfully, but these errors were encountered: