Do you write the first compiler in another programming language? And the fully rewrite the compiler once the first compiler is mature enough to produce reliable builds, compile the new compiler on that first compiler, in order to have a compiler that is written in the same language as the one it’s compiling?

If this is the case, and this might be a stupid question, why would want to? You’ll essentially be throwing away potentially years of work on that first compiler just to have a circularly compiling programming language? What benefits could this have to make the extra effort worth it?

  • Ephera
    link
    52 years ago

    I mean, superficially there’s a ton of languages, but if you start having requirements, you quickly get to the ground of it.

    At the start of this year, I was looking for a language for a project where I basically wanted operations folks to write that programming language in order to configure their deployments.

    As sort of base requirements I had:

    • compiled, statically typed
    • strong typing with sum types
    • readable, high-level, powerful enough to define nice interfaces

    Into closer consideration got these:

    • Wren -> not actually statically typed
    • Zig -> too low-level
    • V -> too immature
    • Prolog -> too mind-bendy
    • OCaml -> objects are kind of bolted on, stdlib doesn’t really make use of them
    • Rust -> too low-level, strings are too clumsy
    • Nim -> significant whitespace, no interfaces/traits, Python-esque imports
    • Haxe -> Generates code in other languages which is hard to debug
    • Scala -> need to also know Java to use libraries, need JVM on target host

    At the end, I went with Scala, but I’m currently battling that JVM requirement (trying to compile native binaries with GraalVM) and mostly losing, so it’s certainly not ideal either.

    • Ephera
      link
      1
      edit-2
      2 years ago

      I should probably add, though, that obviously at the end of it, I did not write a new programming language. That is still a rather large endeavour.

      But I certainly considered it.
      Even just a Rust pre-processor might solve some of my problems, though it would probably create new problems, too.