Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Those benchmarks aren’t great.

A real world-ish workload made generic over all these types would provide much more interesting results. Especially if heap usage was also tracked.



Real world benchmarks also wouldn't be great because they would be showing how well it works in someone else's program, rather than yours.

This at least gives you an idea of what the relative cost of different operations are so you can consider what are frequent operations in your program and then benchmark a couple from there, rather than everything.


the author has some recommendations, to quote formatting):

> Suggestions:

>

> Generally, String

> If you deal mostly with string literals but want some flexibility (like clap), generally you'll want Cow<'static, str>

> If a profiler says your strings are a problem:

> Try different crates and settings for that crate out with a profiler

> O(1) clones are important when doing a lot of clones.

> For one-off allocations, they are slower.

> For short-lived programs, look into string interning

i.e. author thinks you should profile with your own use case

EDIT: Not sure why HN removes indention between a leading > and the start of the text, makes quoting unnecessary hard


> Not sure why HN removes indention between a leading > and the start of the text, makes quoting unnecessary hard

Because HN’s markup is the most dreary, half-assed, and useless one in the history of lightweight markups.

HN will remove a bunch of characters it doesn’t like because they might be used for fun, parse two+ newlines as a paragraph break, 4-indent as a literal block, and mis-parse * as emphasis.

That’s it. So you get all the drawbacks of HTML with almost none of the tools provided by even just the original markdown. No quoting, no line breaks, no lists, no inline code, …


2-indent is a literal block. 4-indent also is, but only because it's a 2-indent.

HN markup also supports \-escapes (so you can write \*hello\* to get *hello*), but they grow linearly, not exponentially, with repeated escapes (\\\* becomes \\*). It also truncates long URLs in display, and it handles a single pair of parentheses in them (so you can write https://example.com/print(%22Hello,%20world%21%22)). But I think that's all.


HTML doesn't do indentation. I typed four spaces between every word in these sentences.


but HN doesn't provide me with a HTML input field but a text input field and HTML has stuff like <blockquote> absent from HN input format and properly converting user input is a bread and butter task of anything displaying user content

so HTML collapsing whitespace is really meaningless for the argument IMHO




Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: