News for hackers. Stuff that matters.
Re:How to implement a programming language in JavaScript by tumurinn on Wednesday June 29, 2016 @12:09AM (#11999435)
Just wondering if it is true that most of the modern language parsers are written in C?
Re:How to implement a programming language in JavaScript by rtpg on Wednesday June 29, 2016 @04:11AM (#12000186)
I don't think this is true. Loads of FP languages are self-hosted.
Re:How to implement a programming language in JavaScript by sjrd on Wednesday June 29, 2016 @04:26AM (#12000241)
Not only FP. Lots of languages are self-hosted. So actually most modern parsers are not written in C, since they are written in the language they parse.
Re:How to implement a programming language in JavaScript by lifthrasiir on Wednesday June 29, 2016 @12:47AM (#11999553)
Probably true, but only because the implementation language for them is also C. Some of them also frequently use a mix of the implementation language and grammar specification DSL like yacc.
Re:How to implement a programming language in JavaScript by sebcat on Wednesday June 29, 2016 @01:25AM (#11999674)
Use of DSLs and tools like flex and bison makes the implementation a whole lot more reliable (but only if they're used, and some commonly run languages have a very implementation-specific grammar).

consider:

    input:    /* empty string */
            | input line
    ;
    
    line:     '\n'
            | exp '\n'  { printf ("\t%.10g\n", $1); }
    ;
    
    exp:      NUM                { $$ = $1;         }
            | exp '+' exp        { $$ = $1 + $3;    }
            | exp '-' exp        { $$ = $1 - $3;    }
            | exp '*' exp        { $$ = $1 * $3;    }
            | exp '/' exp        { $$ = $1 / $3;    }
            | '-' exp  %prec NEG { $$ = -$2;        }
            | exp '^' exp        { $$ = pow ($1, $3); }
            | '(' exp ')'        { $$ = $2;         }
    ;
http://dinosaur.compilertools.net/bison/bison_5.html#SEC27
Re:How to implement a programming language in JavaScript by pcr0 on Wednesday June 29, 2016 @09:17AM (#12001412)
Python, Ruby, PHP: C

JS: no standard parser, but V8(chrome), SpiderMonkey(firefox) and Chakra(edge) are all C++

Go, C, C++: self-hosted (written in the same language)

Java, Erlang: parser/compiler self-hosted, but VMs written in C.

Re:How to implement a programming language in JavaScript by nv-vn on Wednesday June 29, 2016 @10:14AM (#12001738)
I doubt it. If anything, C++, but even that doesn't seem likely. The vast majority of languages seem to be self-hosted. A good portion compilers or interpreters in C or C++ probably use (F)lex and Yacc/Bison so even saying C or C++ are the most popular choice (but not necessarily the majority) sounds like a stretch.
Re:How to implement a programming language in JavaScript by matiasb on Wednesday June 29, 2016 @01:55AM (#11999765)
Go is now written in Go
Re:How to implement a programming language in JavaScript by spriggan3 on Wednesday June 29, 2016 @03:20AM (#12000019)
It used to be written in C before bootstrapping.