67

Just read that Rusts compiler is written in Rust. How did they compile the first compiler?

Comments
  • 26
    As far as I know they wrote it the first time in another language and later wrote it in rust and compiled it with the first compiler. Correct me if i'm wrong.
  • 36
    They wrote it in c then they wrote it in rust. It's called bootstrapping. Gcc does the same.
  • 1
  • 3
    So what's first programming language? Did it need a compiler?
  • 27
    Can this be used to explain the chicken and the egg?
  • 4
    Assembler?
  • 5
    @FunkDelegate and before assembler there was switching bits on and off :D
  • 2
    @D3add3d Yeah, I know c-languages are third generation, so swiches are first gen and assembler is 2nd gen I guess.
  • 5
    @D3add3d
    Bellow assembly is machine language, which is implemented at the hardware level.
  • 17
    Yo dawg, I compiled a compiler so you can compile your compiler.
  • 1
    @azous but can it interpret?
  • 13
    Assembly is not even one language, it's a family of machine-specific languages. Assembler is not a language either, it's the code that translates an assembly flavor into machine code.

    For a new language, you write specs which tell compiler devs how the compiler must behave. Then a compiler is written in any existing language which can fully satisfy those specs.

    The first C compilers were written in B and assembly, and yeah, the further you go back the closer you get to punch cards and manual wire plugging.

    GCC is also not just a C compiler, it's a compiler collection written mainly in C and C++, with some Ada, Fortran, and Go.
  • 1
    @bittersweet
    GCC is the GNU Compiler Collection and includes GCC, the GNU C Compiler, among others (shitty naming scheme, I know). All compilers are written in C and C++ and share common code.
  • 2
    Does it means that the first implementation of C compiler depended on the machine they used somehow? Or is assembly the same on every hardware?
  • 2
    @Gnonpi
    All compilers are machine dependant since a compiler converts code written in a language like C to machine language, and machine language differs from architecture to architecture (x86 machine language is different from ARM machine language, which is different from POWER machine language). And, since assembly is basically just a nicer way to write machine language, assembly varies as well. The first C compiler was written in B and assembly, and the first B compiler was probably written in assembly.
  • 1
    @tiberius1900 thanks for the explanation. It's a part of computer science I never really studied.
  • 1
    I heard that Visual Studio team is using the latest commits to develop
  • 2
    Pretty sure it was written in OCaml first and then bootstrapped
  • 1
    @andros705
    You can't because JavaScript is interpreted, not compiled.
  • 2
    @andros705
    I guess my question would be: why?
  • 3
    @bittersweet Thank you!

    People confusing assembly and assember is one of those little technical things that annoys me.

    Like people confusing static typing and strong typing, but I'm more forgiving on that one because I also forget which is which most of the time :|

    I get that a lot of people here are learning and might not have known the difference, so for reference: An *assembler* converts *assembly/assembly language* into machine code.

    I'm a Grammar Nazi... Sorry :|
  • 1
    @FunkDelegate real men use Assembler.
  • 2
  • 1
    @tofonion Go binary if you want to. I'm not going to stop you.
  • 0
Add Comment