Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Surely a left-field type of question but here goes.

Given the current state of machine learning, could an AST be generated to accommodate a given language?

And more importantly, can the form of an AST cause a difference in performance of the overall program?



> Given the current state of machine learning, could an AST be generated to accommodate a given language?

No machine learning required. It is certainly possible to automatically generate an AST based on a grammar.

The more interesting question is whether you can automatically generate a grammar based on samples of the language - https://en.wikipedia.org/wiki/Grammar_induction - although it is unclear why you'd bother trying for a programming language (as opposed to natural language).

> And more importantly, can the form of an AST cause a difference in performance of the overall program?

If you are compiling to machine code, or to bytecode for some VM, or transpiling to another source language (e.g. JavaScript): not really. The form of an AST could make a difference to compilation speed or the ease of implementing later stages of the compiler, but I can't see how it would directly make any difference to the performance of the compiled program.

However, if you are doing tree-based interpretation: Yes, differences in choice of AST can make a significant difference to runtime performance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: