Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> go needs go, haskell needs haskell, rust needs rust

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.

[1] https://nim-lang.org



Rust's first compilers were written with OCaml.

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.


I think bootstrap with OCaml is ok - if just bootstrap from source becomes possible at all. Binary-only dependency is awful when Rust is wanted on yet unsupported systems.


It's not a significant issue if you can accept cross-compiling. This is how most platforms get their start.


> This is how most platforms get their start.

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.


> I don't understand why Haskell and Rust don't provide bootstrapping from C. Did they write the first compilers with Assembler?

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...


GHC has a special mode (not available in released builds) that compiles Haskell to plain old C, which can then be compiled by any other C compiler. Of course when compiled in such manner, Haskell code runs very slowly but it works.


> See for instance the comments ...

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.


> 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.

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.


> Unless you are talking about an architecture which doesn't have llvm backend

Nim doesn't depend on LLVM. It works also with GNU C.


Yes, i was talking about rust and haskell. How many architectures out there that don't have llvm backend but only gcc?(excluding the microcontrollers with very little RAM(<1M))


haskell was C-bootstrap-able many versions ago, but you need the previous version to build the next from that point forward so it's quite a dance.

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. :)


GHC is still C-boostrap-able. That's literally the only reason why the C backend still exists:

> 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.


so GHC can generate C code to bootstrap GHC?


GHC can compile GHC (or Haskell in general) to C, the main use case being bootstrapping GHC without cross-compilation, as the latter has historically been lacking:

> 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)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: