Comment by theoldgreybeard

3 months ago

I'm a ruby developer, would never dream of switching to another language as my bread and butter - but my language design hot take for ruby is that symbols were a mistake and unnecessary and the language would have been better off just using frozen (immutable) string literals for everything except for the syntax of keyword arguments.

Unfortunately we can't change it now, but generally I just don't use symbols anymore unless I absolutely have to.

I've always been conflicted on them. I like that they allow me to be more explicit about things which are read from input or parsed out as strings vs internal parts of my program (I rarely call .to_sym), but I've also lost time to being careless and indexing hash maps with the wrong type.

Overall, I think I'm glad they exist.

  • I've had to fix so many errors over the years due to string/symbol mismatch in function calls and/or hash access, and never once have I benefited from the extra optimizations that the guaranteed singular allocation of symbols have given me where I wasn't able to get the same benefit from a frozen string literal.

    If it was up to me I'd get rid of them, but I know I have an unpopular opinion and it's really only a thought experiment.