Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the Kotlin language written in Kotlin?

I was looking at the Kotlin Github page and I noticed that the Kotlin language itself is mostly written in Kotlin:enter image description here I am just wondering, how is it possible for a language to be mostly written in it's own language? Wouldn't the compiler need to be written (in a different language) before you can even use the language being created?

like image 928
eeze Avatar asked Aug 11 '18 18:08

eeze


People also ask

Is Kotlin written in Kotlin?

Kotlin used the Java programming language for its initial implementation, then most of the Kotlin compiler's source code got rewritten to Kotlin. Now, most of new code that is added to the Kotlin compiler codebase is written in Kotlin.

What language is Kotlin made of?

 Kotlin is inspired by existing languages such as Java, C#, JavaScript, Scala and Groovy.

Is Android written in Kotlin?

Kotlin is officially supported by Google for Android development, meaning that Android documentation and tooling is designed with Kotlin in mind. Certain Android APIs, like Android KTX, are Kotlin-specific, but most are written in Java and can be called from either Java or Kotlin.

How do I write to Kotlin?

Kotlin write file with PrintWriter txt file. The printWriter returns a PrintWriter for writing the content to the file. The use method executes the given block function on the file and then closes it. With println we write a string to the file including a terminating new line.


1 Answers

The process of writing a compiler in its source language is called bootstrapping.

In fact, at its earliest stage, it involves writing the compiler in another (often a lower-level) programming language, supporting a reasonable subset of the features designed for the compiler's source language.

Then, using the subset of the features that were implemented in the first step, one can rewrite the compiler's code in the language it compiles. It gives you a compiler of a subset of the language that is written in the same language.

Afterwards, one can add new features (not using them in the code at first) and build a more powerful compiler each time, and so on iteratively.

Kotlin used the Java programming language for its initial implementation, then most of the Kotlin compiler's source code got rewritten to Kotlin. Now, most of new code that is added to the Kotlin compiler codebase is written in Kotlin.

like image 74
hotkey Avatar answered Oct 22 '22 04:10

hotkey