Re:Why Ruby Has Symbols
by avgcorrection on Thursday April 14, 2022 @09:21AM
(#31026624)
This seems to be a dynamic language thing. Could statically typed languages have some uses for it? In Java one might use a lot of constant strings which are keys for property files. You can of course do some dynamic stuff in order to construct them but they are more likely to be used as constant strings. Would using a separate construct for that make optimization easier? Or wouldn’t it make a difference in practice?
[ Parent
| on HN ]
Re:Why Ruby Has Symbols
by dmitrytsepelev on Thursday April 14, 2022 @09:31AM
(#31026717)
Java does use string interning for constants. It can help in any case when you have a lot of instances of the same string (and when you need to compare that strings)