Search code examples
swiftcompiler-construction

Is the swift-2.0 compiler self-hosting?


What language is the Swift 2.0 compiler written in? C++?

Would a self-hosting swift be more powerful? More desirable?

How does Swift's compiler API compare with F#'s or https://github.com/dotnet/roslyn?


Solution

  • What language is the swift-2.0 compiler written in? C++?

    We can't yet say for sure if it's entirely in C++, because Apple hasn't released the source yet. We know it's built on LLVM so large parts are C++. Possibly some parts are written in Swift, but Apple hasn't revealed any Swift/C++ integration so I kind of doubt it.

    Would a self-hosting swift be more powerful?

    Unlikely. All Turing-complete languages are equally “powerful” in terms of what they can output. Some algorithms are easier to implement in language X than in language Y, but gcc (written in C and C++) and clang (written in C++) already implement many sophisticated optimizations, so this isn't a strong argument.

    More desirable?

    Maybe. Some languages are more “powerful” than others in terms of how conveniently you can achieve certain goals. For example, the pattern matching support in languages like ML and Haskell can be very useful in compiler implementation, but I don't know if Swift's pattern matching is particularly useful in that way.

    How does Swift's compiler API compare with F#'s or https://github.com/dotnet/roslyn?

    Impossible to say, since Swift has no public compiler API yet.