1. 27

  2. 3

    As often comes up here and on HN, it seems like self-hosting is often a step that young languages take to stress-test the language, but compiling a programming language is a different tasks than general purpose programming tasks.

    I’m curious if anyone knows of any relatively popular languages that did not go through the self-hosting-compiler stepping stone, and, if any, what project did those languages use to sort of “prove themselves”?

    1. 3

      Swift hasn’t gone self-hosting at least yet, the compiler is still in C++.

      1. 2

        Rust is not self-hosting too since they rely on LLVM and rustc is not sufficient to build rustc from source.

        1. 2

          Thinking for like 30 seconds more, I have a list:

          • C# (recently it is self-hosting but was popular before self hosting)
          • python, javascript, ruby, php, R; although not sure if interpreted languages count

          It looks like most of the other relatively-mainstream (non-interpreted) languages took the self-hosting route so maybe there aren’t any success stories/project examples for languages that took a different approach

          1. 1

            Sticking with just compiled languages, these don’t have self-hosting compilers (brackets show compiler implementation language): Java (C++), D, Objective-C, Julia (all C/C++ and LLVM), Elm (haskell), etc. Fortran probably had a self-hosted compiler at one point, but nowadays all the implementations are in C.

            1. 2

              I didn’t include java b.c. this wikipedia page lists it as a language with self-hosting compiler: https://en.wikipedia.org/wiki/Self-hosting_(compilers) but I don’t see any evidence of that anywhere else.

              Objective-C and Fortran/Julia are both interesting as far as the how did they prove themselves question goes. Both sort of had a target market in mind, so they just started building things to meet the needs of that market. I suppose elm falls into that category as well.

              I guess something like a web server or database might be a good proof-of-viability for a language like zig as well, however, it looks like my premise for “why selfhost” is wrong in zig’s case, see: https://github.com/ziglang/zig/issues/89#issuecomment-328214707

              1. 4

                IMO the most compelling pro for self-hosting is that everyone who uses the language can read/debug/extend the compiler. Its much easier to onboard new contributors if you don’t require expertise in an additional language.

        2. 3

          The comments wondering about whether Zig made the right call requiring libraries to handle allocation failure individually makes for a great read. As noted by khim, the linked Why Zig when there’s already X language is also a great introduction.