OT: Swift is now open source
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Thu Dec 3 23:51:32 PST 2015
On 2015-12-03 20:10, Steven Schveighoffer wrote:
> The truth is, swift is orders of magnitude better than Objective C.
>
> I have gotten used to the nullable API, though it sometimes seems more
> clunky than useful.
I find it very clunky as well. Sometimes it's too strict. I was a bit
surprised when I noticed that converting from an integer to an enum
returned an optional.
> Apple's API is still rather verbose and hard to discover, but that is not swift's fault.
They could have gone the D route by separating the method name from the
selector:
extern(Objective-C) class Foo
{
void bar()
@selector("thisIsMyReallyLongSelector:withAnotherSelector:");
}
> And the lack of semi-colons has poisoned me from writing syntactically
> valid lines in D :)
>
> I miss D's algorithms and range API when working with swift. A lot. I've
> tried to use their sequence API, but it's very confusing.
I have not used it much, but I think it it's quite alright. But it's
ridicule complicated to slice a string in Swift compared to D. One needs
to pass in a range of a specific index type.
var str = "Hello, playground"
str.substringWithRange(Range<String.Index>(start:
str.startIndex.advancedBy(2), end: str.endIndex.advancedBy(-1))) //"llo,
playgroun"
[1]
One thing I really don't like in the D algorithms is "find". Instead of
returning the actual element it returns the "rest" of the range.
Although Swift doesn't even have "find" (as far as I can see) the use of
optional types would be perfect here.
[1] http://stackoverflow.com/a/24045156
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list