Live data from Hacker News

Choosing a more optimal `String` type

swatinem.de

1–10 of 24 posts

Re: Choosing a more optimal `String` type

#5

Why use strings and pass them around in the first place? Why not limit the use of String types to system boundaries where data must be serialized into or from character-oriented streams?

The typical strategy for doing that in a context like this is string interning. That's literally what most of the types described in the post are doing behind the scenes, in one form or another. The post is literally about doing your suggestion -- just using a library to do so, and leveraging the type system to reduce some of the boilerplate.

Re: Choosing a more optimal `String` type

#7
post #4

‘More optimal' is oxymoronic; ‘better’ is just that.

From 1983:

Although "optimum" is an absolute term, like "unique", it became common verbal practice to make it relative: "not quite optimum" or "less optimum" or "not very optimum". Mel called the maximum time-delay locations the "most pessimum".

https://users.cs.utah.edu/~elb/folklore/mel-annotated/node1....

Re: Choosing a more optimal `String` type

#9
post #7
post #4

‘More optimal' is oxymoronic; ‘better’ is just that.

From 1983: Although "optimum" is an absolute term, like "unique", it became common verbal practice to make it relative: "not quite optimum" or "less optimum" or "not very optimum". Mel called the maximum time-delay locations the "most pessimum". https://users.cs.utah.edu/~elb/folklore/mel-annotated/node1....

Even worse! ‘Optimum’ in English is a noun, not an adjective.

Re: Choosing a more optimal `String` type

#10
These leaves off several relevant string types, including ecow which was encouraged over smol_str [0]

See https://github.com/rosetta-rs/string-rosetta-rs for some more analysis. HipStr also has a decent table [1]

[0] https://www.reddit.com/r/rust/comments/117ksvr/ecow_compact_...

[1] https://crates.io/crates/hipstr

Post reply on HN