Hacker News new | ask | show | jobs
by chrisseaton 1534 days ago
> At this point with no practical difference between them

Gah no! This isn't true! Even if you turn on frozen string literals comparing two strings is slower because they have to test for a non-frozen and non-interned string also happening to be the same.

https://twitter.com/ChrisGSeaton/status/1514603665801109508

There's a pointer comparison, but behind it is on the failure side is a full-byte-comparison. Atrocious for cache even if the strings are tiny. If they aren't you're checking every byte!

2 comments

I'm a big fan of explicit symbols, but some syntactic sugar around immutable strings and type inference should let you use "symbols" with little performance penalty. Of course by then you might as well use explicit symbols anyway, but I guess there's some additional flexibility. Of course that hurts macro-writing a bit, but not much.
Okay mutable non-frozen strings shouldn't exist either, and people should use string builders.

Really both features (symbols and mutable strings) aren't worth the literally endless bugs that they cause.