LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-08-2004, 08:56 PM   #1
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Rep: Reputation: 30
Compiler conundrum: Which came first, a compiler, or it's source code?


It's been bothering me for awhile now.

How was the first compiler developed, being that no compiler was available to compile it?

I'm guessing it was some sort of internal part of the hardware, manually built-in.
 
Old 01-08-2004, 09:25 PM   #2
h/w
Senior Member
 
Registered: Mar 2003
Location: New York, NY
Distribution: Debian Testing
Posts: 1,286

Rep: Reputation: 46
a compiler is not one piece of software. it starts out with a lexer, then a parser ... and ends with the assembly code which the linker takes to map virtual addr to the physical addresses. so, basically, it's a tool which checks for syntax and semantics of a language, creates the code readable by the machine, and ...
 
Old 01-08-2004, 09:38 PM   #3
mr_segfault
Member
 
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95

Rep: Reputation: 15
First was machine code. : first programs written directly in the hardware's machine code

Then was assembler: A program written in machine code to interpret asm into machine code.

Then was a compiler: a set of programs (lexical analyser, parser linker etc) which could convert source code to assembler/machine code.

Of cource it is not done like that today
 
Old 01-08-2004, 10:53 PM   #4
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ya, they built simple (relatively anyway) compilers that they used to compile the more complex compilers and it all just evolved over time.... basically. But as was said above. A compiler is really a group of several different tools and then were built mostly from the ground up the first time.
 
Old 01-09-2004, 03:57 AM   #5
nowonmai
Member
 
Registered: Jun 2003
Posts: 481

Rep: Reputation: 48
I used to have a box that plugged into the 'user' port of my C64. It had a bunch of switches and leds and basically allowed me to toggle code directly into the memory. Even the smallest program was tedious enough, but it was fun and taught me a lot about programming early computers.
 
Old 01-09-2004, 10:29 AM   #6
fr0zen
Member
 
Registered: Nov 2003
Location: 127.0.0.1
Distribution: xubuntu
Posts: 217

Original Poster
Rep: Reputation: 30
Hmm. This is interesting. Thanks for all your replies. Compiling is part of my daily routine (obviously) and I've been curious about its origins. I think I have a better understanding of just how advanced things have gotten.
 
Old 01-09-2004, 10:49 AM   #7
DavidHayes
LQ Newbie
 
Registered: Jul 2001
Posts: 16

Rep: Reputation: 0
An interesting point is that most compilers are written in the language they are built to compile...
A good example is c#. The first c# compiler obviously couldn't have been written in c# so they must have built a compiler in another language to develop the first c# compiler.
 
Old 01-10-2004, 02:12 PM   #8
wgself
LQ Newbie
 
Registered: Jan 2004
Location: Charlottesville, VA
Distribution: RedHat 8.0
Posts: 9

Rep: Reputation: 0
early compilers

An example was the transition form C to C++. The first C++ systems had preprocessors that converted the C++ source to C source then ran it through a regular C compiler. It took a few years for vendors to deliver compilers that compiled C++ directly.
 
Old 01-10-2004, 02:18 PM   #9
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
actually, there was i believe a 'b' programming language, which was woefully inadequate, the 'c' language's origin (as alot of you probably know) was for the purpose of making the unix operating system more portable instead of having to re-write (or at least alot of adapting) it in assembly on everytime a new mainframe was developed hence the c language was born, for this purpose...
 
Old 01-10-2004, 02:25 PM   #10
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
There was also a precursor to the language B. I haven't ever been able to find an official name for it anywhere, but one might assume it was called A. I suppose it is even possible the original C compilers were built with B but I am pretty sure that is not how Stallman started GCC. Maybe somebody should download the first version of GCC and see how it is built, and also see if it can build itself once it is built. My guess is it can.
 
Old 01-17-2004, 04:54 PM   #11
Chris Weimer
Member
 
Registered: Jan 2004
Location: NYC
Distribution: Fedora XFCE
Posts: 91

Rep: Reputation: Disabled
Quote:
There was also a precursor to the language B.
Fortran, or something like that
 
Old 01-17-2004, 11:17 PM   #12
wgself
LQ Newbie
 
Registered: Jan 2004
Location: Charlottesville, VA
Distribution: RedHat 8.0
Posts: 9

Rep: Reputation: 0
fortran - stands for formula translation and it predates c by seversl years. It was developed by IBM and some of it's customers in the mid fifties. For a long time it was the most used language for technical problems.
c was not based on it at all though
 
Old 01-18-2004, 12:05 AM   #13
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092
Blog Entries: 1

Rep: Reputation: 90
there were a, b and c... as much as I know... anyways those things are "lost" in history.... perhaps in a million years there will be paloenthologists ready to clear it up.

The fact is that in the "early ages" programs were written directly to binary code.... no pnemonics.... only bynary data.

Some people must have realized that a "compiler" was necessary in order to share code between architectures... and of course, to be able to program at a "higher level".

First compiler (or compilers)..... written in bynary, of course. After that.... why write in bynary anymore?... use the compiler you made before to "build" a new compiler. (sound paradox-tical, right?)
 
Old 01-18-2004, 01:02 AM   #14
wgself
LQ Newbie
 
Registered: Jan 2004
Location: Charlottesville, VA
Distribution: RedHat 8.0
Posts: 9

Rep: Reputation: 0
Actually the intermediate step is assembler. The first programs written in binary quickly gave way to assembler as it was far more 'human readable'. After assembler the macro assembler came along which allowed reuse of modules of code. One of Microsoft's early success was a macro assembler for Intel chips that was the standard for years. MASM was still supported until a few years ago at least.
The early compilers compiled C or Fortran or whatever high level language into assembly code then ran it through an assembler then it was linked. These steps were slowly merged into a single process which started with source and produced an executable.
Many compilers still support a switch to output assembly language for debugging and optimization.
 
Old 01-18-2004, 10:12 AM   #15
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
Ya, gcc has an option to see the assembly code it produces. It is quite interesting to look at when you compare how it assembles a C program at different levels of optimization. The assembly code at no-optimization is actually quite readable and easy to understand. However, it starts to get cryptic very quickly.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for C compiler default output... configure: error: C compiler cannot create fiorejm Linux - Software 6 11-12-2009 12:35 PM
Building compiler from source corbis_demon Programming 2 06-08-2005 08:34 AM
how do I compile programs from source with a secondary compiler? jarobman Programming 3 02-16-2005 05:57 PM
Error - no gcc3 or cc compiler when installing source code bshelton Linux - General 1 09-16-2003 02:26 PM
new compiler, still no source icyfire Linux - Newbie 8 02-20-2002 07:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration