473,544 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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
Nov 13 '05 #1
12 25426
Unbiased_me <ma*********@ya hoo.com> scribbled the following:
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.
"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.
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
Off-topic.
Manas Mittal


--
/-- Joona Palaste (pa*****@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
Nov 13 '05 #2

"Unbiased_m e" <ma*********@ya hoo.com> wrote

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.

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.
Nov 13 '05 #3
In 'comp.lang.c', ma*********@yah oo.com (Unbiased_me) wrote:
I recently read in book that the C compiler is written in C. I unable
Nonsense. The is no "The C compiler". There are thousand of C compilers.
to comprehend the concept behind this. How is the compiler design
started...Where dodoes one start.
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.
I tried Googling for the answer that C is written in C, however the
- '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)
web search proved futile.
You asked the wrong question.

Try "how was the first C compiler written"

3rd answer:

http://cm.bell-labs.com/cm/cs/who/dmr/primevalC.html
C # and .net is written in .net...What!, and the list goes on


Nonsense again.

--
-ed- em**********@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/
Nov 13 '05 #4
Emmanuel Delahaye <em**********@n oos.fr> writes:
[...]
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.


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) ks*@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"
Nov 13 '05 #5
"Unbiased_m e" <ma*********@ya hoo.com> wrote in message
news:43******** *************** ***@posting.goo gle.com...
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.


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
Nov 13 '05 #6
Unbiased_me wrote:
I tried Googling for the answer that C is written in C, however the
web search proved futile.


Try:
http://www.google.com/search?q=%22co...in+itself%22+C
Nov 13 '05 #7
bd
On Sat, 26 Jul 2003 10:36:49 -0700, Unbiased_me wrote:
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.
The first C compiler was not written in C. Many of the rest were, however.
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


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.

Nov 13 '05 #8
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
ma*********@yah oo.com
Nov 13 '05 #9
On 31 Jul 2003 00:18:39 -0700,
Suresh Kumar J <su****@sankhya .com> wrote:

I recently read in book that the C compiler is written in C. I unable


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.


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
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5809
by: Tim Freeman | last post by:
Doing an independent study with Dave Beazley this quarter, Atul Varma has written a C compiler on his own in Python. It generates annotated x86 assembly code from arbitrary C files. Quoting Atul's website: * The different stages of compilation are encapsulated in visitor classes, which (in my opinion) makes the code quite readable, and...
7
2067
by: winlinchu | last post by:
Hi! I use Python, and writing some extension modules I think which could be written an C compiler, useful only to compile extension modules (I not think an GCC!!!!), so that the user not have to use GCC, Microsoft Visual C++, or other. It must have an common API to all platforms, even if obviously the implementation is various. Could be...
12
1433
by: Ralf Dieholt | last post by:
I still don´t get it - what is the advantage of C ? I can program anything in BASIC V2 on a C64, does C have any advantages over BASIC V2 ? Seems to be more cryptic than BASIC to me.
19
2046
by: petantik | last post by:
Where can I find a good resource, on the web, that will give me a good comprehensive idea of how to write a compiler in C for C or maybe another language. http://petantik.blogsome.com - A Lucid look at Reality ... maybe?
0
971
by: The ants are driving me crazy | last post by:
Has anyone else seen this blog? http://www.panopticoncentral.net/archive/2007/05/24/20730.aspx
61
6892
by: giveitawhril2008 | last post by:
I'm just learning about Python now and it sounds interesting. But I just read (on the Wiki page) that mainstream Python was written in C. That's what I was searching for: Python was written in what other language? See, my concern was something like: OK, if Python is so hot, then, hopefully someone is writing it in assembly language for each...
0
7449
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7385
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7642
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5950
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5316
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4938
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1861
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
688
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.