1

I have been poking around at the TypeScript compiler and found this curious statement in the language spec:

TypeScript compiler is implemented in TypeScript

Is this even possible? I must believe that tsc (TypeScript Compiler) must have largely been developed in Javascript, but maybe I am missing something here.

1
  • 1
    Well, the GCC compiler suite (for C, C++, etc.), is written primarily in C and C++, so TypeScript isn't the only specimen of "compiler for X written in X" out there. Obviously, at the start, a different compiler must have been used until the code was to a point where it could be considered "self-hosting", but that idea isn't really that unusual... Commented Mar 26, 2013 at 14:28

1 Answer 1

4

It is true. You can read the code yourself.

The key to bootstrapping a language like this is that you do start in JavaScript, gradually refactoring your code into TypeScript as you add language features. It's been a very long time, though, since the TypeScript compiler was pure JS. Obviously this does cause some pain whenever breaking design decisions are made (if you poke around in the testcases you'll see references to things like 'oldclass' and 'es6class' and other historical oddities).

Sign up to request clarification or add additional context in comments.

3 Comments

Being self-hosted is a point of pride for most designers or communities. See: en.wikipedia.org/wiki/Bootstrapping_%28compilers%29
it is not just about pride, also a powerful self-validation tool
There is also an alternative to a cyclic bootstrap: growing a language. But, I doubt this approach will work on top of anything JavaScript-based.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.