takada
takada

Reputation: 41

How did the scala compiler first compile?

I read the scala compiler recently.

Scala compiler written by Scala.

I realized. How did it first compile?

Scala didn't exist yet...right?

Upvotes: 3

Views: 424

Answers (2)

Jörg W Mittag
Jörg W Mittag

Reputation: 369458

I read the scala compiler recently.

Scala compiler written by Scala.

I realized. How did it first compile?

It was compiled with the previous version of the Scala compiler, which was written in Java. Note that the name of the current Scala compiler is "nsc", which stands for "new Scala compiler" – that should give you a hint that there existed a compiler before the current one. And that compiler was written in Java.

However, it is not actually necessary that the compiler written in Scala is the second compiler. It could also be the first compiler. How would that work?

Well, the first option is that before there was a Scala compiler, there could have been a Scala interpreter. Then, you could have used that interpreter to run the Scala compiler and compile itself.

The second option is that the compiler could have been translated by hand into another language. Technically speaking, this is also compilation or interpretation (depending on how exactly you perform it), just done by a human brain instead of a program. Niklaus Wirth did this with the first version of the Oberon compiler. The Oberon compiler was always written in Oberon, there was never a different version. It was hand-translated by his students into a Fortran dialect, the translated version compiled by the Fortran compiler, then the compiled version was used to compile the original version.

Scala didn't exist yet...right?

That is a completely different question, actually. A language can exist without there ever having been an implementation. For example, Plankalkül existed for ~30 years, until it was implemented for the very first time. ISWIM has never been implemented AFAIK, and yet, it is a very important programming language.

Upvotes: 0

OlivierBlanvillain
OlivierBlanvillain

Reputation: 7768

The first version of the Scala compiler was written in Java.

Upvotes: 3

Related Questions