News for hackers. Stuff that matters.
Re:Why Is Swift's String API So Hard? by grey-area on Friday November 06, 2015 @11:01AM (#10520126)
Isn't this quite common? Most languages allow you to represent those strings as different types and parse them/to from a plain string representation.

From Ruby: String, Pathname, Url, ActiveRecord::Relation etc or from Go: strings, database/sql stmt + orm types built on top, net/url etc though file paths are just strings.

Re:Why Is Swift's String API So Hard? by MrBuddyCasino on Friday November 06, 2015 @11:29AM (#10520283)
It is, even Java does that.

Where it gets interesting is advanced trickery, as performed by Haskell. You can have a type String that cares of escaping/unescaping stuff that comes from tainted sources in a webapp, eliminating a whole lot of security issues. Thats just one example I know, but I'm not a Haskell guy - there are surely more.

Re:Why Is Swift's String API So Hard? by mozumder on Saturday November 07, 2015 @05:57AM (#10524429)
Yep. He basically just described "classes" in the object-oriented world.
Re:Why Is Swift's String API So Hard? by tokenrove on Saturday November 07, 2015 @09:07AM (#10524815)
I don't think it has much to do with classes. Python, for example, has no pathname/string distinction that I know of.

Common Lisp is in the object-oriented world, and indeed some of the things mentioned are implemented as classes. I think the point was more about the standard library's attempt to do The Right Thing and how library implementors tend to follow that.

(Also, for better or for worse, CL's pathnames contain information like host, device, and version, that aren't so relevant on the major OSes in use these days; but try dealing with VMS filenames with Ruby's Pathname...)

Re:Why Is Swift's String API So Hard? by lispm on Saturday November 07, 2015 @06:29PM (#10526657)
Device and even host are quite common in the Windows world:

https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...

Volume = Device

Or Microsoft's UNC path:

https://en.wikipedia.org/wiki/Path_(computing)#Uniform_Namin...

\\ComputerName\SharedFolder\Resource -> \\host\device\path