How was the first C compiler written?

后端 未结 3 1356
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 15:27

Is it true that the first C compiler was written in C itself? Then, how was it executed and compiled? Or, was this compiler written in assembly language?

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 16:05

    Reading Dennis Ritchie's note on primevalC indicates that, rather like the chicken and the egg, C evolved from a precursor language along with its own compiler via bootstrapping. The speciation timescales were quicker than for Gallus gallus domesticus.

    One can even see the compiler source code caught in the midst of the evolutionary turmoil. The note links to two snapshots of it restored from tape backups. This code has also been placed on github. These snapshots constitute intermediate fossils, years before K&R syntax. Dennis' description of one of the tapes shows it is a freeze-frame of structs being bootstrapped:

    "prestruct-c" is a copy of the compiler just before I started changing it to use structures itself.

    In other words the compiler had been augmented to support structs but didn't yet use them. A good time to make a tape backup...

提交回复
热议问题