I was looking at the Kotlin Github page and I noticed that the Kotlin language itself is mostly written in Kotlin: 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?
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.
Kotlin is inspired by existing languages such as Java, C#, JavaScript, Scala and Groovy.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With