473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

"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 25407
Unbiased_me <ma*********@yahoo.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.helsinki.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_me" <ma*********@yahoo.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*********@yahoo.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**********@noos.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**********@noos.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_Keith) 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_me" <ma*********@yahoo.com> wrote in message
news:43**************************@posting.google.c om...
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*********@yahoo.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
> 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.


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++.
Nov 13 '05 #11
> > 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.


Try google with
bootstrapping compiler

and you will find some useful explanations
f.i.
http://homepage.ntlworld.com/edmund....bcompiler.html

Regards,
Rinie
Nov 13 '05 #12
ve*@station02.ohout.pharmapartners.nl (Villy Kruse) writes:
The GNU C compiler is by the way written in K&R so any very old native
pre-ANSI C compiler can compile it.


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

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

Similar topics

3
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...
7
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...
12
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
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...
0
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
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.