Swift Is Fast Now

Today, I update the Xcode 6 Beta 3 and retest the bubble sort that I wrote yesterday. In Beta 3, bubble sort is done in 11 miliseconds in Debug Mode. Before it done in 14 miliseconds. After that I changed to the Release Mode and run it. It done in the 0.15 miliseconds. Yes, this time swift is faster than Objective-C now. In objective-C , it done in 0.28 miliseconds.

Swift Programming Language book has been updated and you need to update it.

Changes in Xcode 6 beta 3 for Swift are

  • Array in Swift has been completely redesigned to have full value semantics like Dictionary and String have always had in Swift. This resolves various mutability problems – now a ‘let’ array is completely immutable, and a ‘var’ array is completely mutable – composes properly with Dictionary and String, and solves other deeper problems. Value semantics may be surprising if you are used to NSArray or C arrays: a copy of the array now produces a full and independent copy of all of the elements using an efficient lazy copy implementation. This is a major change for Array, and there are still some performance issues to be addressed. Please see the Swift Programming Language for more information. (17192555)!
  • The Array and Dictionary “sugar” syntax has been redesigned: You now declare arrays as [Int] instead of as Int[], as shorthand for Array. The old syntax made sense when arrays had semantics closer to C arrays, but would be misleading with the new value semantics approach. Along with this, Dictionary syntax has improved so that [Key:Value] is treated as sugar for Dictionary. Both of these are now consistent with each other and with the literal syntax used to build an array or dictionary. Please see the Swift Programming Language for more information.!
  • NSDictionary* is now imported from Objective-C APIs as [NSObject : AnyObject]. (16870626)!
  • The half-closed range operator has been changed from .. to ..< to reduce confusion and ambiguity. Now the two range operators are ..< and … for half-closed and closed ranges, respectively (17203527).!
  • nil is now a literal in the language, not a global constant of _Nil type. This change resolved a number of problems with nil; e.g. nil in a collection, nil converting to Any, etc. Types can now indicate that they are nil compatible by conforming to the NilLiteralConvertible protocol. (16951729)!
  • APIs imported from C no longer use type aliases like CInt or CFloat, which obfuscated the underlying type. They are now imported as Int32 and Float, etc.!
  • APIs imported from C that use C pointers are now imported with a much simpler API type structure which is more predictable, preserves const mutability in more cases, and preserves __autoreleased pointer information. Now you will see UnsafePointer, ConstUnsafePointer, AutoreleasingUnsafePointer, etc. Function pointers are also imported now, and can be referenced and passed around. However, you cannot call a C function pointer or convert a closure to C function pointer type.!

You can read more at here

comments powered byDisqus