[HN Gopher] Jank's new persistent string is fast (2023)
___________________________________________________________________
Jank's new persistent string is fast (2023)
Author : diggan
Score : 37 points
Date : 2024-06-10 23:30 UTC (1 days ago)
(HTM) web link (jank-lang.org)
(TXT) w3m dump (jank-lang.org)
| iansinnott wrote:
| Great to see this project is still going! I was fairly excited
| for Jank when working with Clojure regularly. Looks like the
| project is quite active.
| tialaramex wrote:
| This spends a lot of time talking about the C++ Small String
| Optimization (SSO) but then it decides it doesn't really care
| about the zero terminator.
|
| It is not at all clear to me that the SSO is worth it if you _don
| 't_ need this terminator. C++ has no real choice, it is wedded to
| C-style zero terminated strings and so the SSO is necessary to be
| competitive, but if you're rejecting that surely it's time to
| entirely re-evaluate this data structure ?
| SkiFire13 wrote:
| Why do you think the SSO is linked to the zero terminator? I
| always thought it was due to the cost of allocations (and
| deallocations!) combined with the fact that most strings are
| actually pretty small.
| tialaramex wrote:
| Sure, but in a language without the zero terminator the
| _empty_ string doesn 't need an allocation. With a zero
| terminator, only SSO allows us to avoid that. There are a lot
| of empty strings.
|
| [On a typical modern 64-bit computer] An _empty_ Rust
| std::String is 24 bytes, exactly the same as the Clang libc++
| std::string as somewhat smaller than an MSVC or GCC
| std::string
|
| Most strings are "pretty small" but that's relative. SSO
| often gives you 15 characters, so the string
| "http://news.ycombinator.com/" is far too big, so is my full
| name, my work email address, a credit card number, and so on.
|
| The biggest pay off seems to be that empty string, in Rust's
| model it's free, in C++ it could not be free without SSO.
___________________________________________________________________
(page generated 2024-06-12 23:02 UTC)