Was the original C compiler written in some old assembly language and now later flex and bison are used instead?

  • 3
    – ninjalj
    Commented Jul 2, 2017 at 10:48
  • 9
    It was written in C. What do "flex and bison" have to do with anything? Commented Jul 2, 2017 at 11:00
  • 5
    What are flex and bison? Commented Jul 2, 2017 at 13:17
  • 11
    But C existed well before flex and bison (and GNU). The predecessors of flex and bison were lex and yacc.
    – mannaggia
    Commented Jul 2, 2017 at 16:18
  • 10
    It might be worth mentioning that modern compilers like gcc normally don't use generated lexers and parsers anymore.
    – tofro
    Commented Jul 2, 2017 at 21:56

2 Answers 2


C didn't spring into being suddenly, but was created by slowly modifying the B language--which was written in itself. Therefore you might say that C was always written in itself, but at first it was just a slightly modified B.

Dennis Ritchie describes the evolution of C in The Development of the C Language. He started by making small improvements to the B language:

In 1971 I began to extend the B language by adding a character type and also rewrote its compiler to generate PDP-11 machine instructions instead of threaded code. Thus the transition from B to C was contemporaneous with the creation of a compiler capable of producing programs fast and small enough to compete with assembly language. I called the slightly-extended language NB, for `new B.'

Eventually, he made enough changes that the language deserved a new name:

After creating the type system, the associated syntax, and the compiler for the new language, I felt that it deserved a new name; NB seemed insufficiently distinctive. I decided to follow the single-letter style and called it C, leaving open the question whether the name represented a progression through the alphabet or through the letters in BCPL.

  • 3
    So was there also a language called "A" that B was originally written in?
    – user5318
    Commented Jul 2, 2017 at 22:30
  • 15
    @coderworks B was written in BCPL which was written in CPL, which was written in and influenced by ALGOL 60. So in a roundabout way, kind of.
    – cat
    Commented Jul 3, 2017 at 0:01
  • 10
    @coderworks by the way, D is also written in C (and D) :D
    – cat
    Commented Jul 3, 2017 at 5:21
  • 4
    @cat +1 to your comment for your punny smiley. I typically don't favor the :D variation of a smiley, but in this case it was the most appropriate. Kudos.
    – TOOGAM
    Commented Jul 4, 2017 at 6:36
  • 6
    @TOOGAM Oh, I appreciate your PhD thesis of a comment on why you upvoted ;)
    – cat
    Commented Jul 4, 2017 at 9:14

As is evident from its name, YACC (Yet Another Compiler Compiler) was not the first compiler writing aid. Its predecessor was the TMG tool.

TMG was the compiler definition tool used by Ken Thompson to write the compiler for the B language on his PDP-7 in 1970. B was the immediate ancestor of C.

The tmg executable can still be seen on the UNIX V6 disks, along with yacc. In UNIX V7, AFAIR, tmg was already omitted.

  • 2
    There were many many others besides TMG. Floyd described one in the Floyd Production Language paper around 1963; WIlliam Waite had one in the late 1960s; many others. Hence 'yet another'.
    – user207421
    Commented Jul 4, 2017 at 1:21
  • 2
    @EJP Sure, but it was specifically TMG that figured in the development lineage of the C language.
    – Leo B.
    Commented Jul 5, 2017 at 19:23
  • 1
    The original "compiler compiler" (by that name) was written by Tony Brooker and Derrick Morris in 1960.
    – dave
    Commented Jan 21, 2021 at 13:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .