Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Swift compile to native code?

Tags:

swift

Simple question really, however there doesn't seem to be a straight answer in the current developer documentation.

Does Swift compile to machine language (i.e. assembly), or does it compile to some intermediary form that then runs on a virtual machine?

(I suspect it does, but being unfamiliar with development in Apple's world it is not clear to me like it may be to someone who is.)

like image 698
markmnl Avatar asked Jun 05 '14 05:06

markmnl


People also ask

Is Swift code compiled or interpreted?

Swift is a compiled language means before producing the actual output Swift perform various activities. These activities are generally performed by the Swift compiler.

How does the Swift compiler work?

As a whole, the Swift compiler is principally responsible for translating Swift source code into efficient, executable machine code. However, the Swift compiler front-end also supports a number of other tools, including IDE integration with syntax coloring, code completion, and other conveniences.

Does Swift use a virtual machine?

Installing Swift (virtual machine)You can install Swift with an all-in-one virtual machine by following instructions here: http://swift.openstack.org/development_saio.html.

What is Swift compiler written in?

The Swift compiler is written mostly in C++, and this won't change in the near future. You can extend the standard library using Swift, but if you want to contribute a new language feature or some optimization, you'll need to write C++.


1 Answers

Yes, it compiles to machine language by way of LLVM Bitcode and, as @connor said, runs on top of the Objective-C runtime.

like image 157
David Berry Avatar answered Oct 11 '22 13:10

David Berry