[フレーム]
BT

InfoQ Software Architects' Newsletter

A monthly overview of things you need to know as an architect or aspiring architect.

View an example

We protect your privacy.

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Unlock the full InfoQ experience

Unlock the full InfoQ experience by logging in! Stay updated with your favorite authors and topics, engage with content, and download exclusive resources.

Log In
or

Don't have an InfoQ account?

Register
  • Stay updated on topics and peers that matter to youReceive instant alerts on the latest insights and trends.
  • Quickly access free resources for continuous learningMinibooks, videos with transcripts, and training materials.
  • Save articles and read at anytimeBookmark articles to read whenever youre ready.

Topics

Choose your language

InfoQ Homepage News Apple Releases Swift, a High-performance High-level Language for iOS and OSX

Apple Releases Swift, a High-performance High-level Language for iOS and OSX

Leia em PortuguÃas

This item in japanese

Lire ce contenu en français

Jun 03, 2014 2 min read

Write for InfoQ

Feed your curiosity. Help 550k+ global
senior developers
each month stay ahead.
Get in touch

Today at WWDC 2014, Apple announced the beta availability of a new programming language, Swift, which is set to ship with iOS 8 and OSX Yosemite later this year. Swift is a high-level programming language that will be familiar to JavaScript developers, but is compiled using LLVM to produce highly performant executable code for both OSX and iOS platforms.

Apple has heavily invested in LLVM technologies, which provide an abstract instruction set that can be translated for specific architectures. Clang replaced GCC as the compiler of choice for C and Objective-C programs, and both of those are translated with Clang into LLVM instructions, which are then optimised into an executable for the platform. The new programming language, Swift, produces LLVM bytecode in the same way and can co-exist with existing Objective-C applications and libraries.

In addition, swift also comes with a REPL environment for testing code. Normally used by interpreted languages such as JavaScript or Python, a REPL provides a Read-Evaluate-Print Loop that can be used to evaluate individual expressions and statements at the command line for easy debugging. Combined with powerful looping, string interpolation and printing/debugging options, it allows an interactive style of development and testing that is frequently missing for compiled languages such as C and Java.

Swift is a strongly typed language, though it uses type inference to reduce the amount of characters typed by the developer. Types can be provided explicitly, and for numeric types, specific sized elements such as UInt8 or Int32 can be used.The type engine also provides for Optional valued types; an optional value can be dereferenced with a ? or ! depending on whether the value is expected to exist. The collections in Swift provide literal support for both arrays (with []) and dictionaries/maps (with [:]) and can include generic types.

Functions are also first class elements in the language, and can be used to pass functions as variables to other elements. Arguments can also be named explicitly (which provides compatibility with Objective-C’s named arguments) or provided as positional arguments only. Parameters can also have default values, allowing arguments to be omitted if not required.

The swift integration can use Objective-C objects, both from the standard libraries (such as UIKit or Cocoa) as well as user-defined types. Classes can also be created in swift natively (which can then also be used from Objective-C) which, like other Objective-C objects, are reference counted. (The references are managed automatically by the runtime, so the user does not need to worry about memory management in swift directly.) As well as classes, which are reference types, it is possible to create struct value types that can be passed by copy as values to function types.

Finally swift has multiple return types, through the use of tuples. These tuples can be used in matching semantics (with the case statement) or variable assignment.

Swift is available via the Xcode 6 developer preview, and will be released in production in the next few months. At this time, there is no confirmation that the swift language will be merged upstream with LLVM, but having recently merged the ARM 64-bit support and worked on the fast JIT for Safari’s JavaScript, it is likely that some of it will fold into the upstream clang runtime hosted by LLVM. This could provide the ability for swift programs to be written for other architectures where there is a clang compiler.

Rate this Article

Adoption
Style

This content is in the OSX topic

Related Topics:

Related Content

The InfoQ Newsletter

A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example

We protect your privacy.

BT

AltStyle によって変換されたページ (->オリジナル) /