News for hackers. Stuff that matters.
Re:I Wrote a String Type by karmakaze on Saturday September 09, 2023 @11:19PM (#37452601)
Another useful datatype is a rope[0]. It is useful for using immutable/shared pieces that can build up to other longer compositions. In particular, an operation such as concatenation can be O(1) since that's matches the representation of a rope.

[0] https://en.wikipedia.org/wiki/Rope_(data_structure)

Re:I Wrote a String Type by jcparkyn on Sunday September 10, 2023 @01:08AM (#37453071)
Also worth noting that just about every javascript engine uses ropes internally to represent strings (most of the time).

https://docs.google.com/document/d/1o-MJPAddpfBfDZCkIHNKbMiM...

Re:I Wrote a String Type by codethief on Sunday September 10, 2023 @06:38AM (#37454591)
> most of the time

Looking at the reference[0] given at the very end of the document, wouldn't the word "sometimes" be more appropriate?

[0]: https://mrale.ph/blog/2016/11/23/making-less-dart-faster.htm...

Re:I Wrote a String Type by jcparkyn on Sunday September 10, 2023 @09:06PM (#37461683)
Interesting, seems like things are more complicated than I thought.
Re:I Wrote a String Type by shirleyquirk on Sunday September 10, 2023 @07:21AM (#37454808)
The Nim compiler used ropes internally for years, until recently[0] because removing them reduced memory consumption and decreased compile times, so ymmv

[0]https://github.com/nim-lang/Nim/pull/20433

Re:I Wrote a String Type by dietr1ch on Sunday September 10, 2023 @06:10PM (#37460620)
This is a big tell that maybe we don't want to know exactly the type, but to have way to let the compiler/benchmarks to pick the best performing data structure for the task at hand, but I think that on most programming languages neither the language nor the tooling help you too much here.*

*Saying this mostly with the intent of being proved wrong ;) kxcd://386

Re:I Wrote a String Type by sakex on Sunday September 10, 2023 @06:29AM (#37454547)
A company had me implement that in Rust during an interview. It was pretty hard