Hacker News new | past | comments | ask | show | jobs | submit login

> One issue to consider is that strings typically feature random access indexing of code points

True but I find it's much rarer to actually need random access to arbitrary code points. Most of the time I either use strings as opaque "things" or I'm iterating through characters to find something interesting (e.g. parsing) where I can build my own index, if and when necessary.

I do agree with the article that if an abstraction is very leaky it's better to be upfront about that.




I think that accessing characters by index is _probably_ a code smell in most places, especially if that string may contain arbitrary UTF-8.


Accessing string content by arbitrary indices is probably an error. Accessing string content by indices you got from previous lookups is useful for a number of situations.


If you have an index from a previous lookup, that can be a byte index.


You're right to the degree that people probably aren't using P6. :)


It's usually wrong, but you have a large number of people who don't get regular expressions. It's hard to visualize an automata crawling over a string and handing out matches.

The simpler mental model of splitting and splicing is easily grokable, so there's a lot of utility in supporting it.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: