0

This is my first question so be nice lol...

Think of it this way. Python is written in C, which is written in an older C compiler, which is written in an even older C compiler, which is written in B, which is written in (I think) BCPL. I am not sure what BCPL is written in, but it seems that there must be an original language somewhere?

In other words, every programming language is written in an older programming language. So what came first, and what was that coded in?

8

What are programming languages written in?

Programming language compilers and runtimes are written in programming languages — not necessarily languages that are older or are different than the one they take as input.  Some of the runtime code will drop into assembly to access certain hardware instructions or code sequences not easily obtained through the compiler.


Once bootstrapped, programming languages can self-host, so they are often written in the same language they compile.  For example, C compilers are written in C or C++ and C#'s Roselyn compiler is written in C#.

When the Roselyn compiler adds a new language feature, they won't use it in the source code for the compiler until it is debugged and working (e.g. released).  This akin to the bootstrapping exercise (limited to a new feature rather than the whole language).

But to be clear, there is the potential (and often realized) for the programming language to be written in the latest version of its input language.


So what came first, and what was that coded in?

Machine code came first, and the first assemblers were themselves very very simple (early assembly languages were very easy to parse and generate machine code for), they were written in machine code, until bootstrapped and self-hosted.

| improve this answer | |
7

Think of it this way. Python is written in C,

No, it is not.

You seem to be confusing a Programming Language like Python or C with a Programming Language Implementation (e.g. a Compiler or Interpreter) like PyPy or Clang.

A Programming Language is a set of semantic and syntactic rules and restrictions. It is just an idea. A piece of paper. It isn't "written in" anything (in the sense that e.g. Linux is "written in" C). At most, we can say it is written in English, or more precisely, in a specific jargon of English, a semi-format subset of English extended with logic notation.

Different specifications are written in different styles, here is an example of some specifications:

There are multiple Python implementations in common use today, and only one of them is written in C:

In other words, every programming language is written in an older programming language. So what came first, and what was that coded in?

Again, you are confusing Programming Languages and Programming Language Implementations.

Programming Languages are written in English. Programming Language Implementations are written in Programming Languages. They can be written in any Programming Language. For example, Jython is a Python implementation written in Java. GHC is a Haskell implementation written in Haskell. GCC is a C compiler written in C. tsc is a TypeScript compiler written in TypeScript. rustc is a Rust compiler written in Rust. NSC is a Scala compiler written in Scala. javac is a Java compiler written in Java. Roslyn is a C# compiler written in C#.

And so on and so forth, there really is no restriction on the language used to implement a compiler or interpreter. (There is a theoretical limitation in that an interpreter for a Turing-complete language must also be written in a Turing-complete language.)

| improve this answer | |
  • Programming Languages can also be written in Human Languages other than English. – user253751 Oct 15 at 10:51
  • Now that the difference between language and language implementation is clear, the question remains the same (or almost) _What are programming languages implementations written in? Not complaining about this answer (which I like!) but it does not fully respond to the "implicit" question. Otherwise would be the perfect answer – Laiv Oct 15 at 11:41
  • As @Laiv says, although this highlights the difference between the languages and their implementations, the question still stands. All implementations are written in other languages, on and on and on... – fartgeek Oct 15 at 16:19
  • @Laiv: I am answering that question in the last two paragraphs: language implementations are written in languages. Now, if you want to know specifics, then I cannot answer that. Programming language choice is often a subjective personal choice, so they are written in whatever language the author chooses to. – Jörg W Mittag Oct 15 at 16:27
  • @fartgeek: Programming language choice is often a subjective personal choice, so a language implementation will typically be written in whatever language the author likes. I personally like Scala and Ruby, so if I had to implement a language, I would likely do it in Scala or Ruby, but that is a completely personal choice, and someone else may choose a different language. – Jörg W Mittag Oct 15 at 16:28
6

Each machine has an instruction set it natively executes.

That instruction set is the first language.

The first higher level language was assembly, literally allowing the programmer to write a long expression like mov ax bx instead of the corresponding binary word.

The first compiler was written in machine language, though more accurately it would have been called an assembler but today's standards. It would have taken the assembly language and translated it to the binary encoding.

This has happened many times over for many different machines until the first cross-compilers were developed that could rewrite a program into another machine language.

Even now though there are still languages who are first implemented in terms of a machine language.

| improve this answer | |
  • All true, but worth pointing out that even before we had the actual machines we had the instruction sets. This all used to just be mathematics that ran in our heads. We've come a long way. – candied_orange Oct 15 at 1:05
  • @candied_orange True, Lambda the Ultimate – Kain0_0 Oct 15 at 2:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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