Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm curious about the birth of the compiler. How did programming begin? Did people first build hardware that recognized a certain set of commands, or did people define a language and then build hardware around it? And on a related note, what was the first programming language?

share|improve this question
5  
1  
One of the sub questions was a question in it's own right: What was the first programming language written for computers?. –  Mark Booth Jul 9 '12 at 16:42
    
Surely this is something you could look up? –  Caleb Jul 9 '12 at 20:02
    
@Caleb read the comments in SkyDan's answer.. –  David Cowden Jul 9 '12 at 20:44
2  
@Brian Valid assumption, but turns out to be wrong. It’s not a chicken-egg problem at all, there’s a very clear answer (hint: the most highly voted below is wrong). Source code long predates compilers. –  Konrad Rudolph Jul 11 '12 at 20:09

6 Answers 6

up vote 18 down vote accepted

This has a very clear answer, actually: Source code came first – by a big margin.

Before giving the technical details, a bit of perspective:

The first programming languages were all translated into machine language or assembler by hand. The idea of using a piece of software to automate this translation (either via a compiler or evaluator) always came later, and was far from intuitive.

Consider this quote of the Wikipedia article on FORTRAN which illustrates the reluctance compilers had to face:

… the first FORTRAN compiler [was] delivered in April 1957. This was the first optimizing compiler, because customers were reluctant to use a high-level programming language unless its compiler could generate code whose performance was comparable to that of hand-coded assembly language. [emphasis mine]

=> By the time the FORTRAN compiler hit the market (1957), people were already happily programming both in assembly language and FORTRAN.

The case was similar for LISP (from Hackers & Painters):

Steve Russell said, look, why don't I program this eval …, and I said to him, ho, ho, you're confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bug, and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today..."

Once again, not only does the source code (in LISP) predate the interpreter, the latter wasn’t even implicit in the former.

But these developments are relatively late. Even not considering Charles Babbage’s Analytical Engine and Ada Lovelace’s related first program, there were programming languages in the 20th century which predated compilers:

Konrad Zuse’s Plankalkül and the mathematical construct of λ-calculus introduced by Alonzo Church. Both of these are indubitably formally specified programming languages, but neither had a compiler at the time.

To put this into perspective, λ-calculus is from the 1930s, and Plankalkül was developed around 1945. By contrast, the first FORTRAN compiler came out in 1957 (but again three years after FORTRAN was specified).

share|improve this answer
    
Great answer! I didn't know code used to be compiled by hand, but that makes sense. –  ckb Apr 24 '13 at 15:32

The algorithms were sorted out on paper, then the alus were wired up physically/mechanically (moving wires). to change the program you move the wires and run again.

Later the assembly language sorted out on paper, translated to machine code by hand, then using switches, etc to feed it into ram. Or punch cards, etc. Eventually you can make an assembler, then you can program in assembly not machine code, then you can make a compiler. Eventually you can bootstrap that compiler. And make new languages and new compilers, etc.

The first language was not a language, later the first language was assembly language. for every processor the first language is assembly language (derived from the machine code). The instruction set is designed first then the hardware to implement it then assembler, then compilers.

share|improve this answer

This question is pivots strongly on our semantic interpretation of 'source code'. If we define it as 'text-based computer instructions that are compiled', then presumably a compiler came first.

I'm more inclined to go with something more authoritative, such as Mark Harman's paper "Why Source Code Analysis and Manipulation Will Always Be Important" presented at the Tenth IEEE International Working Conference on Source Code Analysis and Manipulation

Definition 1 (Source Code): For the purpose of clarity ‘source code’ is taken to mean any fully executable description of a software system. It is therefore so construed as to include machine code, very high level languages and executable graphical representations of systems.

And I think your answer is implicit in that definition - source code most certainly came first.

share|improve this answer
    
“presumably a compiler came first” – only if you define “compiled” as “translated by an automatic tool”, rather than “translated to machine code by hand”. –  Konrad Rudolph Jul 12 '12 at 15:06
    
Very interesting paper. I like that definition of source code -- although it makes my question a non-question really.. –  David Cowden Jul 12 '12 at 18:33
    
