Issue #17472 has been updated by duerst (Martin D=FCrst).


marcandre (Marc-Andre Lafortune) wrote in #note-21:
> duerst (Martin D=FCrst) wrote in #note-20:
> > Javascript doesn't have symbols in the first place
> =

> Actually, it does (since ES 6): https://developer.mozilla.org/en-US/docs/=
Web/JavaScript/Reference/Global_Objects/Symbol

Thanks for the pointer. I haven't fully understood that page, but it seems =
to me that in JS, the 'uniqueness' aspect is much more important, and there=
 are less similarities with strings than in Ruby. Also, the interface on JS=
 symbols is much smaller than in Ruby, and quite inconvenient except for so=
me very narrow use cases.


joelb (Joel Blum) wrote in #note-22:
> > Actually, it does (since ES 6): https://developer.mozilla.org/en-US/doc=
s/Web/JavaScript/Reference/Global_Objects/Symbol
> =

> I find it very unlikely any language will make symbols the default hash k=
eys like Ruby did.

Definitely not JS, see above. But what about various Lisp variants?

> > String are meant for input/output of text. Symbols are identifier for d=
evelopers.
> =

> Why do you need that distinction?

You don't need that distinction. There is also no need to distinguish integ=
ers and floats. Most programming languages make that distinction, but some,=
 including JS, don't (or didn't?).

There is also no strict need to distinguish between strings and numbers. Al=
most all programming languages have such a distinction, but in Perl (+most =
shells, awk,...), a string that looks like a number is just a number, and a=
ny number is a string. Some languages (e.g. Python, Haskell) provide arrays=
 and tuples, others (e.g. Ruby, JS last time I checked) have only arrays. S=
ome languages distinguish between characters and strings (Ruby up to versio=
n 1.8, C), others don't (Ruby from version 1.9,...).

Each choice has its reasons, advantages, and disadvantages. If all programm=
ing languages were the same, it would be very boring.

----------------------------------------
Feature #17472: HashWithIndifferentAccess like Hash extension
https://bugs.ruby-lang.org/issues/17472#change-91187

* Author: naruse (Yui NARUSE)
* Status: Open
* Priority: Normal
* Target version: 3.1
----------------------------------------
Rails has [ActiveSupport::HashWithIndifferentAccess](https://api.rubyonrail=
s.org/classes/ActiveSupport/HashWithIndifferentAccess.html), which is widel=
y used in Rails to handle Request, Session, ActionView's form construction,=
 ActiveRecord's DB communication, and so on. It receives String or Symbol a=
nd normalize them to fetch the value. But it is implemented with Ruby. If w=
e provide C implementation of that, Rails will gain the performance improve=
ment.

summary of previous discussion: https://github.com/rails/rails/pull/40182#i=
ssuecomment-687607812



-- =

https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>