I wonder…
Code. Punchcards, and directly typing in values.
code
My guess is:
Code existed first - IF you qualify machine language as ‘code’
The first compiler was written in machine language directly (it had to, as no compilers existed).
That compiler took assembler and generated machine code.
The first C compiler was then written in assembler.
Then a the C compiler was re-written in C and compiled with the C compiler written in assembler.
Then it’s turtles all the way down…
They used to enter the code directly on the computer and then later even would program the gates permanently that create the program, which which evolved to be a large part of the functionality of modern processors - pre-created ready-to-run libraries.
Code. Ada Lovelace wrote a program to calculate Bernoulli numbers in 1843. (See program here, page 79.)
If you count the old looms that used punch cards, it’s even older. First graphics processor too!
Good point! I had thought about mentioning those, or even the antikythera long, long before that, but I think Lovelace’s program is the first example of proto-modern algorithmic code. I hadn’t thought of the loom as a graphics processor, though. Talk about old school graphics!
I was thinking that before programs
there had to be direct setting of binary flags or switches or vacuum tubes or whatever, and only later was there any translation from something else. If you’ve ever written in assembly language you’ll know its as close to the hardware as you can get without writing binary codes directly… which is sometimes possible (self modifying code).
Has no one heard of an abacus, sundial, or many much older forms of computing that proceed programming?
Rocks and other miscellaneous items predate those.
I’ll play devil’s advocate here and argue that abacuses, etc., (and rocks ;)) are tools to assist human computers, whereas code in the sense of the original post refers to an instruction set that runs on an automated computer.
But now that I think about it, humans manually translated high-level algorithms into machine-level instructions long before programs were written to automate the translation. That makes humans the first compilers, so I guess compilers predate code after all.
The first C++ compiler was written in C++. Chew on that!
Maths.
It must’ve been code because you only have 2 options, which is binary.
Before code you could write logic directly into switches. I still ‘write’ logic in pneumatics or relays from time to time for my day job.
IIRC at least some of the first computers operated on base-10.
Babbage computer was base 10 (wasn’t actually built till many years later), and WITCH was also decimal.
But the question was which came first, code or compiler. Those are more like peripherals to help the human computer.
First came interpreter of instructions(for lamp computers that was reader of perfocards/punchcards/whatever else you call them). Was that compiler or not? It does transform input data (from punchcards into electronic signal) so it can be called so. But assuming we don’t say that our modern processors ‘compile’ instructions, but ‘interpret’ instead, I’d say first was interpreter, then code, then compiler. If you say interpreting code from one type of instructions into another is compiling - then hardware compiler first. It all depends on how you define it.
There was no interpreter. Just instructions.
Imagine a music box.
https://www.youtube.com/watch?v=rvK83xglHGw
That would be roughly equivalent to the first computers.
Command directly performs operations. “Interpreter” assumes there is an intermediate form command needs to be translated from one form into another to be executed. In first machine, there’s no intermediate form and nothing to translate. Therefore, no interpreter and no compiler.