@KonradRudolph isn't the unit that performs compilation, whether it's a machine, human, or divine intervention, called 'a compiler'? –  Kirk Broadhurst Jul 12 '12 at 23:37

Interpreters existed before compilers so source code existed before compilers.

There are some very interesting papers on the history of computing here. The source code for the FORTRAN II compiler is supposed to be available, but those links are broken.

This paper, from 1954, describes the Whirlwhind interpreter.

share|improve this answer

Programming began with people writing machine code directly into memory, onto punched cards and paper tape or even shorting links on a patch panel. Whether the hardware was built around the needs of the software or vice versa is difficult to tell. Certainly the earliest design for a turing complete programmable computer, Babbage's Analytical engine, pre-dated Ada Lovelace's first documented program.

As to the first programming language, I have argued that it was the machine language of Babbage's analytical engine (from the question What was the first programming language written for computers?)

To answer the question in your question title, since assembly language is source code, and assembly languages pre-date high level languages which could be compiled into assembler, the source code came first.

Also, a compiler has never been necessary, just convenient.

It is perfectly possible to write software directly into memory if you have memorised the appropriate op-code tables. In fact, some early computers required the user to punch in the bootstrap code on the front panel hex keypad to get them to boot, but you could tap in any code you liked and it would be run.

Admittedly as CPU's get more complex, this gets more difficult, but a simple instruction set like 6809, or Z80 (ignoring all the weird indexed modes) is relatively easy to program even without an assembler, let alone a compiler from a high level language.

If Babbage's analytical engine had ever been built, I'm sure there would have been a steampunk Mel, writing optimised programs directly onto loom cards.

share|improve this answer
1  
Did you actually read the definition of source code at that wikipedia link you posted? As said above, machine code is not source code. And machine code != assembly. Machine code was there first. –  occulus Jul 9 '12 at 13:47
    
@MarkBooth I think MIPS and AVR are even simpler.. –  David Cowden Jul 9 '12 at 14:56
4  
@occulus - In what way is assembly language not source code? Assembly language maps one assembly language instruction to one machine code and can be trivially assembled in your head, if you know your op code tables. Honestly, kids these days... *8') –  Mark Booth Jul 9 '12 at 15:02
1  
To me, assembly language is movl $0, -20(%rbp), whereas machine code is C745EC00000000, and it's the latter (well, something like it) that was first manually entered or read from paper tape. As to whether machine code counts as source code, I'm inclined to say "whatever floats your boat". If you're toggling it in manually, then yeah, I'd say it counts. –  John Bode Jul 9 '12 at 15:55
    
@JohnBode - Oh I agree, but given the 1:1 correspondence between assembly instructions and machine code instructions, assembly is just a matter of mechanical translation (assembly), the logic is identical. Compilation implies a much more complex many:many translation (though Occam is a high level language and many Occam statements mapped 1:1 onto Transputer instructions due to its MISC architecture. *8'). –  Mark Booth Jul 10 '12 at 9:40

The compiler was first. It was directly written in machine code, for the source could not be compiled with out a compiler.

Wikipedia articles like this one about Computer Languages can answer most of the questions, if not just pick one of the books by Tanenbaum like Structured Computer Organization , which can answer more questions than you can even ask :)

I can not say anything more specific, for your question is too broad.

share|improve this answer
20  
It could also be argued that the source was first, because for the very first "computers" the source was equivalent to the binary (i.e. they were programmed directly in the machine-readable language). –  Joachim Sauer Jul 9 '12 at 9:44
5  
@Joachim By definition, source code is human-readable text that is translated by the compiler into machine code. Machine code itself therefore is not source code. –  SkyDan Jul 9 '12 at 9:46
11  
The compiler was first, but it was implemented in biological neural networks. –  Den Jul 9 '12 at 10:00
7  
Why is this so highly voted? It’s wrong. Source code in high-level languages (notably λ-calculus, Plankalkül and LISP) long predates both compilers and interpreters. This isn’t even taking into account the semi-formal programs Ada Lovelace wrote. –  Konrad Rudolph Jul 11 '12 at 20:01
3  
@SkyDan What’s your definition then? I know of no sensible definition for which your answer is correct (both for “compiler” and “source code in a high-level language” – let alone low-level). –  Konrad Rudolph Jul 12 '12 at 6:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.