Re:Show HN: A self-hosted js compiler in 1k loc
by munificent on Friday February 10, 2017 @03:04PM
(#13618417)
> It isn't really a compiler, because the target language is the same as the source.
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.
Re:Show HN: A self-hosted js compiler in 1k loc
by EpicEng on Friday February 10, 2017 @08:54PM
(#13620485)
Compiler:
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.
Re:Show HN: A self-hosted js compiler in 1k loc
by bbcbasic on Friday February 10, 2017 @08:51PM
(#13620473)
I'd say transpiler, or at least preprocessor. It does add a language feature, after all.
Re:Show HN: A self-hosted js compiler in 1k loc
by Schampu on Sunday February 12, 2017 @08:24AM
(#13628210)
I just added a second feature called "inout", which lets you pass variables by reference
Re:Show HN: A self-hosted js compiler in 1k loc
by pvg on Friday February 10, 2017 @04:07PM
(#13618918)
'Pretty-printer' is not quite right either. Nobody bootstraps pretty-printers by repeatedly running them through themselves and extending them which I think was kind of the point of the exercise here.
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.