Re:Ask HN: Which TypeScript codebase should I study to get b...
by dcuthbertson on Thursday November 09, 2017 @12:54PM
(#15664346)
From what I recall, start by writing a minimal compiler for language X in some other language, Y, and compile it. Now you have an X-compiler written in Y.
Rewrite the minimal compiler in X, and compile it using the one that was written in Y. That gives you an X-compiler written in X compiled from one written in Y.
To be sure _that one_ works, recompile your X source code with that last compiler. Now you have a compiler written in X and built with one also written in X.
Continue to add more features written in minimal-X to get X-compilers with more X features.
Re:Ask HN: Which TypeScript codebase should I study to get b...
by pjmlp on Thursday November 09, 2017 @05:03PM
(#15666211)
Just as small improvement, for the first step an interpreter is a better approach, just to ease the bootstraping process by not having to write a compiler backend twice.
Rewrite the minimal compiler in X, and compile it using the one that was written in Y. That gives you an X-compiler written in X compiled from one written in Y.
To be sure _that one_ works, recompile your X source code with that last compiler. Now you have a compiler written in X and built with one also written in X.
Continue to add more features written in minimal-X to get X-compilers with more X features.