On 6 Jul, 2014, at 1:38 am, Jens Alfke < email@hidden> wrote: On Jul 5, 2014, at 6:48 AM, Gerriet M. Denkmann < email@hidden> wrote: Swift is 200 times slower: 1.7 ↔ 0.0085 sec Probably I am not using Swift very expertly. Also I know that this is not the final version of Swift - but still.
If you’re getting such huge differences, then I suspect you’re doing something wrong.
I think this may be what I found quite quickly when trying to write Swift, and it's something I haven't quite gotten past yet.
Apart from some of the frustrations with the language, which are going to get fewer over time, I found my code looked for all the world like objective-c objects and C constructs driven by Swift statements. I wasn't using tuples and generics and other Swift language features, I was assigning ObjC variables to Swift variables and then calling the usual ObjC methods on them. That includes the ones which don't currently translate very prettily over to Swift like the enumerations I was talking about the other day.
I'm expecting that Swift will start to grow its own native class library at some point, either by adding some more native-looking Swift-only extensions on some of our old favourite ObjC classes, which encourage developers to stay in the Swift paradigm, or by more explicitly bridged basic workhorse types (on top of string, array and dictionary which already are). I find that having most of the functionality of a string provided by NSString methods is clever and brings lots of functionality very quickly, but somehow it keeps my brain writing ObjC-Swift. Before long I want an NSData and .. now I'm really writing ObjC again.
Perhaps this will change with time as I write more Swift classes and the language evolves to give Swift itself more native depth. Until then my Swift attempts are cyborgs, and they are neither pretty, easy to understand nor terribly performant.
Hey there's a book idea there somewhere, Swift for dyed-in-the-wool Objective-C programmers.
|