Jump to content

Swift 1.2 features an improved compiler and Objective-C interactions


Recommended Posts

Guest Derek Kessler
Posted

06bf28d1f941ca164ff13936e868cc06.jpg

 

Apple's youngest programming language, Swift, received a fairly substantial update with today's first beta of Xcode 6.3, at least in beta form. The Swift 1.2 beta features an improved compiler that's both more stable and more speedy, as well as new Objective-C (the programming language that pre-Swift iOS apps were built on) interactions for building more capable hybrid apps.

 

 

Here's what's new in the compiler:

 

  • Incremental builds — Source files that haven't changed will no longer be re-compiled by default, which will significantly improve build times for most common cases. Larger structural changes to your code may still require multiple files to be rebuilt.

  • Faster executables — Debug builds produce binaries that run considerably faster, and new optimizations deliver even better Release build performance.

  • Better compiler diagnostics — Clearer error and warning messages, along with new Fix-its, make it easier to write proper Swift 1.2 code.

  • Stability improvements — The most common compiler crashes have been fixed. You should also see fewer SourceKit warnings within the Xcode editor.

 

In addition to the enhanced and improved compiler, Swift 1.2 also features improvements to the language itself:

 

  • as! for failable casts — Casts that can fail at runtime are now expressed with the new as! operator to make their potential for runtime failure clear to readers and maintainers of your code.

  • Nullability may now be expressed in Objective-C headers — New Objective-C extensions in Clang allow you to express the nullability of pointers and blocks in your Objective-C API. You can provide Objective-C frameworks that work great with Swift code, and improve your Swift experience when mixing and matching with Objective-C code in your own project.

  • Swift enums can now be exported to Objective-C using the @objc attribute.

  • let constants are now more powerful and consistent — The new rule is that a let constant must be initialized before use (like a var), and that it may only be initialized, not reassigned or mutated after initialization.

  • More powerful optional unwrapping with if let — The if let construct can now unwrap multiple optionals at once, as well as include intervening boolean conditions. This lets you express conditional control flow without unnecessary nesting.

  • New native Set data structure — An unordered collection of unique elements that bridges with NSSet and provides value semantics like Array and Dictionary.

 

As this is a beta of Swift 1.2 these features are, naturally, subject to change in behavior and implementation, and might not work perfectly out of this preliminary gate. But if you're in the developer beta program, definitely check it out and see what you can do with these new additions to the language.

 

Source: Apple

 

850537ea260278f661f9b79eab522b10.gif

 

 

b71d493c13ef0a0162fa24d2f7312087._.png

2a49a0b0cc58695905b4a165c6b90528._.gif

62998c06086402b6d7f4a9528c4c53b8._.gif

 

345dd516e3780163653e897e22b9dcdd._.giffbe278f9f482b6ed6f48a7ccc938c691._.gif53784ded532d6d68fc0afd0294199d2f._.gif

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...