I especially liked Raymond's comment: "Compiler optimizations may have been carefully selected for expository purposes." Counterintuitive, and interesting that the Swift program demonstrates the effect as clearly as the C program.
Thanks. I do not see that when I use what I would think to be the straightforward way to count (using integers), though:
var count = Int()
for var i in array
{
i += negBoundary
let delta = (i > 0.0) ? 1 : 0
count += delta
}
(timed using mach_absolute_time(), on my system, that code also seems about twice as fast as the SIMD code)
I did not check whether that trigraph gets compiled to a branch (I tried, but I had trouble reading the disassembly that otool gave me; I’m not used to x86, and I found the code surprisingly long)
Swift is really starting to show it's superiority to ObjC. I think we'll see a very significant inflection point in iOS development when Swift is open sourced.
Since this all relates to simd.h it seems like it's taking advantage of C APIs which are equally available to Obj-C coders.
Swift seems great, but I wouldn't expect any huge technical advantages over Obj-C until Apple stops caring about Obj-C (which I suspect huge chunks of Cocoa are written in for starters).
You can choose to ignore their subtle messages (e.g. use Autolayout, Size Classes) but at some point in the not too distant future, you'll likely regret not starting with Swift earlier.
Oh, no argument there -- and I wouldn't call the messages subtle, either. That said, Apple would be insane to orphan its Obj-C codebase (but it may start deprecating...)
I was just pointing out that the original linked article isn't really about Swift, just an Apple framework that can be used with Swift.
Author here; that's not correct. Swift 2 introduced compiler support for the SIMD intrinsics that make this possible. It's listed directly as one of the new features of Swift 2.
So -- going back to the original point -- in fact this was Swift catching up with Obj-C, so it does pertain to Swift but is not evidence of Swift getting ahead of Obj-C.
I guess you didn't pay attention to this years WWDC. Apple pushed Swift harder than they have ever pushed anything else. 7 session mentioned Swift in their title , only one did Obj-C and Swift was also mentioned in that sessions title. Almost all of the examples were in Swift.
The message is clear: learn Swift or be left behind.
You obviously didn't pay attention to what I wrote.
I paid great attention to both WWDCs. In fact I read the Swift book immediately after the announcement. However, the point I am making remains true: Obj-C isn't going away soon and the linked article is not about Swift pulling away from Obj-C (indeed, it's about Swift catching up to Obj-C -- see author's comment elsewhere in thread).
In fact, here's a link to an article explaining how to bridge from Swift to Obj-C to make use of simd.h.
Although the language itself is clearly superior, Cocoa was written for objective c, so coding with this language still is a quite pleasant experience. I don't feel an urge to move to swift right now, but i'll certainly start learning it during the course of the year, and probably switch to it at the end of the year.
The big change will occure once we start to see apple framework designed for swift, using swift specific patterns, and then adapted to objective-c for compatibility purpose. But for now, it's still a wrapper on top.
http://blogs.msdn.com/b/oldnewthing/archive/2014/06/13/10533...
I especially liked Raymond's comment: "Compiler optimizations may have been carefully selected for expository purposes." Counterintuitive, and interesting that the Swift program demonstrates the effect as clearly as the C program.