"The C compiler is Written in C" What!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Unbiased_me

    "The C compiler is Written in C" What!

    Hi There

    I recently read in book that the C compiler is written in C. I unable
    to comprehend the concept behind this. How is the compiler design
    started...Where dodoes one start.

    I tried Googling for the answer that C is written in C, however the
    web search proved futile.

    C # and .net is written in .net...What!, and the list goes on

    Manas Mittal
  • Joona I Palaste

    #2
    Re: "The C compiler is Written in C" What!

    Unbiased_me <mailmethere@ya hoo.com> scribbled the following:[color=blue]
    > Hi There[/color]
    [color=blue]
    > I recently read in book that the C compiler is written in C. I unable
    > to comprehend the concept behind this. How is the compiler design
    > started...Where dodoes one start.[/color]

    "The C compiler"? There's more than one, you know. Lots of them, in
    fact. Some of them are written in C, some aren't.

    How does one write a C compiler in C? Generally, by using another C
    compiler. That C compiler is usually either compiled in advance, or
    written in another language.
    It is even possible to compile a C compiler with itself. This process,
    which is called bootstrapping, enables additional compiling, where each
    successive compilation of the compiler adds more features.
    [color=blue]
    > I tried Googling for the answer that C is written in C, however the
    > web search proved futile.[/color]
    [color=blue]
    > C # and .net is written in .net...What!, and the list goes on[/color]

    Off-topic.
    [color=blue]
    > Manas Mittal[/color]

    --
    /-- Joona Palaste (palaste@cc.hel sinki.fi) ---------------------------\
    | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
    | http://www.helsinki.fi/~palaste W++ B OP+ |
    \----------------------------------------- Finland rules! ------------/
    "As we all know, the hardware for the PC is great, but the software sucks."
    - Petro Tyschtschenko

    Comment

    • Malcolm

      #3
      Re: &quot;The C compiler is Written in C&quot; What!


      "Unbiased_m e" <mailmethere@ya hoo.com> wrote[color=blue]
      >
      > I recently read in book that the C compiler is written in C. I unable
      > to comprehend the concept behind this. How is the compiler design
      > started...Where dodoes one start.
      >[/color]
      It's called bootstapping. It's traditional for a compiler to compile itself.

      To achieve this magic you first need a C compiler on another machine, or
      alternatively a c interpreter - very slow and inefficient but enough to get
      the first version of the compiler working.


      Comment

      • Emmanuel Delahaye

        #4
        Re: &quot;The C compiler is Written in C&quot; What!

        In 'comp.lang.c', mailmethere@yah oo.com (Unbiased_me) wrote:
        [color=blue]
        > I recently read in book that the C compiler is written in C. I unable[/color]

        Nonsense. The is no "The C compiler". There are thousand of C compilers.
        [color=blue]
        > to comprehend the concept behind this. How is the compiler design
        > started...Where dodoes one start.[/color]

        You believe that you are facing to a kinda egg and chicken paradox. Well,
        it's not completely false. It's obvious that the very first C compiler ever
        written was not written in C, but more probably in assembly language or
        possibly in a predate language like BCPL.
        [color=blue]
        > I tried Googling for the answer that C is written in C, however the[/color]

        - 'C' is just a letter of the alphabet.

        - The C langage is a syntactic and semantic definition. It's a big book
        written in text with characters. Nothing else, nothing more. It's called the
        C standard.

        - A C source (.c) is just a plain text file. It contains a program written in
        C according to the syntax and semantic defined by the C standard.

        - A C compiler is a program that takes C sources and translate the to
        assembly of machine code. (Actually, the job is completed by the linker)
        [color=blue]
        > web search proved futile.[/color]

        You asked the wrong question.

        Try "how was the first C compiler written"

        3rd answer:

        🔑Surf like a Boss! Unleash the indomitable power of our lightning-fast, rock-solid VPN shield. Maximum cybersecurity and privacy protection. Built on WireGuard

        [color=blue]
        > C # and .net is written in .net...What!, and the list goes on[/color]

        Nonsense again.

        --
        -ed- emdelYOURBRA@no os.fr [remove YOURBRA before answering me]
        The C-language FAQ: http://www.eskimo.com/~scs/C-faq/top.html
        <blank line>
        FAQ de f.c.l.c : http://www.isty-info.uvsq.fr/~rumeau/fclc/

        Comment

        • Keith Thompson

          #5
          Re: &quot;The C compiler is Written in C&quot; What!

          Emmanuel Delahaye <emdelYOURBRA@n oos.fr> writes:
          [...][color=blue]
          > You believe that you are facing to a kinda egg and chicken paradox. Well,
          > it's not completely false. It's obvious that the very first C compiler ever
          > written was not written in C, but more probably in assembly language or
          > possibly in a predate language like BCPL.[/color]

          It would also be possible to write the first compiler for a given
          language in the language itself, then manually translate it to some
          other language (either assembly or a similar high-level language) and
          compile the manually translated sources. In this approach, in the
          very early development stages, a human is part of the compilation
          process. Once this first stage yields a working compiler, it can be
          used to compile the original sources directly, and manual translation
          is no longer necessary.

          Further development typically consists of implementing a new feature
          in version N, then making use of it (if appropriate) in version N+1.

          --
          Keith Thompson (The_Other_Keit h) kst@cts.com <http://www.ghoti.net/~kst>
          San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
          Schroedinger does Shakespeare: "To be *and* not to be"

          Comment

          • Glen Herrmannsfeldt

            #6
            Re: &quot;The C compiler is Written in C&quot; What!

            "Unbiased_m e" <mailmethere@ya hoo.com> wrote in message
            news:43797288.0 307260936.7ea88 22c@posting.goo gle.com...
            [color=blue]
            > I recently read in book that the C compiler is written in C. I unable
            > to comprehend the concept behind this. How is the compiler design
            > started...Where does one start.
            >
            > I tried Googling for the answer that C is written in C, however the
            > web search proved futile.[/color]

            It is usual to write a compiler in the language that it compiles. If
            existing compilers exist, the first compiler can be compiled on
            another compiler (possibly on another machine), and then the result
            used to compile the new one.

            If no existing compilers exist, a simple (subset) compiler is written
            in another language to compile a simple version of the new one, and
            slowly add to it.

            While C compilers written in C are common, I do know of at least one
            Fortran compiler written in Fortran. That is not so common.

            There are a number of good books on compiler design that will explain this.

            -- glen

            Comment

            • Larry__Weiss

              #7
              Re: &quot;The C compiler is Written in C&quot; What!

              Unbiased_me wrote:[color=blue]
              > I tried Googling for the answer that C is written in C, however the
              > web search proved futile.
              >[/color]

              Try:

              Comment

              • bd

                #8
                Re: &quot;The C compiler is Written in C&quot; What!

                On Sat, 26 Jul 2003 10:36:49 -0700, Unbiased_me wrote:
                [color=blue]
                > Hi There
                >
                > I recently read in book that the C compiler is written in C. I unable
                > to comprehend the concept behind this. How is the compiler design
                > started...Where dodoes one start.[/color]

                The first C compiler was not written in C. Many of the rest were, however.
                [color=blue]
                > I tried Googling for the answer that C is written in C, however the
                > web search proved futile.
                >
                > C # and .net is written in .net...What!, and the list goes on[/color]

                They were probably C originally.

                --
                Freenet distribution not available
                I don't want to be young again, I just don't want to get any older.

                Comment

                • Manas Mittal

                  #9
                  Re: &quot;The C compiler is Written in C&quot; What!

                  Thank You People for your responses. It really helped me, especially
                  the reference to 'bootstrapping' which allowed me to delve further on
                  the topic.

                  Thank You

                  Manas Mittal
                  mailmethere@yah oo.com

                  Comment

                  • Villy Kruse

                    #10
                    Re: &quot;The C compiler is Written in C&quot; What!

                    On 31 Jul 2003 00:18:39 -0700,
                    Suresh Kumar J <suresh@sankhya .com> wrote:

                    [color=blue][color=green]
                    >> I recently read in book that the C compiler is written in C. I unable[/color]
                    >
                    >Yes ! It was an iterative process that assembly language was used to
                    >build a C compiler (basic C features) initially. Then the basic
                    >C compiler was used to build C Compiler with full C features.
                    >
                    >If you see GNU CC, The native C compiler is used to build C/C++
                    >compilers for cross target/platforms.
                    >[/color]

                    The GNU C compiler is by the way written in K&R so any very old native
                    pre-ANSI C compiler can compile it.



                    Villy

                    Comment

                    • Marco van de Voort

                      #11
                      Re: &quot;The C compiler is Written in C&quot; What!

                      > While C compilers written in C are common, I do know of at least one[color=blue]
                      > Fortran compiler written in Fortran. That is not so common.[/color]

                      Pascal compilers are usually also written in Pascal. (open source
                      example: Free Pascal - www.freepascal.org)

                      Exceptions: GNU Pascal (as gcc derivative), and Delphi v2+ (in C++,
                      the runtime system is entirely Pascal though)

                      The last one is quite funny, since IIRC Borland's C++ builder's
                      runtime system depends (at least in the earlier versions) on the
                      Pascal classes libs, so essentially you got a C++ compiler linking to
                      partially pascal libraries, and that part of the libraries in pascal
                      were compiled by a pascal compiler written in C++.

                      Comment

                      • Rinie Kervel

                        #12
                        Re: &quot;The C compiler is Written in C&quot; What!

                        > > I recently read in book that the C compiler is written in C. I[color=blue][color=green]
                        > > unable to comprehend the concept behind this. How is the compiler
                        > > design started...Where does one start.[/color][/color]

                        Try google with
                        bootstrapping compiler

                        and you will find some useful explanations
                        f.i.


                        Regards,
                        Rinie

                        Comment

                        • Ben Pfaff

                          #13
                          Re: &quot;The C compiler is Written in C&quot; What!

                          vek@station02.o hout.pharmapart ners.nl (Villy Kruse) writes:
                          [color=blue]
                          > The GNU C compiler is by the way written in K&R so any very old native
                          > pre-ANSI C compiler can compile it.[/color]

                          This is changing in GCC 3.4 according to gcc.gnu.org.
                          --
                          "The fact that there is a holy war doesn't mean that one of the sides
                          doesn't suck - usually both do..."
                          --Alexander Viro

                          Comment

                          Working...