<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 17, 2016 at 5:03 PM, Kenny Leung via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Aug 17, 2016, at 1:57 PM, William Sumner <<a href="mailto:prestonsumner@me.com">prestonsumner@me.com</a>> wrote:<br>
<br>
> You may be interested in this article by Mike Ash, which gives a rationale for the String API, including why indexes aren't simple integers: <a href="https://www.mikeash.com/pyblog/friday-qa-2015-11-06-why-is-swifts-string-api-so-hard.html" rel="noreferrer" target="_blank">https://www.mikeash.com/<wbr>pyblog/friday-qa-2015-11-06-<wbr>why-is-swifts-string-api-so-<wbr>hard.html</a><br>
<br>
</span>Thanks for the pointer.<br>
<br>
I guess being told *why* the String API is so hard doesn’t make me feel much better about the fact that it *is* hard.<br>
<br>
It opens:<br>
<br>
“One of the biggest complaints I see from people using Swift is the String API. It's difficult and obtuse, and people often wish it were more like string APIs in other languages.”<br>
<br>
It’s been said on the list that they are thinking about rewriting the String at some point. I’m hoping that the API can be made simpler.<br></blockquote><div><br></div><div>I too am excited to see what improvements may come.</div><div><br></div><div>That said, the Swift String APIs are far and away *the best* string APIs I've ever worked with, precisely because they promote _correct_ code in so many ways that alternative "simpler" APIs don't. It's exactly this learning process, where you learn that index-based slicing of NSString is unsafe and that traversing Strings character-by-character is computationally expensive, and then you find that you don't need to use either the unsafe or the expensive methods after all, that reveals the power of the design. As a result, you now have a Unicode-ready *and* performant slice algorithm. The fact that you've been guided to this end result by the API design is precisely what makes me appreciate it so much!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
-Kenny<br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div></div>