logoalt Hacker News

o11cyesterday at 9:22 PM4 repliesview on HN

Hm, this implementation seems allergic to passing types by value, which eliminates half of the allocations. It also makes the mistake of being mutable-first, and provides some fundamentally-inefficient operations.

The main mistake that this makes in common with most string implementations make is to only provide a single type, rather than a series of mostly-compatible types that can be used generically in common contexts, but which differ in ways that sometimes matter. Ownership, lifetime, representation, etc.


Replies

zahlmantoday at 12:05 AM

> It also makes the mistake of being mutable-first

Is mutability not part of the point of having a string buffer? Wouldn't the corresponding immutable type just be a string?

show 1 reply
remexreyesterday at 10:34 PM

How would you recommend doing that sort of "subtyping"? _Generic and macros?

show 1 reply
ameliusyesterday at 10:56 PM

I wonder how an LLM would rate this code.

show 1 reply