And C needs C, or for more recent compilers, C++ needs C++. You just don't notice it because these two languages are already part of the base system.
And C needs C, or for more recent compilers, C++ needs C++. You just don't notice it because these two languages are already part of the base system.
So, bootstrapping matters to me, and the bootstrapping story for anything involving LLVM isn't very good (I'm actually having some problems with a language other than Rust in this regard).
Interpreters you can generally build fairly easily from source (Lua, Ruby, Python, Tcl, for example). But when it comes to compilers, bootstrapping is generally a much bigger obstacle. There are a few notable exceptions that only require a C compiler, no internet access during their build, and build in an acceptably short time:
* OCaml bootstraps from C via a bytecode interpreter, which is then used to build the native compiler. On my laptop (using four cores), I can actually do that in under a minute (two minutes if I want flambda).
* Nim compiles to C and hence builds in half a minute on the same machine from C sources.
* LuaJIT builds in a few seconds, assuming a dynamically typed language with a JIT compiler is sufficient for you.
most any scheme/lisp compiler as well
requiring internet access and binary bootstrap toolkits thing for the core piece of an ecosystem (e.g. the language compiler) is decidedly new-school, rooted in overly commercial projects, and for the worst, imho.
ps: lawn.
Every time you add a new language feature you increase them time to write your bootstrapping compiler. Garbage collection means you will spend a few more months building a garbage collector. (remember we are writing in machine language so most of the abstractions you are used to dealing with - even in assembly - are missing. Thus complexity is growing exponentially)
How is this a large advantage? When was the last time someone actually did this?
https://github.com/Wilfred/babyc http://www.sigbus.info/how-i-wrote-a-self-hosting-c-compiler... http://zserge.com/blog/cucu-part1.html https://c9x.me/qcc/ https://github.com/alexfru/SmallerC
I believe that Niklaus Wirth created his first self hosting implementation in a small subset of the language and expanded from there. Anyone thinking about doing this for a non-trivial language should consider following that example.
That's painful. It's one big point which Nim [1] does better. It compiles to C and bootstraps from C. That makes porting to other platforms much easier.
I don't understand why Haskell and Rust don't provide bootstrapping from C. Did they write the first compilers with Assembler?
> You just don't notice it because these two languages are already part of the base system.
C (not C++) has become the essential foundation on any platform. You will likely not be able to sell your embedded system unless it supports C.
I don't know about Haskell, but the first Rust compiler was written in OCaml. See for instance the comments at https://www.reddit.com/r/rust/comments/6nt2j1/is_there_any_e...
Interesting! So, it should basically be possible to bootstrap from source using OCaml and the old source from the Git repository.
It's interesting that OCaml was used to develop Rust since OCaml is also used for formal verification of SPARK (a dialect of Ada) which is another language for safety critical applications. OCaml seems to be a good choice to invent new big languages.
We don't provide bootstrapping from C because no C-based toolchain has ever existed. However, it may in the future; see my link upthread.
The key word here is 'start'. I don't like to arbitrarily constrain tools, but I've always felt that cross-compilers were sort of a last resort, ie, you don't have a native compiler (you're writing the compiler or operating system), or are really pressed for time. Once you've got a native compiler, that should be it: self-hosted from there on.
Unless you are talking about an architecture which doesn't have llvm backend, it takes the same effort as nim to port rust and haskell.
> Did they write the first compilers with Assembler?
Rust was written in Ocaml first, bootstrapping from C need decent amount of effort. I don't know the origins of haskell.
Nim doesn't depend on LLVM. It works also with GNU C.
There is also no effort to maintain the "old" version as a strict "bootstrap" since everyone just has binaries of the previous version lying around. :)
> The C code generator is only supported when GHC is built in unregisterised mode, a mode where GHC produces 'portable' C code as output to facilitate porting GHC itself to a new platform.
> Support for cross-compilation works reasonably well in 7.8.1. Previous versions had various issues which are usually work-aroundable.
(7.8.1 was released in 2014, GHC itself is 25 years old)