Show HN: A self-hosted js compiler in 1k loc
github.com
github.com
For a JavaScript compiler (or VM) to be genuinely described as self-hosting, it would need to be able to run using itself, without depending on an existing implementation such as V8, ChakraCore etc. The hard part is not outputting code that can be evaluated by JS itself, but implementing the semantics of JS in terms of a lower-level of abstraction, ideally native code.
I think it could still be deemed a "compiler" even if it output the same language if it was doing some significant transformation or modification of it.
But, yes, in this case I think you're right and a "pretty-printer" is a better description of it.
a program that converts instructions into a machine-code or lower-level form so that they can be read and executed by a computer
Since they add features, I guess this would qualify as it outputs a "lower level form", but man it's really pushing the definition.
Apparently the answer is: to Javascript. It's what some call a transpiler: it compiles Javascript plus some extra features down to a more "vanilla" Javascript (es5?). I tend to dislike the term transpiler (transpilers are just compilers that target high-level languages), but I guess in this case the term would have helped me understand what was meant!
find ./chrome-v8-src | xargs sed -i ':a;N;$!ba;s/\n//g'
Boom!
Very elegant and easily extensible.